mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Cleanup
This commit is contained in:
parent
d67a0259cf
commit
e250c226ca
@ -335,13 +335,17 @@ static void destroyContextWGL(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
static void loadWGLExtensions(void)
|
static void loadWGLExtensions(void)
|
||||||
{
|
{
|
||||||
int pf;
|
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
HDC dc;
|
|
||||||
HGLRC rc;
|
HGLRC rc;
|
||||||
|
HDC dc = GetDC(_glfw.win32.helperWindowHandle);;
|
||||||
|
|
||||||
_glfw.wgl.extensionsLoaded = GLFW_TRUE;
|
_glfw.wgl.extensionsLoaded = GLFW_TRUE;
|
||||||
|
|
||||||
|
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
||||||
|
// OpenGL ICD, from which we can then query WGL extensions
|
||||||
|
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
|
||||||
|
// creation failure occurs during manual pixel format enumeration
|
||||||
|
|
||||||
ZeroMemory(&pfd, sizeof(pfd));
|
ZeroMemory(&pfd, sizeof(pfd));
|
||||||
pfd.nSize = sizeof(pfd);
|
pfd.nSize = sizeof(pfd);
|
||||||
pfd.nVersion = 1;
|
pfd.nVersion = 1;
|
||||||
@ -349,27 +353,10 @@ static void loadWGLExtensions(void)
|
|||||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||||
pfd.cColorBits = 24;
|
pfd.cColorBits = 24;
|
||||||
|
|
||||||
dc = GetDC(_glfw.win32.helperWindowHandle);
|
if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
|
||||||
|
|
||||||
pf = ChoosePixelFormat(dc, &pfd);
|
|
||||||
if (!pf)
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to choose pixel format for WGL extension loading");
|
"WGL: Failed to set pixel format for dummy context");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DescribePixelFormat(dc, pf, sizeof(pfd), &pfd))
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"WGL: Failed to describe pixel format for WGL extension loading");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPixelFormat(dc, pf, &pfd))
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"WGL: Failed to set pixel format for WGL extension loading");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +364,7 @@ static void loadWGLExtensions(void)
|
|||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to create context for WGL extension loading");
|
"WGL: Failed to create dummy context");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,31 +373,25 @@ static void loadWGLExtensions(void)
|
|||||||
wglDeleteContext(rc);
|
wglDeleteContext(rc);
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to make context current for WGL extension loading");
|
"WGL: Failed to make dummy context current");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions for WGL_EXT_extension_string
|
// NOTE: Functions must be loaded first as they're needed to retrieve the
|
||||||
// NOTE: These are needed by extensionSupported
|
// extension string that tells us whether the functions are supported
|
||||||
_glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
|
_glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
|
||||||
wglGetProcAddress("wglGetExtensionsStringEXT");
|
wglGetProcAddress("wglGetExtensionsStringEXT");
|
||||||
_glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
|
_glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
|
||||||
wglGetProcAddress("wglGetExtensionsStringARB");
|
wglGetProcAddress("wglGetExtensionsStringARB");
|
||||||
|
|
||||||
// Functions for WGL_ARB_create_context
|
|
||||||
_glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
|
_glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
|
||||||
wglGetProcAddress("wglCreateContextAttribsARB");
|
wglGetProcAddress("wglCreateContextAttribsARB");
|
||||||
|
|
||||||
// Functions for WGL_EXT_swap_control
|
|
||||||
_glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
|
_glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
|
||||||
wglGetProcAddress("wglSwapIntervalEXT");
|
wglGetProcAddress("wglSwapIntervalEXT");
|
||||||
|
|
||||||
// Functions for WGL_ARB_pixel_format
|
|
||||||
_glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
|
_glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
|
||||||
wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
||||||
|
|
||||||
// This needs to include every extension used below except for
|
// NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
|
||||||
// WGL_ARB_extensions_string and WGL_EXT_extensions_string
|
// checked below as we are already using them
|
||||||
_glfw.wgl.ARB_multisample =
|
_glfw.wgl.ARB_multisample =
|
||||||
extensionSupportedWGL("WGL_ARB_multisample");
|
extensionSupportedWGL("WGL_ARB_multisample");
|
||||||
_glfw.wgl.ARB_framebuffer_sRGB =
|
_glfw.wgl.ARB_framebuffer_sRGB =
|
||||||
|
Loading…
Reference in New Issue
Block a user