Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a glsl 330 context on osx 10.9 (Mavericks)

I saw a similar question here: OpenGL 4.1(?) under Mavericks, but it seems that person is relying on glut, so the solution doesn't apply.

I'm on OSX 10.9 (Mavericks), with an NVidia GeForce 650, developing in C++, using GLEW and GLFW.

I'm not using xcode- keeping it simple with a very basic makefile.

Anyways- I have these 5 lines of code:

window = glfwCreateWindow(640,480,"hello world",NULL,NULL);
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
glewInit();

printf("shader lang: %s\n",glGetString(GL_SHADING_LANGUAGE_VERSION));

and it prints out

shader lang: 1.2

I'm assuming setting glewExperimental should handle correctly getting the core context? (/ the stuff the other dude was talking about in the other thread)

What else do I need to do to enable the latest shader versions?

Ps- my full code is here, including the makefile: https://github.com/Phildo/openglexp , but I'm not sure how useful it will be.

like image 523
Phildo Avatar asked Feb 14 '23 16:02

Phildo


1 Answers

I have never used GLFW before, but according to the API documentation and my thorough experience with low-level OS X GL context management, the following code should fix your problem:

glfwInit       ();

glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint (GLFW_OPENGL_PROFILE,        GLFW_OPENGL_CORE_PROFILE);

Make sure you call these things before glfwCreateWindow (...)

like image 91
Andon M. Coleman Avatar answered Feb 28 '23 00:02

Andon M. Coleman