PDA

View Full Version : How to get if current GL context is Core or Compatibility



Aliii
08-23-2014, 12:22 PM
Is there a way to get wheter the current OpenGL version is CORE or COMPATIBILITY? ...the same way I can get the version numbers glGetIntegerv(GL_MAJOR_VERSION, ...). Thanks!

Dan Bartlett
08-23-2014, 02:04 PM
Use glGetIntegerv(GL_CONTEXT_PROFILE_MASK,...) in OpenGL 3.2 or above to query this. GL_CONTEXT_FLAGS might also be useful too if you want to check whether debug/forward-compatible/robust/... flags are set.

Aliii
08-23-2014, 09:50 PM
Thanks! Sadly, it returns 0. Which is according to this post is a driver bug:
https://www.opengl.org/discussion_boards/showthread.php/171380-NVIDIA-drivers-not-returning-the-right-profile-mas

I have no control over how the context is created on the lowest level since Im using SDL. I tell it to create a 3.3 Core context, ...3.3 is OK, but it seems to be Compatibility.

mhagain
08-24-2014, 03:10 PM
Try to do something that's not supported in a core context. Depending on your driver this may be as simple as a glBegin/glEnd call, followed by a glGetError. Or you might try a draw call with VAO 0 - you should get GL_INVALID_OPERATION on a core context.

Osbios
08-25-2014, 12:39 PM
Or you might try a draw call with VAO 0 - you should get GL_INVALID_OPERATION on a core context.
To my knowledge nvidia blobs allow using the 0 VAO in core.

malexander
08-27-2014, 03:48 PM
Trying checking for the GL_ARB_compatibility extension:



int num_ext = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &num_ext);
for(int i=0; i<num_ext; i++)
if(!strcmp(glGetStringi(GL_EXTENSIONS,i), "GL_ARB_compatibility"))
printf("Compatiblity Profile\n");


If that is extension is present, you're definitely in a compatibility profile. Otherwise, assume core.