[SDL] Beginner question: can't enter to fullscreen mode

Petri Latvala petri.latvala at realityescape.net
Sun Jun 26 16:15:15 PDT 2005

On Sun, Jun 26, 2005 at 11:50:13PM +0200, Ferran Ferri  wrote:
> ===================================================================
> the procedure to enter to the full screen mode is:
> void CGameEngine::toggleToFullScreenMode()
> {
> 		if (SDL_WM_ToggleFullScreen(m_mainScreen) == 0){
> 			printf("Unable to go to full sreen: %s
> \n",SDL_GetError());
> 		}
> }
> And the project is a console project. Some ideas? 

SDL_WM_ToggleFullscreen is a glorious example of a misdesign. It
cannot be implemented anywhere except on X11. And I hear BeOS might
have it too. In any case, Win32 doesn't have it, it does nothing

The correct and always working way to switch to fullscreen is to call
SDL_SetVideoMode again with SDL_FULLSCREEN in the flags. It will
destroy the OpenGL context, though, so you have to reload textures and
display lists.

And then an unrelated issue:

> Hi all, I'm programming with MSVC++ 7.1 (a.k.a VC++.NET). I created a
> SDL project with and I can't enter in full screen mode. When I configure
> the video mode I give the following flags to the SDL:
> /* the flags to pass to SDL_SetVideoMode */
>     m_nVideoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
>     m_nVideoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
>     m_nVideoFlags |= SDL_HWPALETTE;       /* Store the palette in
> hardware */
>     m_nVideoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
>     /* This checks to see if surfaces can be stored in memory */
>     if ( info->hw_available )
> 	m_nVideoFlags |= SDL_HWSURFACE;
>     else
> 	m_nVideoFlags |= SDL_SWSURFACE;
>     /* This checks if hardware blits can be done */
>     if ( info->blit_hw )
> 	m_nVideoFlags |= SDL_HWACCEL;

This is a common error and I've been hunting down the source for
this. In short: THE FLAGS ARE WRONG! Where did you get this code?


Double buffering for OpenGL is set up with the call to


before calling SDL_SetVideoMode. SDL_GL_DOUBLEBUFFER as a flag to
SDL_SetVideoMode is wrong. And it does "bad things" too: The value of
SDL_GL_DOUBLEBUFFER is 5, that is, 0x05 = 0x01 + 0x04 = SDL_HWSURFACE

2) SDL_OPENGL is special

A surface can in effect be one of three modes: SDL_SWSURFACE,
SDL_HWSURFACE or SDL_OPENGL. When using OpenGL, a lot of SDL
functionality for graphics make no sense. This means SDL_HWSURFACE and
SDL_SWSURFACE are meaningless, and so is SDL_HWPALETTE.

3) SDL_HWACCEL is plain wrong

This isn't a flag you can give to SDL_SetVideoMode: See
SDL_SetVideoMode docs at

SDL_HWACCEL does _not_ mean hardware-accelerated OpenGL, which is a
common interpretation. From your comments in the code I see you don't
think that, but they hint at another possible error. Blits? You can't
blit (SDL_BlitSurface) when using OpenGL.

SDL_HWACCEL is a read-only _internal_ flag on created surfaces that
SDL uses itself to determine whether blits are hardware accelerated.

"Fortunately" this flag should do nothing when given to
SDL_SetVideoMode, as it doesn't overlap with any values.

Petri Latvala
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050627/072a216f/attachment-0008.pgp>

More information about the SDL mailing list