[MacRuby-devel] OpenGL framework: gl.h versus gl3.h

Jim Getzen jim at getzen.name
Wed Dec 12 06:50:41 PST 2012


I am developing a basic MacRuby OpenGL library and I am avoiding the deprecated fixed-function pipeline in favor of OpenGL 3.2+ core functionality.

The problem is Apple's OpenGL framework has two primary header files: gl.h and gl3.h. In Objective-C, I can just do: #import <OpenGL/gl3.h> to access OpenGL 3.2 functions. In MacRuby, I seem to be limited to: framework 'OpenGL', which loads the older gl.h header.

To a large extent it doesn't matter since much of the 3.2 core functions already existed in OpenGL 2.1. However, there are some functions I need that only exist in 3.2:
glBindVertexArray
glGenVertexArrays
glDeleteVertexArrays

Versions of those functions do exist in OpenGL 2.1 (gl.h) with the APPLE suffix (e.g. glBindVertexArrayAPPLE), but they do not work when using a 3.2 core context.

I have worked around the issue with an Obj-C wrapper that imports gl3.h and wraps those specific functions, but it results in a warning: "gl.h and gl3.h are both included.  Compiler will not invoke errors if using removed OpenGL functionality."

At first glance, the clouds would part and the sun would shine if I could just load the gl3.h header from MacRuby instead of gl.h. However, I suspect that I would then be faced with a bridgesupport file that doesn't reflect gl3.h.

Having a bit of Obj-C code in my library isn't the end of the world, but I'd like to avoid the multiple-header warning, plus possible problems that might result from using OpenGL 2.1 functions with a 3.2 context (although I haven't seen any yet).

Any suggestions? Just port the whole kit to Obj-C and be done? Ugh.

On a related note, these constants are supposed to be defined in AppKit.framework bridgesupport, but aren't:
NSOpenGLPFAOpenGLProfile = 99
NSOpenGLProfileVersion3_2Core = 0x3200

Jim


More information about the MacRuby-devel mailing list