Reputation: 9173
I am writting a C++ application which works with OpenGL on Mac OS X.
I have tried GLFW and Freeglut for window management.
Both glfw and freeglut have been installed with brew
There is something i do not understand.
Here is my C++ Code for FreeGlut:
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitContextVersion (3, 3);
glutInitContextFlags (GLUT_CORE_PROFILE | GLUT_DEBUG);
glutInitWindowSize(WIDTH, HEIGHT);
glutCreateWindow("Test");
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
return -1;
}
cout < <"GL_SHADING_LANGUAGE_VERSION: "<< glGetString (GL_SHADING_LANGUAGE_VERSION) << endl;
...
There is the output:
GL_SHADING_LANGUAGE_VERSION: 1.20
And here is my C++ code with GLFW:
int main(int argc, const char * argv[])
{
if (!glfwInit())
{
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
window = glfwCreateWindow(640, 480, "Test", NULL, NULL);
if (window == NULL) {
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = true;
if (glewInit() != GLEW_OK) {
return -1;
}
std::cout << "GL_SHADING_LANGUAGE_VERSION: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
Here is the output:
GL_SHADING_LANGUAGE_VERSION: 4.10
My question is why the GLSL version is not the same ?
Thanks
Upvotes: 3
Views: 2573
Reputation: 22174
The glut initialization is wrong. GLUT_CORE_PROFILE
is not a valid parameter for glutInitContextFlags
. The correct code should look like this:
glutInitContextVersion(3, 3);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInitContextFlags(GLUT_DEBUG);
Also note, that you are not requesting the same profile in both examples. The GLUT examples asks for 3.3 Core with Debug while the glfw example asks for 3.3 Core with Forward Compatibility.
Upvotes: 2