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

3

8

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?

Advisory answered 26/2, 2013 at 15:50 Comment(4)
Having the exact problem but I'm using FreeGlut as included in XQuartz (opt/x11/lib opt/x11/include). Did you solve the issue?Ott
Same issue here - were you able to solve the problem?Hau
Did anyone of you solved the problem? I'm having the same issue. I'm using freeGlut included in XQuartzInsincere
The best is to just stick with glfw, i got stuck with the same issue on OS X 10.10. Code compiles fine but then it crashes when running. Have XQuartz setup. Tried with no luck to get version 3.2Culosio
G
1

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.

Gammadion answered 26/2, 2013 at 19:11 Comment(3)
I am sorry,but don't see how this relates to my question. As I have shown - it DOES work with GLFW, which runs on top of XQuartz on my system, so it does definitely support 3.2 contexts.Advisory
I am sorry,but don't see how this relates to my question. As I have said - OpenGL 3.2 DOES work with GLFW, which runs on top of XQuartz on my system, so it does definitely support 3.2 contexts. My only issue is that I would like to use freeglut, purely because it's more convenient. But if that's not possible, then I will develop using GLFW. But please don't tell me it's impossible to get 3.2 context, because I've already got one.Advisory
glfw also has a Cocoa and Carbon port, are you certain it is running on top of XQuartz?Gammadion
L
0

Freeglut is an extended implementation of the SGI GLUT Toolkit, and ( with a few exceptions around obsolete hardware ) implements the same functions.

Unfortunately, this includes a number of features that would break in a strictly CORE/FORWARD COMPATIBLE implementation.

Typically, if you request a context WITHOUT specifying a version or profile, you will get the best that the combination of driver and GL toolkit can offer, which is normally a compatibility profile, rather than core profile.

Note that the only thing you lose through using a compatibility profile is the supposed checking for deprecated functions. All new core function should work without issue.

This problem with freeglut is not restricted to Apple, it also manifests under Linux using some Gallium drivers. It is not clear that there is any short-term intent to rectify this, so if you need to use CORE/FORWARD COMPATIBLE, you should probably switch to GLFW or SDL.

Lietman answered 23/2, 2014 at 23:16 Comment(0)
B
0

You need to include the flag. usually under the Version. It should look something like this:

glutInitContextFlag(GLUT_FOWARD_COMPATIBLE);
Branson answered 14/7, 2014 at 15:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.