Use wglGetPixelFormatAttribivARB to get pixel format count

DescribePixelFormat can return a very different number of pixel formats
than does wglGetPixelFormatAttribivARB: 220 vs 670 on my system (Nvidia
GTX 965 M). Being different in that direction is not a problem, but if
DescribePixelFormat returns more formats than
wglGetPixelFormatAttribivARB, the loop will fail and terminate the
context creation.
This commit is contained in:
Bill Currie 2022-09-15 17:08:10 +09:00
parent 6b57e08bb0
commit 2de8371929

18
src/wgl_context.c Normal file → Executable file
View File

@ -72,10 +72,20 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
int attribs[40];
int values[sizeof(attribs) / sizeof(attribs[0])];
nativeCount = DescribePixelFormat(window->context.wgl.dc,
1,
sizeof(PIXELFORMATDESCRIPTOR),
NULL);
if (_glfw.wgl.ARB_pixel_format)
{
int attrib[] = { WGL_NUMBER_PIXEL_FORMATS_ARB };
wglGetPixelFormatAttribivARB(window->context.wgl.dc, 1, 0,
1, attrib, &nativeCount);
}
else
{
nativeCount = DescribePixelFormat(window->context.wgl.dc,
1,
sizeof(PIXELFORMATDESCRIPTOR),
NULL);
}
if (_glfw.wgl.ARB_pixel_format)
{