Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid unnecessary window.makeCurrent() calls #7362

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ protected void loop () {
closedWindows.clear();
int targetFramerate = -2;
for (Lwjgl3Window window : windows) {
window.makeCurrent();
currentWindow = window;
if (currentWindow != window) {
window.makeCurrent();
currentWindow = window;
}
if (targetFramerate == -2) targetFramerate = window.getConfig().foregroundFPS;
synchronized (lifecycleListeners) {
haveWindowsRendered |= window.update();
Expand Down Expand Up @@ -470,6 +472,12 @@ void createWindow (Lwjgl3Window window, Lwjgl3ApplicationConfiguration config, l
window.getGraphics().gl20.glClear(GL11.GL_COLOR_BUFFER_BIT);
GLFW.glfwSwapBuffers(windowHandle);
}

if (currentWindow != null) {
// the call above to createGlfwWindow switches the OpenGL context to the newly created window,
// ensure that the invariant "currentWindow is the window with the current active OpenGL context" holds
currentWindow.makeCurrent();
}
}

static long createGlfwWindow (Lwjgl3ApplicationConfiguration config, long sharedContextWindow) {
Expand Down