mirror of https://github.com/stella-emu/stella.git
Fixed rendering issues in OSX, by never destroying and re-creating the window.
This sometimes results in a window resize being visible, but better that than an outright crash. This issue has been reported to the SDL mailing list, so this fix may be backed out in the future. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2927 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
61972b350a
commit
2d32f3d39a
|
@ -69,6 +69,8 @@ FrameBufferSDL2::~FrameBufferSDL2()
|
||||||
}
|
}
|
||||||
if(myWindow)
|
if(myWindow)
|
||||||
{
|
{
|
||||||
|
SDL_SetWindowFullscreen(myWindow, 0); // on some systems, a crash occurs
|
||||||
|
// when destroying fullscreen window
|
||||||
SDL_DestroyWindow(myWindow);
|
SDL_DestroyWindow(myWindow);
|
||||||
myWindow = NULL;
|
myWindow = NULL;
|
||||||
}
|
}
|
||||||
|
@ -105,10 +107,24 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode,
|
||||||
// Always recreate renderer (some systems need this)
|
// Always recreate renderer (some systems need this)
|
||||||
if(myRenderer)
|
if(myRenderer)
|
||||||
{
|
{
|
||||||
|
// Always clear the (double-buffered) renderer surface
|
||||||
|
SDL_RenderClear(myRenderer);
|
||||||
|
SDL_RenderPresent(myRenderer);
|
||||||
|
SDL_RenderClear(myRenderer);
|
||||||
SDL_DestroyRenderer(myRenderer);
|
SDL_DestroyRenderer(myRenderer);
|
||||||
myRenderer = NULL;
|
myRenderer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uInt32 pos = myOSystem.settings().getBool("center")
|
||||||
|
? SDL_WINDOWPOS_CENTERED : SDL_WINDOWPOS_UNDEFINED;
|
||||||
|
uInt32 flags = mode.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0;
|
||||||
|
|
||||||
|
// OSX seems to have issues with destroying the window, and wants to keep
|
||||||
|
// the same handle
|
||||||
|
// Problem is, doing so on other platforms results in flickering when
|
||||||
|
// toggling fullscreen windowed mode
|
||||||
|
// So we have a special case for OSX
|
||||||
|
#ifndef BSPF_MAC_OSX
|
||||||
// Don't re-create the window if its size hasn't changed, as it's not
|
// Don't re-create the window if its size hasn't changed, as it's not
|
||||||
// necessary, and causes flashing in fullscreen mode
|
// necessary, and causes flashing in fullscreen mode
|
||||||
if(myWindow)
|
if(myWindow)
|
||||||
|
@ -126,13 +142,22 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode,
|
||||||
// Even though window size stayed the same, the title may have changed
|
// Even though window size stayed the same, the title may have changed
|
||||||
SDL_SetWindowTitle(myWindow, title.c_str());
|
SDL_SetWindowTitle(myWindow, title.c_str());
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// OSX wants to *never* re-create the window
|
||||||
|
// This sometimes results in the window being resized *after* it's displayed,
|
||||||
|
// but at least the code works and doesn't crash
|
||||||
|
if(myWindow)
|
||||||
|
{
|
||||||
|
SDL_SetWindowFullscreen(myWindow, flags);
|
||||||
|
SDL_SetWindowSize(myWindow, mode.screen.w, mode.screen.h);
|
||||||
|
SDL_SetWindowPosition(myWindow, pos, pos);
|
||||||
|
SDL_SetWindowTitle(myWindow, title.c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int pos = myOSystem.settings().getBool("center")
|
myWindow = SDL_CreateWindow(title.c_str(), pos, pos,
|
||||||
? SDL_WINDOWPOS_CENTERED : SDL_WINDOWPOS_UNDEFINED;
|
mode.screen.w, mode.screen.h, flags);
|
||||||
myWindow = SDL_CreateWindow(title.c_str(),
|
|
||||||
pos, pos, mode.screen.w, mode.screen.h,
|
|
||||||
mode.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
|
||||||
if(myWindow == NULL)
|
if(myWindow == NULL)
|
||||||
{
|
{
|
||||||
string msg = "ERROR: Unable to open SDL window: " + string(SDL_GetError());
|
string msg = "ERROR: Unable to open SDL window: " + string(SDL_GetError());
|
||||||
|
@ -241,5 +266,5 @@ void FrameBufferSDL2::readPixels(const GUI::Rect& rect,
|
||||||
r.x = rect.x(); r.y = rect.y();
|
r.x = rect.x(); r.y = rect.y();
|
||||||
r.w = rect.width(); r.h = rect.height();
|
r.w = rect.width(); r.h = rect.height();
|
||||||
|
|
||||||
SDL_RenderReadPixels(myRenderer, &r, SDL_PIXELFORMAT_ARGB8888, pixels, pitch);
|
SDL_RenderReadPixels(myRenderer, &r, 0, pixels, pitch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,6 +675,7 @@ void FrameBuffer::setFullscreen(bool enable)
|
||||||
myOSystem.settings().setValue("fullscreen", fullScreen());
|
myOSystem.settings().setValue("fullscreen", fullScreen());
|
||||||
resetSurfaces();
|
resetSurfaces();
|
||||||
setCursorState();
|
setCursorState();
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue