Skip to content

Commit b5c909c

Browse files
committed
fix(GLFW): Actually change window attribute
1 parent aecd6dc commit b5c909c

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

  • jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw

jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -895,26 +895,31 @@ public static void glfwSetWindowMonitor(@NativeType("GLFWwindow *") long window,
895895
}
896896

897897
public static int glfwGetWindowAttrib(@NativeType("GLFWwindow *") long window, int attrib) {
898+
System.out.println("GLFW: Default window GL context is 3.3");
898899
// Turnip + Zink is the only way to get compliant GL 4.6
899900
boolean hasTurnipZink = java.util.Objects.requireNonNull(glGetString(GL_RENDERER)).contains("zink") &&
900901
java.util.Objects.requireNonNull(glGetString(GL_RENDERER)).contains("Turnip");
901902
if (hasTurnipZink) {
902-
if (attrib == GLFW_CONTEXT_VERSION_MAJOR) return 4;
903-
if (attrib == GLFW_CONTEXT_VERSION_MINOR) return 6;
903+
System.out.println("GLFW: Turnip+Zink detected, setting window GL context to 4.6");
904+
internalGetWindow(window).windowAttribs.put(GLFW_CONTEXT_VERSION_MAJOR, 4);
905+
internalGetWindow(window).windowAttribs.put(GLFW_CONTEXT_VERSION_MINOR, 6);
904906
}
905907
// It's been common consensus that virgl exports GL 4.3 on ES 3.2
906908
// I can't find any sources on this though...well besides the implied claim here
907909
// https://github.com/PojavLauncherTeam/PojavLauncher/issues/2697#issuecomment-1030837683
908910
boolean isVirgl = java.util.Objects.requireNonNull(glGetString(GL_RENDERER)).contains("virgl");
909911
if (isVirgl) {
910-
if (attrib == GLFW_CONTEXT_VERSION_MAJOR) return 4;
911-
if (attrib == GLFW_CONTEXT_VERSION_MINOR) return 3;
912+
System.out.println("GLFW: virglrenderer detected, setting window GL context to 4.3");
913+
internalGetWindow(window).windowAttribs.put(GLFW_CONTEXT_VERSION_MAJOR, 4);
914+
internalGetWindow(window).windowAttribs.put(GLFW_CONTEXT_VERSION_MINOR, 6);
912915
}
913-
// MobileGlues returns 4.0.0 as well as has compute shaders (from GL 4.0)
914-
boolean isMobileGlues = java.util.Objects.requireNonNull(glGetString(GL_VERSION)).contains("MobileGlues");
915-
if (isMobileGlues) { // In MobileGlues, GL_RENDERER returns GPU,( ANGLE, Vulkan,) ES while GL_VERSION returns
916-
if (attrib == GLFW_CONTEXT_VERSION_MAJOR) return 4; // 4.0.0 MobileGlues <MobileGlues Release Version>
917-
if (attrib == GLFW_CONTEXT_VERSION_MINOR) return 0;
916+
// MobileGlues returns 4.0.0 as well as has compute shaders (from GL 4.0)
917+
boolean isMobileGlues = java.util.Objects.requireNonNull(glGetString(GL_VERSION)).contains("MobileGlues");
918+
if (isMobileGlues) { // In MobileGlues, GL_RENDERER returns GPU,( ANGLE, Vulkan,) ES
919+
// while GL_VERSION returns 4.0.0 MobileGlues <MobileGlues Release Version>
920+
System.out.println("GLFW: MobileGlues detected, setting window GL context to 4.0");
921+
internalGetWindow(window).windowAttribs.put(GLFW_CONTEXT_VERSION_MAJOR, 4);
922+
internalGetWindow(window).windowAttribs.put(GLFW_CONTEXT_VERSION_MINOR, 6);
918923
}
919924
// We can assume GL 3.3 for everything else just to be safe stuff
920925
// doesn't ask for tesselation when we probably don't have any :(

0 commit comments

Comments
 (0)