sdl1.3 cocoawindow toggle to fullscreen OpenGL context loss

View: New views
3 Messages — Rating Filter:   Alert me  

sdl1.3 cocoawindow toggle to fullscreen OpenGL context loss

by vickylh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
I used it like this:

SDL_DestroyWindow;

SDL_CreateWindow;

SDL_GL_MakeCurrent;

It works well in Windows, but it can't work in mac os. As sdl 1.2, the opengl context lost and mouse event lost.
Could someone can fix it?

_______________________________________________
SDL mailing list
SDL@...
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: sdl1.3 cocoawindow toggle to fullscreen OpenGL context loss

by Sam Lantinga-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm surprised you're able to keep an OpenGL context across a
windowed/fullscreen switch without having to reload your textures and
so forth.  In general it's my understanding that you can't.

On Thu, Oct 22, 2009 at 8:58 PM, vickylh <perivickylh@...> wrote:

> I used it like this:
>
> SDL_DestroyWindow;
>
> SDL_CreateWindow;
>
> SDL_GL_MakeCurrent;
>
> It works well in Windows, but it can't work in mac os. As sdl 1.2, the
> opengl context lost and mouse event lost.
> Could someone can fix it?
> _______________________________________________
> SDL mailing list
> SDL@...
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>



--
        -Sam Lantinga, Founder and President, Galaxy Gameworks LLC
_______________________________________________
SDL mailing list
SDL@...
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: sdl1.3 cocoawindow toggle to fullscreen OpenGL context loss

by vickylh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Thank you for your reply!
Yes, i do it in Windows.But it can't work in SnowLeopard.
If you will,i can send the Exe to you.
Follow is my code:
void _InitSystem()
{
if ( SDL_WasInit(SDL_INIT_EVERYTHING) != 0 ) {
fprintf( stderr, "SDL is already running.\n" );
return ;

}

if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
/* Failed, exit. */
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
return ;

}
/* Information about the current video settings. */
const SDL_VideoInfo* info = NULL;


/* Select first display */
int status=SDL_SelectVideoDisplay(0);
if (status<0)
{
fprintf(stderr, "Can't attach to first display: %s\n", SDL_GetError());
exit(-1);
}

if (m_eDisplayMode & MODE_ARGB )
{
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_ALPHA_SIZE, 8 );
}
if (m_eDisplayMode & MODE_DOUBLE_BUFFER )
{
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
}
if (m_eDisplayMode & MODE_SINGLE_BUFFER )
{
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 0 );
}
if (m_eDisplayMode & MODE_DEPTH_BUFFER )
{
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
glEnable(GL_DEPTH_TEST);
}

SDL_DisplayMode fullscreen_mode;
fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
fullscreen_mode.w = m_nScreenWidth;
fullscreen_mode.h = m_nScreenHeight;

if (SDL_SetFullscreenDisplayMode(&fullscreen_mode) < 0)
{
fprintf(stderr, "Can't switch to fullscreen display mode: %s\n",
SDL_GetError());
return ;
}

_CreateWindow();

m_Context = SDL_GL_CreateContext(m_nWindowID);
if (m_Context == NULL)
{
fprintf(stderr, "Can't create OpenGL context: %s\n", SDL_GetError());
}
/*
Something about Opengl......
*/
}
void _CreateWindow()
{
int flags = 0;

flags = SDL_WINDOW_OPENGL;
flags |= SDL_WINDOW_SHOWN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS |SDL_WINDOW_RESIZABLE;


if (m_bNoFrame)
{
flags |= SDL_WINDOW_BORDERLESS;
}
if (m_bResizable)
{
flags |= SDL_WINDOW_RESIZABLE;
}
if (!m_bWindow)
{
flags |= SDL_WINDOW_FULLSCREEN;
}
m_nWindowID = SDL_CreateWindow(m_szWinTitle, m_nWindowPositionX,
m_nWindowPositionY, m_nScreenWidth, m_nScreenHeight, flags);
}
When i switch from window to fullscreen,i use it like this:
SDL_DestroyWindow(m_nWindowID);

_CreateWindow();

SDL_GL_MakeCurrent(m_nWindowID, m_Context);

SDL_SetWindowPosition(m_nWindowID, m_nWindowPositionX, m_nWindowPositionY);
You can try it in Windows,and the sdl version is 1.3

_______________________________________________
SDL mailing list
SDL@...
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org