Why surfaces?

Hello list,

I’ve been wondering lately, why does SDL use surfaces? SDL is based on
OpenGL, so why not instead of this:—
SDL_Surface *screen = SDL_SetVideoMode(…);
SDL_Surface *image = SDL_LoadBMP(…);
while (1)
{
SDL_BlitSurface(image, NULL, screen, NULL);
}

we get something like this:


SDL_TextureContainer *screen = SDL_SetVideoMode(…)
SDL_Texture *image = SDL_LoadBMP(…)
while (1)
{
SDL_ShowTexture(screen, 0, 0, image);
}

You see what I mean? This approach is of course a lot faster. No matter
how fast SDL’s blitting algorithms may be, nothing beats hardware
graphics processing.

Disclaimer: I’ve only done very little 3D graphics programming, so don’t
flame me if I’m being dumb. :stuck_out_tongue:

That’s very close to the kind of rendering that SDL 1.3 is doing =)

-DarrenOn Fri, 2008-10-10 at 04:51 -0500, Leo Cabrera wrote:

Hello list,

I’ve been wondering lately, why does SDL use surfaces? SDL is based on
OpenGL, so why not instead of this:


SDL_Surface *screen = SDL_SetVideoMode(…);
SDL_Surface *image = SDL_LoadBMP(…);
while (1)
{
SDL_BlitSurface(image, NULL, screen, NULL);
}

we get something like this:


SDL_TextureContainer *screen = SDL_SetVideoMode(…)
SDL_Texture *image = SDL_LoadBMP(…)
while (1)
{
SDL_ShowTexture(screen, 0, 0, image);
}

You see what I mean? This approach is of course a lot faster. No matter
how fast SDL’s blitting algorithms may be, nothing beats hardware
graphics processing.

Disclaimer: I’ve only done very little 3D graphics programming, so don’t
flame me if I’m being dumb. :stuck_out_tongue:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello list,

I’ve been wondering lately, why does SDL use surfaces?
SDL is based on
OpenGL, so why not instead of this:

No it’s not. SDL may support OpenGL but it does not require it to be available. Conversely it does require that images can be used without the availability of OpenGL which is why SDL_Surfaces can be used entirely in main memory as structs with a pointer to the array for the pixel data held as nothing more than bytes in RAM.— On Fri, 10/10/08, Leo Cabrera wrote:

From: Leo Cabrera
Subject: [SDL] Why surfaces?
To: “A list for developers using the SDL library. (includes SDL-announce)”
Date: Friday, October 10, 2008, 9:51 AM

SDL has the concept of a software surface, and that of a hardware
surface. Basically, software surfaces are the first thing you
describe, and hardware surfaces are the second.
The SDL website is full of documentation about this and how it works,
I highly advise to take a look!

StephaneOn Fri, Oct 10, 2008 at 11:51 AM, Leo Cabrera wrote:

Hello list,

I’ve been wondering lately, why does SDL use surfaces? SDL is based on
OpenGL, so why not instead of this:


SDL_Surface *screen = SDL_SetVideoMode(…);
SDL_Surface *image = SDL_LoadBMP(…);
while (1)
{
SDL_BlitSurface(image, NULL, screen, NULL);
}

we get something like this:


SDL_TextureContainer *screen = SDL_SetVideoMode(…)
SDL_Texture *image = SDL_LoadBMP(…)
while (1)
{
SDL_ShowTexture(screen, 0, 0, image);
}