# Extension loading for a wide user base + on a mac

This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

#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>

{
#ifdef WIN32
#else
#endif
}


Thanks!

##### Share on other sites
Why don't just use GLee or GLew?
This will solve both of your problems/questions :)

##### Share on other sites
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.

##### Share on other sites
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 ...

##### Share on other sites
Sorry for the bump, but I would really appreciate any thoughts on what I should do about my first question.

Thanks!

##### Share on other sites
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).

##### Share on other sites
For more specific information on what is supported on OS X, this is the best reference:

http://homepage.mac.com/arekkusu/bugs/GLInfo.html

##### Share on other sites
Quote:
 Original post by RichardSQuestion 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 and , rather than You should use something like the NSGLGetProcAddress belowEven 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 ...)