Hello,

As I've been playing with shaders in OSG, I've tried to get the shader info log 
so I can export it directly to a file (largely because it doesn't want to show 
up in the console when I have a GLSL compilation error).

In any case, I've pieced together several snippets of code across a few posts 
from the forum, but to no avail.

The code:


Code:
osgViewer::ViewerBase::Contexts* c = new osgViewer::ViewerBase::Contexts();

viewer.getContexts(*c);

unsigned int contextID;
osg::ref_ptr<osg::State> stat;

for (osgViewer::ViewerBase::Contexts::iterator itr=c->begin(); itr!=c->end(); 
++itr)
 stat = (*itr)->getState();

contextID = stat->getContextID();

osg::ref_ptr <osg::Geode> pass1 (dynamic_cast<osg::Geode *> (FindNode(root, 
"root_geodeShaderGeometry1")->getFirst()));
osg::ref_ptr <osg::Program> sh1 (dynamic_cast<osg::Program *> 
(pass1->getStateSet()->getAttribute(osg::StateAttribute::PROGRAM, 0)));

std::string log;

osg::Shader* shader = sh1->getShader(0);

shader->compileShader(*(stat.get()));
bool logFound = shader->getGlShaderInfoLog(contextID, log);

if (logFound)
 std::cout << log;




I can retrieve my shader programs fine (I have 3), but i get an unhandled 
exception (access violation) at 0xcdcdcdcd when I try to call compileShader or 
getGlShaderInfoLog.  That tells me the problem isn't with my parameters, but 
with accessing the shader object itself.

I'm sure it's something simple that I've overlooked, and I imagine it's been 
covered in another post somewhere, but since my knowledge of OSG overall is 
pretty much limited to what I've tried to implement, the solution eludes me.

Any thoughts?

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=34726#34726





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to