I’m running Windows 11, VSCode clang++ 18.1.8
I was able to retrieve the function pointer. The issue is when I call the wglChoosePixelFormatARB functions, it returns false and the SM_ASSERT gets called. How can I check which PixelFormats are available?
wglChoosePixelFormatARB =
(PFNWGLCHOOSEPIXELFORMATARBPROC)platform_load_gl_function("wglChoosePixelFormatARB");
wglCreateContextAttribsARB =
(PFNWGLCREATECONTEXTATTRIBSARBPROC)platform_load_gl_function("wglCreateContextAttribsARB");
if(!wglCreateContextAttribsARB || !wglChoosePixelFormatARB)
{
SM_ASSERT(false, "Failed to load OpenGL functions");
return false;
}
{
RECT borderRect = {};
AdjustWindowRectEx(&borderRect, dwStyle, 0, 0);
width += borderRect.right - borderRect.left;
height += borderRect.bottom - borderRect.top;
}
window = CreateWindowExA(0, title, // This references lpszClassName from wc
title, // This is the actual Title
dwStyle,
100,
100,
width,
height,
NULL, // parent
NULL, // menu
instance,
NULL); // lpParam
if(window == NULL)
{
SM_ASSERT(false, "Failed to create Windows Window");
return false;
}
dc = GetDC(window);
if(!dc)
{
SM_ASSERT(false, "Failed to get DC");
return false;
}
const int pixelAttribs[] =
{
WGL_DRAW_TO_WINDOW_ARB, 1, // Can be drawn to window.
WGL_DEPTH_BITS_ARB, 24, // 24 bits for depth buffer.
WGL_STENCIL_BITS_ARB, 8, // 8 bits for stencil buffer.
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, // Use hardware acceleration.
WGL_SWAP_METHOD_ARB, WGL_SWAP_EXCHANGE_ARB, // Exchange front and back buffer instead of copy.
WGL_SAMPLES_ARB, 4, // 4x MSAA.
WGL_SUPPORT_OPENGL_ARB, 1, // Support OpenGL rendering.
WGL_DOUBLE_BUFFER_ARB, 1, // Enable double-buffering.
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, // RGBA color mode.
WGL_COLOR_BITS_ARB, 32, // 32 bit color.
WGL_RED_BITS_ARB, 8, // 8 bits for red.
WGL_GREEN_BITS_ARB, 8, // 8 bits for green.
WGL_BLUE_BITS_ARB, 8, // 8 bits for blue.
WGL_ALPHA_BITS_ARB, 8, // 8 bits for alpha.
0
};
UINT numPixelFormats;
int pixelFormat = 0;
if(!wglChoosePixelFormatARB(dc, pixelAttribs,
0, // Float List
1, // Max Formats
&pixelFormat,
&numPixelFormats))
{
SM_ASSERT(0, "Failed to wglChoosePixelFormatARB");
return false;
}