// Initialize WGL // int _glfwInitContextAPI(void) { if (!_glfwCreateContextTLS()) return GLFW_FALSE; _glfw.wgl.instance = LoadLibraryA("opengl32.dll"); if (!_glfw.wgl.instance) { _glfwInputError(GLFW_PLATFORM_ERROR, "WGL: Failed to load opengl32.dll"); return GLFW_FALSE; } _glfw.wgl.CreateContext = (WGLCREATECONTEXT_T) GetProcAddress(_glfw.wgl.instance, "wglCreateContext"); _glfw.wgl.DeleteContext = (WGLDELETECONTEXT_T) GetProcAddress(_glfw.wgl.instance, "wglDeleteContext"); _glfw.wgl.GetProcAddress = (WGLGETPROCADDRESS_T) GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress"); _glfw.wgl.MakeCurrent = (WGLMAKECURRENT_T) GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent"); _glfw.wgl.ShareLists = (WGLSHARELISTS_T) GetProcAddress(_glfw.wgl.instance, "wglShareLists"); return GLFW_TRUE; }
// Initialize WGL // int _glfwInitContextAPI(void) { if (!_glfwCreateContextTLS()) return GL_FALSE; _glfw.wgl.opengl32.instance = LoadLibraryW(L"opengl32.dll"); if (!_glfw.wgl.opengl32.instance) { _glfwInputError(GLFW_PLATFORM_ERROR, "WGL: Failed to load opengl32.dll"); return GL_FALSE; } return GL_TRUE; }
// Initialize GLX // int _glfwInitContextAPI(void) { #if defined(__CYGWIN__) const char* soname = "libGL-1.so"; #else const char* soname = "libGL.so.1"; #endif if (!_glfwCreateContextTLS()) return GL_FALSE; _glfw.glx.handle = dlopen(soname, RTLD_LAZY | RTLD_GLOBAL); if (!_glfw.glx.handle) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: %s", dlerror()); return GL_FALSE; } _glfw.glx.GetFBConfigs = dlsym(_glfw.glx.handle, "glXGetFBConfigs"); _glfw.glx.GetFBConfigAttrib = dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib"); _glfw.glx.GetClientString = dlsym(_glfw.glx.handle, "glXGetClientString"); _glfw.glx.QueryExtension = dlsym(_glfw.glx.handle, "glXQueryExtension"); _glfw.glx.QueryVersion = dlsym(_glfw.glx.handle, "glXQueryVersion"); _glfw.glx.DestroyContext = dlsym(_glfw.glx.handle, "glXDestroyContext"); _glfw.glx.MakeCurrent = dlsym(_glfw.glx.handle, "glXMakeCurrent"); _glfw.glx.SwapBuffers = dlsym(_glfw.glx.handle, "glXSwapBuffers"); _glfw.glx.QueryExtensionsString = dlsym(_glfw.glx.handle, "glXQueryExtensionsString"); _glfw.glx.CreateNewContext = dlsym(_glfw.glx.handle, "glXCreateNewContext"); _glfw.glx.GetVisualFromFBConfig = dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig"); _glfw.glx.GetProcAddress = dlsym(_glfw.glx.handle, "glXGetProcAddress"); _glfw.glx.GetProcAddressARB = dlsym(_glfw.glx.handle, "glXGetProcAddressARB"); if (!_glfw_glXQueryExtension(_glfw.x11.display, &_glfw.glx.errorBase, &_glfw.glx.eventBase)) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found"); return GL_FALSE; } if (!_glfw_glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor)) { _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to query GLX version"); return GL_FALSE; } if (_glfw.glx.major == 1 && _glfw.glx.minor < 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_EXT_framebuffer_sRGB")) _glfw.glx.EXT_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; }