Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLFW opens OpenGL 3.2 context but Freeglut can't - why?

I am working on a Mac, I've got FreeGlut compiled and installed, but I can't seem to get the OpenGL 3.2 context with it. However, I can get it without any problem while using GLFW. So in GLFW, this code works perfectly fine:

    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwOpenWindow(500, 500, 8, 8, 8, 8, 24, 8, GLFW_WINDOW)

But with FreeGlut, this code fails(on glutCreateWindow):

glutInitContextVersion (3, 2);
glutInitContextProfile(GLUT_CORE_PROFILE);  
glutInitWindowSize (width, height); 
glutInitWindowPosition (300, 200);
int window = glutCreateWindow (argv[0]);

The error it fails with is:

X Error of failed request:  BadRequest (invalid request code or no such operation)
  Major opcode of failed request:  34 (X_UngrabKey)
  Serial number of failed request:  29
  Current serial number in output stream:  29

I am running on MacOS X 10.8 Mountain Lion, with Intel HD4000 graphics, having installed XQuartz as my X11 server,and having compiled and installed FreeGlut 2.8 from sources.

Does anyone know what might be the issue?

like image 590
gambiting Avatar asked Feb 26 '13 15:02

gambiting


1 Answers

In 10.8 and 10.7 GL 3.2 is available if you explicitly call for it when setting up the GL context. Apple calls this the "Core Profile" to distinguish from the "Legacy Profile" which is GL 2.1.

I ran into this issue with Wine on OSX, it does not support OpenGL 3.2. My understanding is that the X11 server (either Apple X11 or XQuartz) currently does not implement the 3.2 support, nor is there a switch to flip somewhere to enable it. It could be for compatibility concerns since 3.2 profile will break some existing GL applications

This post suggests using GLFW (or maybe Apple's GLUT.framework if there is still such a thing)

This page explains the GL stack on OSX and confirms the 2.1 issue with GLX.

like image 158
wally Avatar answered Nov 12 '22 05:11

wally