// Initialize EGL // int _glfwInitContextAPI(void) { if (!_glfwInitTLS()) return GL_FALSE; _glfw.egl.display = eglGetDisplay((EGLNativeDisplayType)_GLFW_EGL_NATIVE_DISPLAY); if (_glfw.egl.display == EGL_NO_DISPLAY) { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to get EGL display: %s", getErrorString(eglGetError())); return GL_FALSE; } if (!eglInitialize(_glfw.egl.display, &_glfw.egl.versionMajor, &_glfw.egl.versionMinor)) { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to initialize EGL: %s", getErrorString(eglGetError())); return GL_FALSE; } if (_glfwPlatformExtensionSupported("EGL_KHR_create_context")) _glfw.egl.KHR_create_context = GL_TRUE; return GL_TRUE; }
// Initialize WGL // int _glfwInitContextAPI(void) { if (!_glfwInitTLS()) return GL_FALSE; _glfw.wgl.opengl32.instance = LoadLibraryW(L"opengl32.dll"); if (!_glfw.wgl.opengl32.instance) { _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to load opengl32.dll"); return GL_FALSE; } return GL_TRUE; }
// Initialize GLX // int _glfwInitContextAPI(void) { if (!_glfwInitTLS()) return GL_FALSE; #ifdef _GLFW_DLOPEN_LIBGL _glfw.glx.libGL = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); if (!_glfw.glx.libGL) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to find libGL"); return GL_FALSE; } #endif if (!glXQueryExtension(_glfw.x11.display, &_glfw.glx.errorBase, &_glfw.glx.eventBase)) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found"); return GL_FALSE; } if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.versionMajor, &_glfw.glx.versionMinor)) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to query GLX version"); return GL_FALSE; } if (_glfw.glx.versionMajor == 1 && _glfw.glx.versionMinor < 3) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX version 1.3 is required"); return GL_FALSE; } if (_glfwPlatformExtensionSupported("GLX_EXT_swap_control")) { _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) _glfwPlatformGetProcAddress("glXSwapIntervalEXT"); if (_glfw.glx.SwapIntervalEXT) _glfw.glx.EXT_swap_control = GL_TRUE; } if (_glfwPlatformExtensionSupported("GLX_SGI_swap_control")) { _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) _glfwPlatformGetProcAddress("glXSwapIntervalSGI"); if (_glfw.glx.SwapIntervalSGI) _glfw.glx.SGI_swap_control = GL_TRUE; } if (_glfwPlatformExtensionSupported("GLX_MESA_swap_control")) { _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC) _glfwPlatformGetProcAddress("glXSwapIntervalMESA"); if (_glfw.glx.SwapIntervalMESA) _glfw.glx.MESA_swap_control = GL_TRUE; } if (_glfwPlatformExtensionSupported("GLX_ARB_multisample")) _glfw.glx.ARB_multisample = GL_TRUE; if (_glfwPlatformExtensionSupported("GLX_ARB_framebuffer_sRGB")) _glfw.glx.ARB_framebuffer_sRGB = GL_TRUE; if (_glfwPlatformExtensionSupported("GLX_ARB_create_context")) { _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) _glfwPlatformGetProcAddress("glXCreateContextAttribsARB"); if (_glfw.glx.CreateContextAttribsARB) _glfw.glx.ARB_create_context = GL_TRUE; } if (_glfwPlatformExtensionSupported("GLX_ARB_create_context_robustness")) _glfw.glx.ARB_create_context_robustness = GL_TRUE; if (_glfwPlatformExtensionSupported("GLX_ARB_create_context_profile")) _glfw.glx.ARB_create_context_profile = GL_TRUE; if (_glfwPlatformExtensionSupported("GLX_EXT_create_context_es2_profile")) _glfw.glx.EXT_create_context_es2_profile = GL_TRUE; if (_glfwPlatformExtensionSupported("GLX_ARB_context_flush_control")) _glfw.glx.ARB_context_flush_control = GL_TRUE; return GL_TRUE; }