For now, always get a new OpenGL context in SetVideoMode. Reusing the same context doesn't seem to be working.
Call SetVideoMode when app is fullscreen and regains focus. Did our OGL renderer ever handle Alt+tabbing before this change?
This commit is contained in:
@@ -8,8 +8,24 @@
|
|||||||
|
|
||||||
LowLevelWindow_SDL::LowLevelWindow_SDL()
|
LowLevelWindow_SDL::LowLevelWindow_SDL()
|
||||||
{
|
{
|
||||||
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
Windowed = false;
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
}
|
||||||
|
|
||||||
|
LowLevelWindow_SDL::~LowLevelWindow_SDL()
|
||||||
|
{
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
|
||||||
|
SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *LowLevelWindow_SDL::GetProcAddress(CString s)
|
||||||
|
{
|
||||||
|
return SDL_GL_GetProcAddress(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
|
||||||
|
{
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
/* By default, ignore all SDL events. We'll enable them as we need them.
|
/* By default, ignore all SDL events. We'll enable them as we need them.
|
||||||
* We must not enable any events we don't actually want, since we won't
|
* We must not enable any events we don't actually want, since we won't
|
||||||
@@ -20,24 +36,13 @@ LowLevelWindow_SDL::LowLevelWindow_SDL()
|
|||||||
SDL_EventState(0xFF /*SDL_ALLEVENTS*/, SDL_IGNORE);
|
SDL_EventState(0xFF /*SDL_ALLEVENTS*/, SDL_IGNORE);
|
||||||
|
|
||||||
SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
|
SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
|
||||||
|
SDL_EventState(SDL_ACTIVEEVENT, SDL_ENABLE);
|
||||||
|
|
||||||
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
Windowed = false;
|
Windowed = false;
|
||||||
}
|
|
||||||
|
|
||||||
LowLevelWindow_SDL::~LowLevelWindow_SDL()
|
int flags = SDL_RESIZABLE | SDL_OPENGL; // | SDL_DOUBLEBUF; // no need for DirectDraw to be double-buffered
|
||||||
{
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *LowLevelWindow_SDL::GetProcAddress(CString s)
|
|
||||||
{
|
|
||||||
return SDL_GL_GetProcAddress(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
|
|
||||||
{
|
|
||||||
int flags = SDL_DOUBLEBUF | SDL_RESIZABLE | SDL_OPENGL;
|
|
||||||
if( !windowed )
|
if( !windowed )
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
|
|
||||||
@@ -69,30 +74,30 @@ bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
SDL_EventState(SDL_OPENGLRESET, SDL_ENABLE);
|
// SDL_EventState(SDL_OPENGLRESET, SDL_ENABLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_Surface *screen = SDL_SetVideoMode(width, height, bpp, flags);
|
SDL_Surface *screen = SDL_SetVideoMode(width, height, bpp, flags);
|
||||||
if(!screen)
|
if(!screen)
|
||||||
RageException::Throw("SDL_SetVideoMode failed: %s", SDL_GetError());
|
RageException::Throw("SDL_SetVideoMode failed: %s", SDL_GetError());
|
||||||
|
|
||||||
bool NewOpenGLContext = false;
|
bool NewOpenGLContext = true; // always a new context because we're resetting SDL_Video
|
||||||
|
|
||||||
/* XXX: This event only exists in the SDL tree, and is only needed in
|
/* XXX: This event only exists in the SDL tree, and is only needed in
|
||||||
* Windows. Eventually, it'll probably get upstreamed, and once it's
|
* Windows. Eventually, it'll probably get upstreamed, and once it's
|
||||||
* in the real branch we can remove this #if. */
|
* in the real branch we can remove this #if. */
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
SDL_Event e;
|
// SDL_Event e;
|
||||||
if(SDL_GetEvent(e, SDL_OPENGLRESETMASK))
|
// if(SDL_GetEvent(e, SDL_OPENGLRESETMASK))
|
||||||
{
|
// {
|
||||||
LOG->Trace("New OpenGL context");
|
// LOG->Trace("New OpenGL context");
|
||||||
|
// SDL_WM_SetCaption("StepMania", "StepMania");
|
||||||
|
// NewOpenGLContext = true;
|
||||||
|
// }
|
||||||
|
|
||||||
SDL_WM_SetCaption("StepMania", "StepMania");
|
SDL_WM_SetCaption("StepMania", "StepMania");
|
||||||
|
|
||||||
NewOpenGLContext = true;
|
// SDL_EventState(SDL_OPENGLRESET, SDL_IGNORE);
|
||||||
}
|
|
||||||
|
|
||||||
SDL_EventState(SDL_OPENGLRESET, SDL_IGNORE);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -125,7 +130,7 @@ void LowLevelWindow_SDL::SwapBuffers()
|
|||||||
void LowLevelWindow_SDL::Update(float fDeltaTime)
|
void LowLevelWindow_SDL::Update(float fDeltaTime)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_GetEvent(event, SDL_VIDEORESIZEMASK))
|
while(SDL_GetEvent(event, SDL_VIDEORESIZEMASK|SDL_ACTIVEEVENTMASK))
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
{
|
{
|
||||||
@@ -136,6 +141,20 @@ void LowLevelWindow_SDL::Update(float fDeltaTime)
|
|||||||
/* Let DISPLAY know that our resolution has changed. */
|
/* Let DISPLAY know that our resolution has changed. */
|
||||||
DISPLAY->ResolutionChanged();
|
DISPLAY->ResolutionChanged();
|
||||||
break;
|
break;
|
||||||
|
case SDL_ACTIVEEVENT:
|
||||||
|
if( event.active.gain && // app regaining focus
|
||||||
|
!DISPLAY->IsWindowed() ) // full screen
|
||||||
|
{
|
||||||
|
// need to reacquire an OGL context
|
||||||
|
DISPLAY->SetVideoMode(
|
||||||
|
DISPLAY->IsWindowed(),
|
||||||
|
DISPLAY->GetWidth(),
|
||||||
|
DISPLAY->GetHeight(),
|
||||||
|
DISPLAY->GetBPP(),
|
||||||
|
0,
|
||||||
|
0 );
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user