Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my OpenGL version always 2.1 on Mac OS X?

Tags:

macos

opengl

glfw

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?

like image 720
RnMss Avatar asked Oct 29 '13 12:10

RnMss


People also ask

What version of OpenGL does macOS support?

According to Apple, OpenGL is no longer supported. However, it appears v4. 1 of OpenGL was supported on many devices as of July 28, 2020.

Can you update OpenGL on Mac?

Technically, you cannot get a (windowed) OpenGL 3.2 context programming purely in C on OS X. You have to use part of Cocoa (an Objective-C framework) called NSOpenGL; AGL (deprecated C-based API) as well as the really old X server implementation (XQuartz) are perpetually limited to OpenGL 2.1.

How do I know which OpenGL I have on my Macbook?

Open OpenGL Extensions Viewer. In the Tasks menu, click Summary. You can test the OpenGL version for your GPU by looking at the 4.6 and lower level version: example: The GPU has a 4.6/4.5 level OpenGL version.

Does macOS use OpenGL?

OpenGL was deprecated in macOS 10.14 which means that Apple will no longer develop newer versions of OpenGL for macOS. However, you can still run OpenGL 4 natively on higher versions such as macOS 10.15.


1 Answers

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 );
like image 114
RnMss Avatar answered Sep 23 '22 01:09

RnMss