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

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/

Related

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

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

OSX available OpenGL ARB extensions

from http://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1072_Core.html appears that current OSX 10.7.2 core OpenGL support is still limited at 3.20 with GLSL 1.50
among other data are the available ARB_ extensions.
I was wondering if these were the minimum guaranteed to be present extensions, or if you really have only these four, namely:
ARB_instanced_arrays
ARB_occlusion_query2
ARB_shader_bit_encoding
ARB_timer_query
Im currently developing a portable application that should run on OSX and uses ARB_separate_shader_objects, does it mean it will definitely not run on OSX 10.7.2?
Those, plus the extensions that are part of the legacy profile, are the only extensions currently available with Apple's drivers for the drivers/graphics cards listed on those pages.

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

WebGL on older Mac OS X versions (say 10.4)

Not really a programming related question but...
I'd like very much to experiment with WebGL on my spare time. My current 'spare time' machine is a MacBook running Mac OS X Tiger (10.4.xx) and I'm unable to find a new browser supporting this OS. Firefox dropped support, Chrome too, and Safari idem.
I read somewhere that this is due to a Quicktime bug that Apple won't fix.
Does anyone have more information on this issue ?
Does anyone have a clue or track to find a running implementation of WebGL on Mac OS X 10.4 ?
Cheers,
I know a fellow who is maintaining a Firefox 4 port to OS X 10.4.
Check out http://www.floodgap.com/software/tenfourfox/
Edit: Unfortunately I've just found out that this doesn't quite fulfil your main reason for wanting Firefox 4.
From the dev's site:
OpenGL support is presently disabled
in 10.4Fx. This is Apple's fault, as
Mozilla requires non-power-of-two
texture sizes, which require OpenGL 2.
Unfortunately, PPC Tiger does not
support OpenGL 2 at all, and only a
subset of cards support it in PPC
Leopard (the really irritating part is
that Intel Tiger does have OpenGL 2,
and OpenGL 2 came out in 2004!). It
may be enabled in the future for those
handful of configurations on Leopard,
but this won't benefit the majority of
users. Note that many graphics
features will work just fine; they
just won't be hardware-accelerated.
If you can get a build of Firefox which has WebGL to run, but don't have a GPU that supports OpenGL ES 2.0, you might want to try setting the "webgl.osmesalib" about:config option. Even simple programs will probably run at a flip-book frame rate however.

Update OpenGL libraries on windows

I'm using a 3rd party DLL which uses OpenGL. Right now that 3rd party does not work correctly as the display does not refresh correctly. I came to suspect that the OpenGL library isn't correctly installed or may be outdated.
Is there a way to update the OpenGL library on windows? Is there like an official site which will hold the correct opengl.dll file or something like that?
I believe the OpenGL libraries are just part of the drivers that ship with your graphics card. Upgrading your graphics drivers should upgrade your OpenGL stuff to the latest your card supports.
OpenGL should be up to date on Windows.
However, if you are getting display/refresh problems, and they're only occuring on windows, this is most likely an issue with your graphics driver.
Try updating to your latest OpenGL graphics driver. This fixes many OpenGL issues on Windows.
opengl.dll is part of your display card driver. Windows comes with a default opengl.dll that offers very little acceleration. Re installing the graphics card driver or upgrading to the latest version should take care of your problem.
OpenGL is implemented in the graphics driver. If you want to use the latest OpenGL version as a developer you download and use GLEW (http://glew.sourceforge.net/) as a normal library. This will give you access to cross platform OpenGL 4.1 or whatever version your card supports.

Resources