Hi, I want to get osgProducer in wxWidgets. I am trying to create a seperate 
thread for osgProducer::viewer. I can see the osg window and a seperate 
wxWidget window, but can not get osg window into widget window. I based this 
code on example found on openscenegraph windowing tools kits. Using boost as 
threading library

-Gian Lorenzetto's simple example integrating OSG with wxWidgets. Built against 
OSG 1.1 and wxWidgets 2.6.3. Supports full event handling and open dialog for 
file load.

Any help will be greatly appreciated.

...
osgCanvas_ = new wxOsgCanvas( itemPanel3, ID_OSGCANVAS, wxDefaultPosition, 
wxSize(100, 100), wxSTATIC_BORDER );
...

osgCanvas_->init_Producer(dialog.GetPath())

....

----------------------------------------------------------
wxOsgCanvas::wxOsgCanvas(wxWindow *parent, wxWindowID id,
                       const wxPoint& pos, const wxSize& size, long style, 
const wxString& name) : 
    wxGLCanvas(parent, (wxGLCanvas*) NULL, id, pos, size, 
style|wxFULL_REPAINT_ON_RESIZE , name ),
    viewWidth_(0),
    viewHeight_(0),
    startTick_(0),
    frameNum_(0),
    mViewer(NULL)/*osgProducer::viewer object*/
{
}

------------------------------------------------------------
bool wxOsgCanvas::init_Producer(const wxString &filename)
{
    mFileName=filename;
    mThread= new     
boost::thread(boost::bind(&wxOsgCanvas::run_Producer,this));

    return true;
}
-------------------------------------------------------------
bool wxOsgCanvas::run_Producer()
{
    SetCurrent();


    mViewer= new osgProducer::Viewer();

    mViewer->setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);

    model_=osgDB::readNodeFile(mFileName.c_str());

    if (!model_)    
    {return false;}

    mViewer->setSceneData(model_.get());

    mViewer->setClearColor(osg::Vec4(0.1,0.1,0.1,0));

    mViewer->realize();

    while( !mViewer->done() )
    
    {
    SetCurrent();
      
    mViewer->sync();
    mViewer->update(); 
    mViewer->frame();

    }

     mViewer->sync();
     return 0;
}


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to