Skip to content

Commit 9f94d6b

Browse files
committed
OpenGLDevice: Fix incorrect SDL MakeCurrent()/DoneCurrent() usage
Too bad multiple windows on a single aren't supported properly. Should just rip this whole thing out.
1 parent 6a4ae21 commit 9f94d6b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/util/opengl_context_sdl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ OpenGLContext::SurfaceHandle OpenGLContextSDL::CreateSurface(WindowInfo& wi, Err
124124

125125
void OpenGLContextSDL::DestroySurface(SurfaceHandle handle)
126126
{
127-
// cleaned up on window destruction?
127+
// cleaned up on window destruction? but we still need to clear current
128+
SDL_Window* const window = static_cast<SDL_Window*>(handle);
129+
if (m_current_window == window)
130+
DoneCurrent();
128131
}
129132

130133
void OpenGLContextSDL::ResizeSurface(WindowInfo& wi, SurfaceHandle handle)
@@ -159,7 +162,7 @@ bool OpenGLContextSDL::MakeCurrent(SurfaceHandle surface, Error* error /* = null
159162
if (m_current_window == window)
160163
return true;
161164

162-
if (SDL_GL_MakeCurrent(window, m_context) != 0)
165+
if (!SDL_GL_MakeCurrent(window, m_context))
163166
{
164167
ERROR_LOG("SDL_GL_MakeCurrent() failed: {}", SDL_GetError());
165168
return false;
@@ -171,7 +174,7 @@ bool OpenGLContextSDL::MakeCurrent(SurfaceHandle surface, Error* error /* = null
171174

172175
bool OpenGLContextSDL::DoneCurrent()
173176
{
174-
if (SDL_GL_MakeCurrent(nullptr, nullptr) != 0)
177+
if (!SDL_GL_MakeCurrent(nullptr, nullptr))
175178
return false;
176179

177180
m_current_window = nullptr;

0 commit comments

Comments
 (0)