-1

I'm trying to learn how OpenSceneGraph work, so I've follow some tutorial. So far, everything worked, but now, I got problem with text.

I got no building error, but when i'm launching the program, i got the following messages :

(1) "Unhandle exception at 0x73F12252 (msvcr100.dll) in myprograme : 0xC0000005: Access violated when reading 0x00AEE000"

(2) "Unhandle exception at 0x1000AF10 (osg80-osgText.dll) in myprograme : 0xC0000005: Access violated when reading 0x00194000"

I've already check the dll, tried to put them in the launch folder, but it changes nothing.

Here's the piece of code where it happens :

osg::Vec3 pyramidTwoPosition(15, 0, 0);
pyramidTwoXForm->setPosition(pyramidTwoPosition);

testText->setCharacterSize(25); 
testText->setFont("../arial.ttf"); //Error (1)
testText->setText("Test text"); //Error (2)
testText->setAxisAlignment(osgText::Text::SCREEN);
testText->setPosition(osg::Vec3(0, 0, 0));
testText->setColor(osg::Vec4(1, 0, 0, 1.0f));

osg::Geode* textGeode = new osg::Geode();
textGeode->addDrawable(testText);
pyramidTwoXForm->addChild(textGeode);
vallentin
  • 23,478
  • 6
  • 59
  • 81

1 Answers1

1

A couple of tips:

  • Try to put a bit more of your program along with your code snippet; the best you can do is have a whole running program which has the error you try to solve. This way, we'll be able to execute and test it, and help you more easily.
  • Are you trying this in debug? If so, no stack trace?
  • What version of Visual Studio are you using, and what version of Visual Studio was used to make the DLLs?

From the top of my head:

  • You seem to use an application compiled with VS2010 with OSG DLLs compiled for/with VS2005. Your DLLs and app should be compiled with the same compiler.
  • You might get a memory leak with your line osg::Geode* textGeode = new osg::Geode();. Use osg::ref_ptr<osg::Geode> textGeode = new osg::Geode(); instead. Most OSG objects are osg::Referenced (OSG smart pointers), so failure to add an object just created to a smart pointer might cause you memory leaks.
Vaillancourt
  • 1,380
  • 1
  • 11
  • 42