[SDL] OpenGL fullscreen

Blake Senftner bsenftner at earthlink.net
Fri Jul 19 13:49:00 PDT 2002

----- Original Message ----- 
From: "Maciej Babinski" <maciej at imsa.edu>
Sent: Friday, July 19, 2002 1:12 PM

> Hello, I'm working on an OpenGL SDL application that will eventually
> work in both fullscreen and windowed mode. I can currently set the
> GL attributes, and initialize a fullscreen or windowed surface,
> but OpenGL rendering in fullscreen mode takes a _lot_ longer than
> in a window, and makes animating even small models look very jerky.
> I'm setting a 32bit video mode, with 8 bits for red, green, blue,
> and alpha each, a 32bit depth buffer, and doublebuffering. 
> This is my call to SetVideoMode:
> screen = SDL_SetVideoMode(800, 600, 32,
> the acquired depth is always 32, and the flags on the surface get
> Any help would be appreciated.
> Maciej Babinski
> maciej at imsa.edu


I used the following logic to set up my OpenGL SDL application that runs both full screen and windowed. This is cut from a routine that gets parameters 'width', 'height' and 'fullscreenflag'.

  // set the flag that gets passed to SDL requesting 
  // how we want things configured:
  if (fullscreenflag) 
    flags |= SDL_FULLSCREEN;

    // if we're doing full screen, ignore the passed in 
    // width & height values and set to the screen dimensions:
    width  = gApp->GetCurrentFullScrnXRes();
    height = gApp->GetCurrentFullScrnYRes();
    gApp->SetCurrentWindowedXRes( width  );
    gApp->SetCurrentWindowedYRes( height );

  // passing "bits" as zero requests the same bit depth as the desktop
  // (I've previously checked to be sure it's at least 32.)
  // This is where the OpenGL Context is created:
  if (SDL_SetVideoMode( width, height, 0, flags) == NULL) 
    return FALSE;

Note that I use this logic at application startup before the above logic that calls SDL_SetVideoMode():

  // use this to give us the bits per pixel of the desktop:
  const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
  gFrameBufferBitsPerPixel = videoInfo->vfmt->BitsPerPixel;
  if (gFrameBufferBitsPerPixel < 32)
    fprintf( stderr, "must have at least a 32 bit desktop!\n" );
    return 1;

  // tell SDL the minimum size we want for these attributes:
  SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
  SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
  SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 );
  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

Using this logic, I get faster frame rates when full screen than when running windowed. I hope that helps. 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020719/46ebf26d/attachment-0008.htm>

More information about the SDL mailing list