Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: How to get if current GL context is Core or Compatibility

  1. #1
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    52

    How to get if current GL context is Core or Compatibility

    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!

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    456
    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.

  3. #3
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    52
    Thanks! Sadly, it returns 0. Which is according to this post is a driver bug:
    https://www.opengl.org/discussion_bo...ht-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.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,217
    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.

  5. #5
    Intern Contributor
    Join Date
    May 2013
    Posts
    69
    Quote Originally Posted by mhagain View Post
    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.

  6. #6
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    327
    Trying checking for the GL_ARB_compatibility extension:

    Code :
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •