20

I'm using GLFW 3.0 on Mac OS X 10.8, graphic card is Intel HD Graphics 5000

And my OpenGL API version is 2.1, aquired by

glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);

Compiling options:

g++ ... -framework OpenGL -framework Cocoa -framework IOKit ...

Headers:

#include <GLFW/glfw3.h>
#include <GL/glu.h>

The version is always 2.1, unlike the reported 3.2. My OS has been upgraded to 10.9, and OpenGL version is still 2.1.

It still cannot compile GLSL 3.3, while Apple says it supports 4.1. How do I access higher versions of the library?

legends2k
  • 31,634
  • 25
  • 118
  • 222
RnMss
  • 3,696
  • 3
  • 28
  • 37
  • glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); To write before creating your window. – Pierre Emmanuel Lallemant Oct 29 '13 at 12:58
  • @PierreEmmanuelLallemant : I tried this, and it leads to a failure in `glfwCreateWindow`. – RnMss Oct 29 '13 at 13:06
  • 1
    Try glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // opengl 3.2 or glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); // opengl 3.1 .It would crash only when the opengl version is not supported by OS X. – Pierre Emmanuel Lallemant Oct 29 '13 at 13:33
  • @PierreEmmanuelLallemant : The same result... – RnMss Oct 29 '13 at 14:19
  • Just because you upgraded your operating system does not mean you can use OpenGL 4.1... you need the appropriate version of the MacOS X Platform SDK. More than likely what you _really_ need to do is upgrade Xcode as well. There is a setting in the Xcode IDE that allows you to choose the default SDK that the commandline toolchain uses, I cannot remember where it is off the top of my head unfortunately. – Andon M. Coleman Oct 29 '13 at 20:07
  • @AndonM.Coleman : I did upgrade XCode, otherwise it could not even compile&link the code. – RnMss Oct 30 '13 at 04:13
  • To @PierreEmmanuelLallemant : I finally figured it out, I answered myself. And you were close to it. – RnMss Oct 30 '13 at 12:45

1 Answers1

31

You need to add both "forward_compat" and "core_profile" hints before creating the window.

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwCreateWindow(640, 480, "Hello World", NULL, NULL );
xryl669
  • 3,376
  • 24
  • 47
RnMss
  • 3,696
  • 3
  • 28
  • 37