How to use WGL_CONTEXT_MAJOR_VERSION_ARB and WGL_CONTEXT_MINOR_VERSION_ARB on Windows?

WinMain.cpp

#define WGL_CONTEXT_MAJOR_VERSION_ARB     0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB     0x2092
#define WGL_CONTEXT_FLAGS_ARB             0x2094
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB  0x00000001
#define WGL_CONTEXT_PROFILE_MASK_ARB      0x9126
typedef HGLRC(WINAPI* PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC, HGLRC, const int*);

I tried a couple of hexidecimal to decimal converters on 0x2091 and 0x2902 for the WGL_CONTEXT_MAJOR_VERSION_ARB and WGL_CONTEXT_MINOR_VERSION_ARB values. Things don’t seem to convert anything close to the OpenGL 3 for major and three for the minor context that is being loaded here. WinMain.cpp is set up to load with glad (Hands-On-Game-Animation-Programming-master.zip, Packt publishing). I have the Iris Xe graphics card which does seem to load a 4.6 context running on Windows 11 Pro.

So far I tried setting 4 for the major ARB and 6 for the minor ARB but there is some type of fault being generated by Visual Studio… So far I have 0x2091 converting to 8337 in decimal which does not seem to be anything close to 3 like the context that is being loaded?

So in this case with glad set up how should I set up WGL_CONTEXT_MAJOR_VERSION_ARB, and WGL_CONTEXT_MINOR_VERSION_ARB (and whatever else needs to be changed it?) to load an OpenGL 4.6 context?

Those are just enumerators, numbers which are used to identify properties or settings. You’re supposed to use them to specify which version of OpenGL you want.

WinMain.cpp

	WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
	WGL_CONTEXT_MINOR_VERSION_ARB, 6,

I replaced GLAD with a 4.6 profile I downloaded from the GLAD site. So far the problem is that there is an access violation reading at the line posted below. Any way to get a 4.6 context starting on Windows 11 Pro with Intel Iris Xe?

bool swapControlSupported = strstr(_wglGetExtensionsStringEXT(), "WGL_EXT_swap_control") != 0;

Try:

fprintf( stderr, "wglGetExtensionsString() = %p\n", wglGetExtensionsString() );

If it’s NULL, see this in WGL_EXT_extensions_string:

Also…:

2 Likes