Extension loading for a wide user base + on a mac

Started by
6 comments, last by deavik 18 years, 1 month ago
Hello! 1/ If I want to make my application usable for the widest user base possible, should I use functions introduced by extensions or their equivalents when they were upgraded to core? eg. glDeleteShader (GL 2.0) vs glDeleteObjectARB (ARB_shader_objects), glUniform1f vs glUniform1fARB, in multitexture glActiveTexture vs glActiveTextureARB The GL 2.0 functions (for shader objects) calls look neater + have been decided on after more deliberation I guess so I should use them, but then again the user of my program must have a 2.0 driver. What would you do optimally? 2/ If anyone here is using a Mac (I don't know much about Mac--MacOSX? previous generations?), can you please just outline the process including info about headers requred, #defines required (like I had to #define GLX_GLXEXT_LEGACY with Nvidia's headers for glXGetProcAddressARB), the proc loading function call, any other gotchas. Currently I just go like this:

#ifdef WIN32
#  include <windows.h>
#  include <GL/gl.h>
#else // needed--test for Mac and X, right now it just goes to X code
#  include <GL/gl.h>
#  define GLX_GLXEXT_LEGACY
#  include <GL/glx.h>
#endif


#include <GL/glext.h>




get_proc_address(...)
{
#ifdef WIN32
 // wglGetProcAddress ...
#else
 // glXGetProcAddressARB ...
#endif
}

Thanks!
Advertisement
Why don't just use GLee or GLew?
This will solve both of your problems/questions :)
--
Firslty on Unix the OpenGL support is at 1.5 so you would have to check the version. Second option is you could just dynamically load everything. It depends, not many drivers support OpenGL 2.0 very well. So you might want to support CG as well. Optimally use an extension loader as Enrico suggested or write one if license issues stop you from using one.
The more applications I write, more I find out how less I know
Thanks for the replies! I know using an extension loading library would be a smart thing to do, but I kind of already have a lot of code in place, and just wanted to know what had to be done for a Mac. I have used GLee before (never used GLEW) and it doesn't have support for Mac. I'm trying my best but it's a lot like "pin-the-tail-of-the-donkey" though, because I don't have access to one for testing.

I found a code snippet here (NSGLGetProcAddress) which seems like it should work and that I can use it in my code (what are Carbon and Cocoa BTW?).

About the first question: CRACK are you thinking abuot compile time checks? Those are OK I was wondering about the procs loaded at runtime ...
Sorry for the bump, but I would really appreciate any thoughts on what I should do about my first question.

Thanks!
Question 1:
It is possible for a driver to claim OpenGL 2.0 support, but not export ARB_shader_objects, and vise-versa. For the widest possible support, you technically need to write code to conditionally use both forms.

In practice, you should probably code to the extension form. For instance, NV1x hardware does not support 3D textures, and so only claims OpenGL 1.1 support on OS X (on windows, I believe 3D textures are supported, but are done via software rasterization). However, GLSL vertex shaders are supported on that renderer. Checking for the extension is the only way to get access to GLSL on those systems.

However, the Core variants of the GLSL functions exist on OS X, and work fine, even though GL 2 is not yet exported (there just isn't a proper way to query for partial Core support).

Other OS X specific bits:
You need to include <OpenGL/gl.h> and <OpenGL/glext.h>, rather than <GL/gl.h>
You should use something like the NSGLGetProcAddress below
Even you you want 'wide' support, it isn't worth your time to support OS X 10.2 systems (or earlier).
For more specific information on what is supported on OS X, this is the best reference:

http://homepage.mac.com/arekkusu/bugs/GLInfo.html
Quote:Original post by RichardS
Question 1:
It is possible for a driver to claim OpenGL 2.0 support, but not export ARB_shader_objects, and vise-versa. For the widest possible support, you technically need to write code to conditionally use both forms.

In practice, you should probably code to the extension form. For instance, NV1x hardware does not support 3D textures, and so only claims OpenGL 1.1 support on OS X (on windows, I believe 3D textures are supported, but are done via software rasterization). However, GLSL vertex shaders are supported on that renderer. Checking for the extension is the only way to get access to GLSL on those systems.

However, the Core variants of the GLSL functions exist on OS X, and work fine, even though GL 2 is not yet exported (there just isn't a proper way to query for partial Core support).

Other OS X specific bits:
You need to include <OpenGL/gl.h> and <OpenGL/glext.h>, rather than <GL/gl.h>
You should use something like the NSGLGetProcAddress below
Even you you want 'wide' support, it isn't worth your time to support OS X 10.2 systems (or earlier).

Thanks for the great advice. [smile]

Right now I'm using the 2.0 functions, but I'll try to add conditional support for the ARB extension by parsing the version string or something. And I'll also probably let the Mac be for now (it won't be much change of code if I wnat to get it working later anyway, so ...)

This topic is closed to new replies.

Advertisement