I've created a very simple piece of code that replicates this problem independent of my application. The file openmarker.osg was attached to the first email in this thread.

osg::ref_ptr<osgDB::ReaderWriter::Options> osgfileoptions = new osgDB::ReaderWriter::Options(); osgfileoptions->setObjectCacheHint (osgDB::ReaderWriter::Options::CACHE_NONE);

osg::ref_ptr<osg::Node> om;
osg::StateSet *ss;
osg::Program *ssprog;

long i = 0;
while(i < 3)
{
        om = osgDB::readNodeFile("openmarker.osg", osgfileoptions.get());
        
        if(om != NULL)
        {
                ss = om->getStateSet();
                if(ss != NULL)
                {
ssprog = dynamic_cast<osg::Program*>(ss->getAttribute (osg::StateAttribute::PROGRAM));
                        if(ssprog != NULL)
                        {
cout << "!Program name: " << ssprog->getName() << ", num shaders: " << ssprog->getNumShaders() << "!\n";
                        } else cout << "!Could not find program!\n";
                } else cout << "!Could not find stateset!\n";
        } else cout << "!Could not load model!\n";

        i++;
}

----------------------------------------

!Program name: openmarker program, num shaders: 2!
!Program name: openmarker program, num shaders: 0!
!Program name: openmarker program, num shaders: 0!

It appears that the problem is happening when the files are loaded and has nothing to do with my code.

Alan



On 22 Nov 2006, at 15:47, Alan Purvis wrote:

Hey,

I've stripped out all the fancy auxiliary shader stuff, disabled my NodeVisitors etc.. OSG's logs now read:

Compiling VERTEX source:
void main(void)
{
        gl_Position = ftransform();
}


Compiling FRAGMENT source:
void main(void)
{
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

Linking osg::Program "openmarker program" id=25 contextID=0
        Attrib "gl_Vertex" loc=0

So the program is still linking correctly, no-longer references outside functions and is no longer victim to visitation. I've written similarly simplified shaders for the two board tiles. Same problem manifests as before.

Attached is a picture of the new scene with simplified shaders still displaying the same problem. Also attached is a picture of the scenegraph after being completely unloaded and taken apart and then rebuilt with the same code that constructed it the first time. Everything renders in fixed function (no red particle systems, tiles render as a nearly black mess).

Am I correct in thinking that every time I load the particle system .osg file a new "openmarker program" osg::Program is allocated and kept inside the loaded subgraph's StateSet? If this is the case why am I only seeing the linking message only once in OSG's debug output?

Linking osg::Program "openmarker program" id=25 contextID=0

Surely if there's no caching going on there will be 25 different programs with 25 different IDs?

Elsewhere in the code where I'm creating multiple programs I'm getting multiple IDs:
Linking osg::Program "bloomprogram" id=9 contextID=0
Linking osg::Program "bloomprogram" id=10 contextID=0
Linking osg::Program "bloomprogram" id=11 contextID=0

By the way, it's coincidental that the id in the log for the "openmarker program" is 25 (5x5 like the number of particle systems), ironic luck :)
Linking osg::Program "background kanji program" id=12 contextID=0
Linking osg::Program "hsva2rgba" id=15 contextID=0
Linking osg::Program "white tile program" id=19 contextID=0
Linking osg::Program "black tile program" id=22 contextID=0


Thanks for your time,
Alan

<nofancystuff.jpg>
<teardownandrebuild.jpg>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to