Function to get extension function pointers?

Is there something like wglGetProcAddress/glXGetProcAddress for Mac OS X?

-Lev

Not supplied by Apple. You can use something like this, though:

void* myglGetProcAddress(const char* procName)
{
    static CFBundleRef openGLBundle = NULL;

    if (openGLBundle == NULL)
    {
        openGLBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
    }

    CFStringRef functionName = CFStringCreateWithCString(NULL, procName, kCFStringEncodingASCII);

    void* function = CFBundleGetFunctionPointerForName(openGLBundle, functionName);

    CFRelease(functionName);

    return function;
}

Warning, I didn’t test that code before posting it, though I only edited it slightly from a working example

If the extension you’re trying to use is available on all versions of Mac OS X you want your program to run on, you don’t need that function – you can just link directly to the extension functions.

You can also look at the Mach-O commands for symbol management if you are using dyld.

There should be a Q&A posted shortly covering this for Carbon and Cocoa. Check <http://developer.apple.com/opengl&gt; in the next few days.

Originally posted by Lev:
[b]Is there something like wglGetProcAddress/glXGetProcAddress for Mac OS X?

-Lev[/b]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.