Hi Joel,

Just for reference, the error is:  "Unhandled exception at 0xcdcdcdcd in 
OSG-shader.exe: 0xC0000005: Access violation."

This error is a general error on Windows that means something bad happened. Generally the "something bad" is a null pointer being dereferenced, or something like that, but the only way to know for sure is to build the project in debug and run it. Then the Visual Studio debugger will stop exactly where the error happens and you'll be able to pinpoint the cause.

In your case, it seems to me that two things may cause the error you're getting:

1. osgDB::readShaderFile() for geometryShader1 returned NULL, i.e. the shader file you specified did not exist / could not be read. So when you call geometryShader1->getGlShaderInfoLog(0, log); you're dereferencing a null pointer.

2. osg::Shader::getGlShaderInfoLog() requires that the context ID you pass (0 in your case) be current, or that the shader have been compiled for that context prior to the call, and that isn't the case. Again that might cause a null pointer dereference.

For 2, note that in OSG, unless you run specifically in single threaded mode, you generally don't have a graphics context current in the main application thread. All OpenGL work is done in other threads (GraphicsThread). And shaders are generally compiled only when needed, i.e. when rendering a frame. So if the shader was read correctly, eliminating problem 1, then you probably need to wait for a frame to be rendered before getting the shader info log. You could set a post-frame callback on your camera, or something like that.

In any case, building OSG and your app in debug and running it will tell you what's happening better than I could ever hope to.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to