List of usage examples for org.lwjgl.opengl GL getFunctionProvider
@Nullable public static FunctionProvider getFunctionProvider()
From source file:org.lwjgl.system.jglfw.PlatformLinux.java
License:Open Source License
private static boolean initContextAPI() { GL.getFunctionProvider(); // touch to load libGL // Check if GLX is supported on this display if (glXQueryExtension(x11.display, glx.errorBase, glx.eventBase) == 0) { inputError(GLFW_API_UNAVAILABLE, "GLX: GLX support not found"); return false; }// ww w. j a va2s . c om if (glXQueryVersion(x11.display, glx.versionMajor, glx.versionMinor) == 0) { inputError(GLFW_API_UNAVAILABLE, "GLX: Failed to query GLX version"); return false; } // LWJGL note: We need to call GLX functions before context creation. We retrieve the function pointers here and call the JNI methods manually. // (GLX function pointers do not change across contexts, that's why we can do this). FunctionProvider functionProvider = GL.getFunctionProvider(); // LWJGL TODO: We basically require GLX 1.3 with these. Relax? glx.QueryExtensionsString = functionProvider.getFunctionAddress("glXQueryExtensionsString"); glx.ChooseFBConfig = functionProvider.getFunctionAddress("glXChooseFBConfig"); glx.GetVisualFromFBConfig = functionProvider.getFunctionAddress("glXGetVisualFromFBConfig"); glx.CreateNewContext = functionProvider.getFunctionAddress("glXCreateNewContext"); String extensionsString = memDecodeASCII( memByteBufferNT1(nglXQueryExtensionsString(x11.display, x11.screen, glx.QueryExtensionsString))); Set<String> extensions = new HashSet<String>(32); StringTokenizer tokenizer = new StringTokenizer(extensionsString); while (tokenizer.hasMoreTokens()) extensions.add(tokenizer.nextToken()); if (extensions.contains("GLX_EXT_swap_control")) { glx.SwapIntervalEXT = functionProvider.getFunctionAddress("glXSwapIntervalEXT"); if (glx.SwapIntervalEXT != NULL) glx.EXT_swap_control = true; } if (extensions.contains("GLX_SGI_swap_control")) { glx.SwapIntervalSGI = functionProvider.getFunctionAddress("glXSwapIntervalSGI"); if (glx.SwapIntervalSGI != NULL) glx.SGI_swap_control = true; } if (extensions.contains("GLX_MESA_swap_control")) { glx.SwapIntervalMESA = functionProvider.getFunctionAddress("glXSwapIntervalMESA"); if (glx.SwapIntervalMESA != NULL) glx.MESA_swap_control = true; } if (extensions.contains("GLX_SGIX_fbconfig")) { glx.GetFBConfigAttribSGIX = functionProvider.getFunctionAddress("glXGetFBConfigAttribSGIX"); glx.ChooseFBConfigSGIX = functionProvider.getFunctionAddress("glXChooseFBConfigSGIX"); glx.CreateContextWithConfigSGIX = functionProvider.getFunctionAddress("glXCreateContextWithConfigSGIX"); glx.GetVisualFromFBConfigSGIX = functionProvider.getFunctionAddress("glXGetVisualFromFBConfigSGIX"); if (glx.GetFBConfigAttribSGIX != NULL && glx.ChooseFBConfigSGIX != NULL && glx.CreateContextWithConfigSGIX != NULL && glx.GetVisualFromFBConfigSGIX != NULL) { glx.SGIX_fbconfig = true; } } if (extensions.contains("GLX_ARB_multisample")) glx.ARB_multisample = true; if (extensions.contains("GLX_ARB_framebuffer_sRGB")) glx.ARB_framebuffer_sRGB = true; if (extensions.contains("GLX_ARB_create_context")) { glx.CreateContextAttribsARB = functionProvider.getFunctionAddress("glXCreateContextAttribsARB"); if (glx.CreateContextAttribsARB != NULL) glx.ARB_create_context = true; } if (extensions.contains("GLX_ARB_create_context_robustness")) glx.ARB_create_context_robustness = true; if (extensions.contains("GLX_ARB_create_context_profile")) glx.ARB_create_context_profile = true; if (extensions.contains("GLX_EXT_create_context_es2_profile")) glx.EXT_create_context_es2_profile = true; return true; }