Hi,

I use OSG 3.0.1 on a Windows 7 Professional x64 SP1 platform with Visual Studio 
2010 Premium SP1. I compiled the OSG binaries from source. (The following 
problem could be reproduced at least with Windows 7 Ultimate x86 SP1, Visual 
Studio 2010 Premium SP1).

My goal is to use the osgFX node kit to write a customized Effect. Therefore, I 
looked into the predefined osgFX::Cartoon Effect, copied it into my project, 
renamed it into MyCartoon and tried to adapt the code to my needs. In order to 
debug a program crash, I reduced the original osgFX::Cartoon Effect code to the 
following core:

namespace
{
    // register a prototype for this effect
    Registry::Proxy proxy(new MyCartoon);

    // default technique class
    class DefaultTechnique : public Technique {
    public:
        DefaultTechnique()
            : Technique() {}

        void getRequiredExtensions(std::vector<std::string>& extensions) const
        {
            extensions.push_back("GL_ARB_vertex_program");
        }

    protected:
        void define_passes()
        {
        }

    private:
    };
}

MyCartoon::MyCartoon()
:    Effect()
{
}

MyCartoon::MyCartoon(const MyCartoon& copy, const osg::CopyOp& copyop)
:    Effect(copy, copyop)
{
}

bool MyCartoon::define_techniques()
{
    addTechnique(new DefaultTechnique());
    return true;
}

When my application executes and the render process starts, the program crashes 
with a heap damage error, when it returns from 
osg::Technique::validate(osg::State&). Therein, a local String_list is used to 
hold and traverse the extension strings and it is attempted to be destroyed at 
the end of the function block. The last entries in my call stack are in the 
std::basic_string<> template class and refer to the destruction of the 
extension string "GL_ARB_vertex_program".

If I don't push entries in my getRequiredExtensions() method, the program 
continues without a crash. I also overwrote osg::Technique::validate() in my 
DefaultTechnique and used *exactly* the code from the base class and it worked 
fine. But if I call the base class method directly, it crashes again, when 
destroying the first extension string in the list. I can't figure out, why the 
strings are freed improperly and why there is such a different behaviour, when 
I overwrite osg::Technique::validate().

I searched the OSG examples, tutorials and the "OpenSceneGraph 3.0 Beginner's 
Guide" for sample code, where someone defines a new Effect "outside" the OSG 
library, without success. Maybe, I forgot some essential steps, when deriving 
my own Effect and Technique classes? I would appreciate, if anybody could give 
me a hint or pointer to understand and solve the described problem.

Thanks for your attention
Matthias Schütze, Germany
___________________________________________________________
Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://produkte.web.de/go/toolbar
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to