@@ -895,6 +895,31 @@ public static void glfwSetWindowMonitor(@NativeType("GLFWwindow *") long window,
895895 }
896896
897897 public static int glfwGetWindowAttrib (@ NativeType ("GLFWwindow *" ) long window , int attrib ) {
898+ // Turnip + Zink is the only way to get compliant GL 4.6
899+ boolean hasTurnipZink = Objects .requireNonNull (glGetString (GL_RENDERER )).contains ("zink" ) &&
900+ Objects .requireNonNull (glGetString (GL_RENDERER )).contains ("Turnip" );
901+ if (hasTurnipZink ) {
902+ if (attrib == GLFW_CONTEXT_VERSION_MAJOR ) return 4 ;
903+ if (attrib == GLFW_CONTEXT_VERSION_MINOR ) return 6 ;
904+ }
905+ // It's been common consensus that virgl exports GL 4.3 on ES 3.2
906+ // I can't find any sources on this though...well besides the implied claim here
907+ // https://github.com/PojavLauncherTeam/PojavLauncher/issues/2697#issuecomment-1030837683
908+ boolean isVirgl = Objects .requireNonNull (glGetString (GL_RENDERER )).contains ("virgl" );
909+ if (isVirgl ) {
910+ if (attrib == GLFW_CONTEXT_VERSION_MAJOR ) return 4 ;
911+ if (attrib == GLFW_CONTEXT_VERSION_MINOR ) return 3 ;
912+ }
913+ // MobileGlues returns 4.0.0 as well as has compute shaders (from GL 4.0)
914+ boolean isMobileGlues = 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 ;
918+ }
919+ // We can assume GL 3.3 for everything else just to be safe stuff
920+ // doesn't ask for tesselation when we probably don't have any :(
921+ if (attrib == GLFW_CONTEXT_VERSION_MAJOR ) return 3 ;
922+ if (attrib == GLFW_CONTEXT_VERSION_MINOR ) return 3 ;
898923 return internalGetWindow (window ).windowAttribs .getOrDefault (attrib , 0 );
899924 }
900925
0 commit comments