SDL_DOUBLEBUF | SDL_HWSURFACE + Windowed mode

Hi,

Is it possible to set up SDL with double buffering and hardware surfaces
in windowed mode on Windows? Manipulating the surface and calling
SDL_Flip(…) results in flicker when in windowded mode, in fullscreen
mode it looks beautiful.

Thanks,

-Tim

I use OpenGL and SDL_GL_SWAPBUFFERS in window mode with DOUBLE BUFFER and it
goes ok.
When I used SDL_FLip flicks occurred.

Maybe Sam can change the function name to SDL_Flick, lol

Cheers,
Bruce> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of Tim
M.
Sent: quarta-feira, 14 de janeiro de 2004 19:16
To: sdl at libsdl.org
Subject: [SDL] SDL_DOUBLEBUF | SDL_HWSURFACE + Windowed mode

Hi,

Is it possible to set up SDL with double buffering and hardware surfaces
in windowed mode on Windows? Manipulating the surface and calling
SDL_Flip(…) results in flicker when in windowded mode, in fullscreen
mode it looks beautiful.

Thanks,

-Tim


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Tim M. wrote:

Hi,

Is it possible to set up SDL with double buffering and hardware
surfaces in windowed mode on Windows? Manipulating the surface and
calling SDL_Flip(…) results in flicker when in windowded mode, in
fullscreen mode it looks beautiful.

Thanks,

-Tim


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hardware surfaces are not available in windowed mode (except on Amiga
IIRC). OTOH, they are available in fullscreen mode on Windows (via directx).

For the flicker problem, are you seeing “white flashes” on the screen ?
Maybe you just loose frames in windowed mode, which is not surprising
if you redraw the whole screen.

Julien

Hi Julian,

Thank you for your answer.

This is the rendering code:

void clear_surface(SDL_Surface* surface, Uint8 r, Uint8 g, Uint8 b)
{
Uint32 color = SDL_MapRGB(surface->format, r, g, b);
SDL_FillRect(surface, NULL, color);
}

void render()
{
clear_surface(backbuffer, 0, 0, (Uint8)(rand()%256));
SDL_BlitSurface(backbuffer, NULL, screen, NULL);

SDL_UpdateRect(screen, 0, 0, 0, 0);

}

I do not see white flashes, but approximately the first half of the window
(it is a SWSURFACE displayed in windowed mode) is filled with another
shade of blue than the other half.

Any suggestions?

Thanks,

TimOn Thu, 15 Jan 2004 09:44:45 +0100, Julien Pauty wrote:

Tim M. wrote:

Hi,

Is it possible to set up SDL with double buffering and hardware
surfaces in windowed mode on Windows? Manipulating the surface and
calling SDL_Flip(…) results in flicker when in windowded mode, in
fullscreen mode it looks beautiful.

Thanks,

-Tim


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hardware surfaces are not available in windowed mode (except on Amiga
IIRC). OTOH, they are available in fullscreen mode on Windows (via
directx).

For the flicker problem, are you seeing “white flashes” on the screen ?
Maybe you just loose frames in windowed mode, which is not surprising
if you redraw the whole screen.

Julien


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Tim M. wrote:

Hi Julian,

Thank you for your answer.

This is the rendering code:

void clear_surface(SDL_Surface* surface, Uint8 r, Uint8 g, Uint8 b)
{
Uint32 color = SDL_MapRGB(surface->format, r, g, b);
SDL_FillRect(surface, NULL, color);
}

void render()
{
clear_surface(backbuffer, 0, 0, (Uint8)(rand()%256));
SDL_BlitSurface(backbuffer, NULL, screen, NULL);

SDL_UpdateRect(screen, 0, 0, 0, 0);

}

I do not see white flashes, but approximately the first half of the
window (it is a SWSURFACE displayed in windowed mode) is filled with
another shade of blue than the other half.

Any suggestions?

Yes this is the normal behavior. In windowed mode you can’t do a flip
synch’ed with the monitor refresh, so when you update the framebuffer
in memory (SDL_UpdateRect) the video card may be drawing on the screen.
That’s why you see on the upper part your old blue and on the lower part
the new one.

I think, when you set the video mode in software mode, SDL returns you a
pointer to a secondary surface and not to the surface actually in the
video memory. In this way, just call your clear_surface on the "screen"
surface. This doesn’t alter the surface in video memory but your
secondary surface. The change are copied by SDL in video memory only
when you call SDL_UpdateRect. Thus, you only have 2 transferts in memory
and not 3. It will save some banwidth, improve your framerate and maybe
reduce your visual problem.

Julien

Hi Julien,

Sorry for misspelling your name.

I eliminated the backbuffer but the flicker is as frequent as before. I
have done some Win32 programming and by modifying a backbuffer and
blitting it to the primary surface, I had successfully eliminated any
flicker. I did not make any use of DirectX/OpenGL, just the GDI.

There are lot of applications, notably video players, which display
animation without any flicker.

Is there no way to display animation in SDL in a window without any
flicker?

Thanks,

TimOn Thu, 15 Jan 2004 16:09:27 +0100, Julien Pauty wrote:

Tim M. wrote:

Hi Julian,

Thank you for your answer.

This is the rendering code:

void clear_surface(SDL_Surface* surface, Uint8 r, Uint8 g, Uint8 b)
{
Uint32 color = SDL_MapRGB(surface->format, r, g, b);
SDL_FillRect(surface, NULL, color);
}

void render()
{
clear_surface(backbuffer, 0, 0, (Uint8)(rand()%256));
SDL_BlitSurface(backbuffer, NULL, screen, NULL);

SDL_UpdateRect(screen, 0, 0, 0, 0);

}

I do not see white flashes, but approximately the first half of the
window (it is a SWSURFACE displayed in windowed mode) is filled with
another shade of blue than the other half.

Any suggestions?

Yes this is the normal behavior. In windowed mode you can’t do a flip
synch’ed with the monitor refresh, so when you update the framebuffer
in memory (SDL_UpdateRect) the video card may be drawing on the screen.
That’s why you see on the upper part your old blue and on the lower part
the new one.

I think, when you set the video mode in software mode, SDL returns you a
pointer to a secondary surface and not to the surface actually in the
video memory. In this way, just call your clear_surface on the "screen"
surface. This doesn’t alter the surface in video memory but your
secondary surface. The change are copied by SDL in video memory only
when you call SDL_UpdateRect. Thus, you only have 2 transferts in memory
and not 3. It will save some banwidth, improve your framerate and maybe
reduce your visual problem.

Julien


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl