Skip to content

Commit 02eb5a5

Browse files
committed
FIX: gl context restore before frame draw
We need to make sure the window / gl context are current because some modules (ie osgEarth) tinker with the context during initialization and lave it in an inconsistent state.
1 parent b4729f2 commit 02eb5a5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/displaySystems/GLFW/displaySystem_GLFW.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,17 @@ void GLFWDisplaySystem::run()
228228
im->unlockEvents();
229229
}
230230

231+
// NULL here is needed so glfwMakeContextCurrent after update actually
232+
// resets the context instead of just being a NOP.
233+
// Note that we need to make sure the window / gl context are current
234+
// because some modules (ie osgEarth) tinker with the context during
235+
// initialization and lave it in an inconsistent state.
236+
glfwMakeContextCurrent(NULL);
237+
231238
myEngine->update(uc);
232239

240+
glfwMakeContextCurrent(window);
241+
233242
// Handle window resize
234243
int width, height;
235244
glfwGetFramebufferSize(window, &width, &height);
@@ -250,7 +259,7 @@ void GLFWDisplaySystem::run()
250259
// causes problems with other code.
251260
glEnable(GL_LIGHTING);
252261

253-
dc.drawFrame(frame++);
262+
dc.drawFrame(frame++);
254263
glfwSwapBuffers(window);
255264

256265
// Poll the service manager for new events.

0 commit comments

Comments
 (0)