How do I upgrade my OpenGL from 2.1 to 3.3 on Mac OSX? - macos

I am trying to program OpenGL 3 in C on my Macbook Pro.
My graphics card is NVIDIA GeForce 320M 256 MB, but I have OpenGL 2.1 According to wikipedia, I should be able to use OpenGL 3.3:
However, when I run glxinfo | grep -i opengl, I get OpenGL version string: 2.1 NVIDIA-8.24.16 310.90.9.05f01.
How do I go about upgrading it? I am running Mavericks.

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.
Apple's own implementation of GLUT wraps NSOpenGL (FreeGLUT does not), and so do GLFW, SDL, etc. They have small portions that are written in Objective-C to interface with NSOpenGL and this allows them to create window-based OpenGL 3.2+ render contexts even in C software.
Now, the problem here is actually that glxinfo uses XQuartz, which does not support OpenGL 3.2+. I would suggest you use the OpenGL Extension Viewer on the Mac App store if you want detailed info about your OpenGL capabilities.
Since you're just starting out with OpenGL development on OS X, I would also suggest you have a look here for a quick overview of the various APIs.

You cannot upgrade your graphics drivers since they are provided by Apple. But your system should support OpenGL 3.3 ( https://developer.apple.com/opengl/capabilities/ ). When creating a OpenGL context you must request a CoreProfile mode. If you are using GLUT this can be done this way:
GLUT on OS X with OpenGL 3.2 Core Profile

Related

How to enable OpenGL 3.X in Mac OS?

Previously I'm using OpenGL on Mac via glew 2.1.0 and JUCE5, but it can only access OpenGL 2.1 APIs. I can't believe that my Macbook Air (Intel Graphics) bought on 2018 can only provide this, and I'm tired to maintain two sets of API calls and shaders for 2.1 and 3.X separately. Then I tried to replace all #include <GL/glew.h> with #include <OpenGL/gl3.h>, then link with OpenGL framework directly. However, the program still failed to compile a #version 130 shader (it claims not supported).
Here I want to know that:
Does all recent Apple devices (after 2010) capable for OpenGL 3.0?
How to turn on OpenGL 3.0 support on MacOS?
Finally I found the way: I have to enable it on JUCE side. When JUCE's OpenGL context is created, I must explicitly set expected OpenGL version by setOpenGLVersionRequired( juce::OpenGLContext::openGL3_2 ) before using it.
IMPORTANT: this would still lead failure to a compile to #version 130 shader, as Apple would strictly deprecate all old features prior to specified API version. A simple workaround is to dynamically prepend a version declaration according to system type, as GLSL 1.3.0 features is mostly included by GLSL 1.5.0.

Unable to link OpenGL compatibility profile (EXT symbols not recognized)

I decided to use GLEW for handling extensions instead of requesting core profile and having to migrate my code.
I would like to add support for FBO's through the EXT profile as a first step.
The problem is gcc will not link my code (OSX 10.10), it does not recognize any gl*EXT() functions. For instance, glBindFrameBufferEXT()
flags as undefined symbol. (glBindFrameBuffer() was also
unrecognized...)
I link against GLEW and have tried using GLEXT or GLFW with compatibility profile, but nothing works! Am I missing a library? How do I tell gcc to use the right GL profile? Am I obliged to migrate to core profile?
In MacOS X GLEW is not doing a lot, because there are not a lot of OpenGL extensions on MacOS X and due to the way OpenGL is integrated in MacOS X all functions of the OpenGL version supported by the available framework are immediately available
… or not, if you're using an extension function that's not supported by MacOS X's OpenGL implementation.
MacOS X is the weird duckling in the OpenGL family: OpenGL is used at a very low level in the OS's core graphics routines, to OpenGL is very well supported by the OS. But it's built so deep into the OS that it hardly can be updated without updating the whole OS.
Solution: Don't use that extension. FBOs have been introduced with OpenGL-3.3 so you've to create a 3.3 core profile context and can use the functions (without the …EXT) directly.

Debugging OpenGL ES 2.0 game that runs in Windows through PowerVR emulation

I have small cross platform engine that runs my OpenGL ES 2.0 games on Android and on Windows. To run it on Windows I am using PowerVR emulator (just libraries linked to the project). It all works well.
Now I would like to debug it and inspect in any OpenGL debugger. I tried Intel GPA, AMD CodeXL, gDebugger, glslDevil. But non of them were able to do it. In case of Intel GPA it did not find the running game. In other cases it started the game but failed to pause it or do anything later.
I do not know whether it is because it is OpenGL ES instead of OpenGL. But the PowerVR emulation must work like translating OpenGL ES to OpenGL, I think?
My questions are:
Is there any (utility) way how to debug OpenGL ES 2.0 programs on Windows?
Or is there any better emulation library than PowerVR that will force the app look like OpenGL for other tools (instead of OpenGL ES)?
I am doing all this as none of debuggers work for me on Android device. I am developing with Samsung Galaxy Tab (which is Tegra GPU), but Nvida's PerfHUD ES does not currently support it (and I also do not meet Android 4.0 or higher having only 3.1)
Is there any way how to debug OpenGL ES on Android device that has Android version 3.1 and it is Samsung Galaxy Tab device?
Thanx
You're correct - PVRVFrame translates OpenGL ES calls into host OpenGL calls. This is why the likes of gDEBugger will capture the OpenGL API calls made by the emulator rather than the calls you actually submitted.
The PowerVR SDK includes an OpenGL ES/EGL API recording tool called PVRTrace that has all of the functionality you're looking for.
The PVRTrace recording libraries can be used to record applications using PVRVFrame on Windows and Linux. The SDK also includes recording libraries for Android and Linux devices.
PVRTraceGUI (analysis tool for Windows, OSX & Linux) can be used to review and inspect the data you've recorded. It also has an Image Analysis widget that allows you to step through the draw calls in your recording & some other handy features, such as a Pixel Analysis pie chart that highlights the most costly fragment shaders in your render so you know where to focus shader optimisation.
There's also a PVRTrace standalone playback tool that allows you to replay your recordings on any of the supported OS's (inc. Windows & Android).
You can find an overview of the tool on the Imagination website here & can download PVRTrace through the PowerVR SDK installer, available here
I routinely debug OpenGL ES on Windows using the PowerVR VFrame translator, which converts OpenGL ES calls to OpenGL, as you said. I think it's the best solution. VFrame has some step and tracing features, but mostly I am using the debugging features of MSVC++.
If you are using GLSurfaceView on android, it has an OpenGL ES tracing feature too. I also recommend using an X86 AVD rather than ARM or trusting the drivers on any one device. This article explains in detail:
http://software.intel.com/en-us/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-1

OSX and OpenGL 4.x compatibility

I'm working on a portable application that should run on OSX-Lion as well.
From what I read here OpenGL/GLSL support seems to be 3.2/150 can someone confirm this?
My application requires at least GLSL ver 400. Is there a way to have it running on Lion? Some cards (i.e. ATI HD6770) are OpenGL 4.1 compliant. Does it mean it can go only as far as 3.2/150 under OSX?
confirmed by alternate source, osx opengl 4.x support is still TBA

How to do OpenGL 3 programming on OS X with a GeForce 9400

I have a MacBook Pro with a GeForce 9400 graphics card. Wikipedia said this card supports OpenGL 3.
But the header and library shipped with OS X 10.6 seems to be OpenGL 2 only (I checked the files in /usr/X11/include/).
I need to do some OpenGL 3 programming. Can I do it with my current hardware and OS? What do I need to get and install?
Sadly, I don't think you can yet, as detailed here.
I believe Lion will upgrade OpenGL to 3.2 for OS X though (which is still short of the more useful 3.3 unfortunately).
NB: I do not own a Mac, this is purely from trying to learn modern OpenGL on the windows side and digging around to understand how portable it would be.
Edit: this thread on the official OpenGL forums has more detail. Although (see comments below this answer) it may not be completely clear why vendors cannot provide OpenGL 3+ compliant drivers, it seems pretty clear that there is no way to use fully OpenGL 3.3 compliant code and shaders in OS X. Some workarounds are provided in that thread however, as well as in my first link.
The best place to check OpenGL support on the various OSX and Mac combinations is:
http://developer.apple.com/graphicsimaging/opengl/capabilities/
See the "Core" subpage for 10.7+
OpenGL 3.2 with GLSL 1.5 on 10.7.2 isn't too bad.
Your current hardware can support OpenGL 3, but not the OS. Mac OS X 10.7 (Lion) should support OpenGL 3, which is a solution only if you can wait many months.
Your only option right now is to switch to a different OS such as Windows or Linux. You'll have to boot from this other operating system, because the virtual machine systems present a virtual video card to the guest operating systems, and none have OpenGL 3 compatible virtual video cards.
(Disclaimer: This information is based on taking Windows OpenGL and replacing wgl with glX. But I did verify that the corresponding extensions exist in GLX land)
You won't find OpenGL 3 support in any header files. Rather you need the GLX_ARB_create_context extension.
The other answers are probably correct about missing support in OSX, but even when support comes, you'll have to use glXGetProcAddress and load the extension. (Can't video card manufacturers add support for these extensions through their driver? Why does it require "OS support"?)
Windows OpenGL developer here. On Windows 7 only OpenGL 1.4 is officially supported, but everyone gets around this limitation by querying which functions are available at run-time.
On OSX I expect you can do the same thing. The easiest way to do this is with The OpenGL Extension Wrangler Library: http://www.opengl.org/sdk/libs/GLEW/

Resources