I tried changing my implementation to follow the osgviewermfc example very
closely with the rendering being done exactly as in the example. It didn't help
with the problem however.
I'm currently trying to take some screenshots at varying times to try to find
out if the model is being rendered and later blanked out.
I was using osgprerender as inspiration for taking screenshots, and I noticed
that if I changed the viewer.run() to while(!viewer.done()){viewer.frame()} in
the example, I would get the exact same problem as in my own application with
the model not being rendered, but the background being rendered.
regards, and thank in advance.
Jesper D. Thomsen
<mailto:[EMAIL PROTECTED]>
________________________________
From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Ümit Uzun [EMAIL
PROTECTED]
Sent: Thursday, September 25, 2008 11:00 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Problems getting a model to render using OSG in an MFC
application
Hi Jesper,
Anyone couldn't find your problem by this way, but problem looks like simple. I
advice you to look at cOSG class and Render threads activation way in
osgviewerMFC example. I think there is render thread activation problem. You
can change clear color but can't render scene. So I think problem is threading
activation.
I hope have answered your question.
Best Regards.
Umit Uzun
2008/9/25 Jesper D. Thomsen <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
Hi all, first posting here, so be gentle.
I'm trying to integrate OSG in an existing MFC application in place of a
temporary custom OpenGL renderer.
I have looked at the osgviewermfc example and based my code on that. So far I
have got a viewer up and running with a single master camera. I have tested
that the camera is being redrawn by changing the clear-color to a random value
every frame. When I assign scenedata to the viewer there is nothing being drawn
however.
I am using the following code in my CView::Oncreate:
------------------------
// Create a trackball manipulator
trackball =
new osgGA::TrackballManipulator();
// Create a Manipulator Switcher
keyswitchManipulator =
new osgGA::KeySwitchMatrixManipulator;
// Add our trackball manipulator to the switcher
keyswitchManipulator->addMatrixManipulator(
'1', "Trackball", trackball);
// Init the switcher to the first manipulator (in this case the only
manipulator)
keyswitchManipulator->selectMatrixManipulator(0);
// Zero based index Value
// Init the main Root Node/Group
mRoot =
new osg::Group;
// Load the Model from the model name
mModel = osgDB::readNodeFile(
"c:/cow.osg");
//// Optimize the model
//osgUtil::Optimizer optimizer;
//optimizer.optimize(mModel);
//optimizer.reset();
// Add the model to the scene
mRoot->addChild(mModel);
// Local Variable to hold window size data
RECT rect;
// Create the viewer for this window
mViewer =
new osgViewer::Viewer();
// Add a Stats Handler to the viewer
mViewer->addEventHandler(
new osgViewer::StatsHandler);
// Get the current window size
::GetWindowRect(m_hWnd, &rect);
// Init the GraphicsContext Traits
traits =
new osg::GraphicsContext::Traits;
// Init the Windata Variable that holds the handle for the Window to display
OSG in.
windata =
new osgViewer::GraphicsWindowWin32::WindowData(m_hWnd);
// Setup the traits parameters
traits->x = 0;
traits->y = 0;
traits->width = rect.right - rect.left;
traits->height = rect.bottom - rect.top;
traits->windowDecoration =
false;
traits->doubleBuffer =
true;
traits->sharedContext = 0;
traits->setInheritedWindowPixelFormat =
true;
traits->inheritedWindowData = windata;
// Create the Graphics Context
gc = osg::GraphicsContext::createGraphicsContext(traits);
// Init a new Camera (Master for this View)
osg_camera =
new osg::Camera;
// Assign Graphics Context to the Camera
osg_camera->setGraphicsContext(gc);
// Set the viewport for the Camera
osg_camera->setViewport(
new osg::Viewport(traits->x, traits->y, traits->width, traits->height));
// Add the Camera to the Viewer
mViewer->addSlave(osg_camera);
// Add the Camera Manipulator to the Viewer
mViewer->setCameraManipulator(keyswitchManipulator);
// Set the Scene Data
mViewer->setSceneData(mRoot);
// Realize the Viewer
mViewer->realize();
-----------------
And in my views OnDraw I use the following:
--------------------
float r = (float) rand()/RAND_MAX;
float g = (float) rand()/RAND_MAX;
float b = (float) rand()/RAND_MAX;
float a = (float) rand()/RAND_MAX;
osg_camera->setClearColor( osg::Vec4(r,g,b,a) );
mViewer->frame();
--------------------
As far as I can tell the osgviewermfc uses pretty much the same code.
Any and all help and hint as to what I'm doing wrong would be much appreciated.
Regards, and thanks in advance.
Jesper D. Thomsen
_______________________________________________
osg-users mailing list
[email protected]<mailto:[email protected]>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org