[osg-users] Reading shader source on Mac

Filip Wänström filip.wanstrom at tii.se
Mon Sep 8 01:07:47 PDT 2008

More merry mac musings...

I get the impression (from the osg source) that when a shader is read from
the file it uses raw c++ IO. This means that shaders source that I have put
in my Resources directory in my App bundle (e.g.
OsgTest.app/Contents/Resources/data/shaders/simple.vert) won't read.

I remedied this by using the following snippet of mac code:

// Function
void SetCWDToMainBundle()
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
    char path[PATH_MAX];
    if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path,
        // Error

// In use:
void SetCWDToMainBundle()
v->loadShaderSourceFromFile( "data/shaders/simple.vert" );
f->loadShaderSourceFromFile( "data/shaders/simple.frag" );

Obviously something like that happens in the image and model loading code so
I guess it's easy to fix If you have access (and understanding of!) to the
source code

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080908/bf280561/attachment-0002.htm>

More information about the osg-users mailing list