SDL_Flip function

SDL_Flip -- swaps screen buffers

Synopsis

int SDL_Flip(SDL_Surface* screen);

Description

On hardware that supports double-buffering, this function sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. On hardware that doesn't support double-buffering or if SDL_SWSURFACE was set, this is equivalent to calling SDL_UpdateRect(screen, 0, 0, 0, 0)

A software screen surface is also updated automatically when parts of a SDL window are redrawn, caused by overlapping windows or by restoring from an iconified state. As a result there is no proper double buffer behavior in windowed mode for a software screen, in contrast to a full screen software mode.

The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode, when setting the video mode for this function to perform hardware flipping.

Note : If you want to swap the buffers of an initialized OpenGL context, use the function SDL_GL_SwapBuffers instead.

Parameter

screen [in]

Return value

-1

0

See Also

SDL_SetVideoMode, SDL_UpdateRect, SDL_GetVideoSurface, SDL_Surface, SDL_GL_SwapBuffers

Example

   1 #include <iostream>
   2 
   3 SDL_Surface* myVideoSurface = NULL;
   4 
   5 // Initialize SDL and the video subsystem
   6 SDL_Init(SDL_INIT_VIDEO);
   7 
   8 // Set the video mode
   9 SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN);
  10 
  11 // Retrieve the current video surface
  12 myVideoSurface = SDL_GetVideoSurface();
  13 
  14 // Do some video operations
  15 // myVideoRoutine1();
  16 // myVideoRoutine2();
  17 
  18 // Update the screen
  19 // WARNING: myVideoSurface is not NULL here
  20 if (SDL_Flip(myVideoSurface) != 0) {
  21     std::cerr << "Failed to swap the buffers: " << SDL_GetError() << std::endl;
  22 }
  23 else {
  24     // Everything is fine
  25 }
  26 
  27 // Do some other video operations
  28 // myVideoRoutine3();
  29 // myVideoRoutine4();
  30 
  31 // Shut down the SDL and all its subsystems
  32 SDL_Quit();

Requirements

Header

SDL.h

Version

1.2.13

Shared object

libSDL.so

DLL

SDL.dll


CategorySDLVideo

SDL_Flip (last edited 2008-08-26 11:44:26 by NeoNeurone)