Simplified WGL extension logic.

Not applying this to GLX or EGL yet because Mesa.
This commit is contained in:
Camilla Berglund 2015-05-04 19:26:01 +02:00
parent 656666e722
commit 905073a506

View File

@ -36,89 +36,45 @@
// //
static void initWGLExtensions(_GLFWwindow* window) static void initWGLExtensions(_GLFWwindow* window)
{ {
// This needs to include every function pointer loaded below // Functions for WGL_EXT_extension_string
window->wgl.SwapIntervalEXT = NULL; // NOTE: These are needed by _glfwPlatformExtensionSupported
window->wgl.GetPixelFormatAttribivARB = NULL;
window->wgl.GetExtensionsStringARB = NULL;
window->wgl.GetExtensionsStringEXT = NULL;
window->wgl.CreateContextAttribsARB = NULL;
// This needs to include every extension used below except for
// WGL_ARB_extensions_string and WGL_EXT_extensions_string
window->wgl.ARB_multisample = GL_FALSE;
window->wgl.ARB_framebuffer_sRGB = GL_FALSE;
window->wgl.ARB_create_context = GL_FALSE;
window->wgl.ARB_create_context_profile = GL_FALSE;
window->wgl.EXT_create_context_es2_profile = GL_FALSE;
window->wgl.ARB_create_context_robustness = GL_FALSE;
window->wgl.EXT_swap_control = GL_FALSE;
window->wgl.ARB_pixel_format = GL_FALSE;
window->wgl.ARB_context_flush_control = GL_FALSE;
window->wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) window->wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
wglGetProcAddress("wglGetExtensionsStringEXT"); wglGetProcAddress("wglGetExtensionsStringEXT");
if (!window->wgl.GetExtensionsStringEXT)
{
window->wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) window->wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
wglGetProcAddress("wglGetExtensionsStringARB"); wglGetProcAddress("wglGetExtensionsStringARB");
if (!window->wgl.GetExtensionsStringARB)
return;
}
if (_glfwPlatformExtensionSupported("WGL_ARB_multisample")) // Functions for WGL_ARB_create_context
window->wgl.ARB_multisample = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_ARB_framebuffer_sRGB"))
window->wgl.ARB_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context"))
{
window->wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) window->wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
wglGetProcAddress("wglCreateContextAttribsARB"); wglGetProcAddress("wglCreateContextAttribsARB");
if (window->wgl.CreateContextAttribsARB) // Functions for WGL_EXT_swap_control
window->wgl.ARB_create_context = GL_TRUE;
}
if (window->wgl.ARB_create_context)
{
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context_profile"))
window->wgl.ARB_create_context_profile = GL_TRUE;
}
if (window->wgl.ARB_create_context &&
window->wgl.ARB_create_context_profile)
{
if (_glfwPlatformExtensionSupported("WGL_EXT_create_context_es2_profile"))
window->wgl.EXT_create_context_es2_profile = GL_TRUE;
}
if (window->wgl.ARB_create_context)
{
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context_robustness"))
window->wgl.ARB_create_context_robustness = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("WGL_EXT_swap_control"))
{
window->wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) window->wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
wglGetProcAddress("wglSwapIntervalEXT"); wglGetProcAddress("wglSwapIntervalEXT");
if (window->wgl.SwapIntervalEXT) // Functions for WGL_ARB_pixel_format
window->wgl.EXT_swap_control = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("WGL_ARB_pixel_format"))
{
window->wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC) window->wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
wglGetProcAddress("wglGetPixelFormatAttribivARB"); wglGetProcAddress("wglGetPixelFormatAttribivARB");
if (window->wgl.GetPixelFormatAttribivARB) // This needs to include every extension used below except for
window->wgl.ARB_pixel_format = GL_TRUE; // WGL_ARB_extensions_string and WGL_EXT_extensions_string
} window->wgl.ARB_multisample =
_glfwPlatformExtensionSupported("WGL_ARB_multisample");
if (_glfwPlatformExtensionSupported("WGL_ARB_context_flush_control")) window->wgl.ARB_framebuffer_sRGB =
window->wgl.ARB_context_flush_control = GL_TRUE; _glfwPlatformExtensionSupported("WGL_ARB_framebuffer_sRGB");
window->wgl.ARB_create_context =
_glfwPlatformExtensionSupported("WGL_ARB_create_context");
window->wgl.ARB_create_context_profile =
_glfwPlatformExtensionSupported("WGL_ARB_create_context_profile");
window->wgl.EXT_create_context_es2_profile =
_glfwPlatformExtensionSupported("WGL_EXT_create_context_es2_profile");
window->wgl.ARB_create_context_robustness =
_glfwPlatformExtensionSupported("WGL_ARB_create_context_robustness");
window->wgl.EXT_swap_control =
_glfwPlatformExtensionSupported("WGL_EXT_swap_control");
window->wgl.ARB_pixel_format =
_glfwPlatformExtensionSupported("WGL_ARB_pixel_format");
window->wgl.ARB_context_flush_control =
_glfwPlatformExtensionSupported("WGL_ARB_context_flush_control");
} }
// Returns the specified attribute of the specified pixel format // Returns the specified attribute of the specified pixel format