Help, I'm confused!

  1. According to the SDL wiki documentation on SDL_SetVideoMode (see it here:
    http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode), they say
    SDL_DOUBLEBUF is only valid with SDL_HWSURFACE. So, what if I write
    something like this:
    pScreen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);

  2. Someone suggest that hardware surface should be used in fullscreen mode.
    Why? Are there any differences or any potential problems if I create a
    hardware surface in windowed mode? And, is double buffer valid in windowed
    mode?

  3. SDL_SetVideoMode returns the framebuffer surface. What is this
    framebuffer really? Is it the so-called off-screen framebuffer? ('coz we
    have to use SDL_UpdateRect (and the like) to make actual changes on the
    screen).

  4. Are there any typical advices on choosing the appropriate flags for some
    specific purposes?

Hi

  1. According to the SDL wiki documentation on SDL_SetVideoMode (see it
    here:
    http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode), they say
    SDL_DOUBLEBUF is only valid with SDL_HWSURFACE. So, what if I write
    something like this:
    pScreen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);

I think it will “ignore” the SDL_DOUBLEBUF flag

  1. Someone suggest that hardware surface should be used in fullscreen
    mode.
    Why? Are there any differences or any potential problems if I create a
    hardware surface in windowed mode? And, is double buffer valid in windowed
    mode?

Probably depends on the hardware. I have used HW surfaces in windowed mode
with no problems.

  1. SDL_SetVideoMode returns the framebuffer surface. What is this
    framebuffer really? Is it the so-called off-screen framebuffer? ('coz we
    have to use SDL_UpdateRect (and the like) to make actual changes on the
    screen).

This is also kind of a “this is what I think” answer, but here we go. If you
HW surface the surface will recide ON the graphics card. Well, in the memory
of the graphicscard. And a SW surface will recide in the system memory.

  1. Are there any typical advices on choosing the appropriate flags for
    some
    specific purposes?

Well, since (if I’m right) a HW surface recide on the card it will blit alot
faster. But it is NOT very fast to read from it. The SW surface is farily
fast to read from thugh but gives you a penelty in blitting speed.

Also, when it comes to speed. Make sure that the surfaces you use (images
etc) have the right depth to avoid convertions and thus loosing speed.

Best regards
Daniel Liljeberg

p.s.
Let me know wich of my thoughts are incorrect :wink:

Thank you very much for your answer. Just one thing still uncleared to me:

pScreen = SDL_SetVideoMode(…);
.
.
/* some blit here /
.
.
/
update the screen /
SDL_UpdateRect(pScreen,…); /
or SDL_Flip() if we’re using hwsurface and
doublebuf */

Yeh, the problem is that this logic makes me think pScreen (the
"framebuffer" returned by SDL_SetVideoMode) is kind of a backbuffer!! and
thus SDL actually makes use of double buffer technique in “normal” case!!!
Any ideas?

DAMiEN wrote:

Hi

  1. According to the SDL wiki documentation on SDL_SetVideoMode (see it

here:

http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode), they say
SDL_DOUBLEBUF is only valid with SDL_HWSURFACE. So, what if I write
something like this:
pScreen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);

I think it will “ignore” the SDL_DOUBLEBUF flag

Not exactly. SDL will transparently set the SDL_HWSURFACE flag when
SDL_DOUBLEBUF is requested, so that this previous line could in some
situations return a hardware surface.

  1. Someone suggest that hardware surface should be used in fullscreen

mode.

Why? Are there any differences or any potential problems if I create a
hardware surface in windowed mode? And, is double buffer valid in windowed
mode?

Probably depends on the hardware. I have used HW surfaces in windowed mode
with no problems.

I should to add that this will never fail. This might give faster/slower
rendering, but the app will work (provided you’re locking/unlocking
surfaces when it’s needed).

Stephane