So, comes the hard part of my asignment. I'm now tasked with taking the wonderful viewer that I've written using OSG and making it play nice with CAVElib. Well, CAVElib does not like to play nice. It must own the OpenGL context and controll everything except the drawing of the objects. Well, the only way I could see to do this was use a GraphicsWindowEmbeded. Now, if I just run CAVElib in the background, so to speak, I can see the example .iv file perfectly. However, there is a constant barage of warnings that an OpenGL error has been detected starting with Warning: detected OpenGL error 'invalid operation' at Before Renderer::compile, once for each pipe, and then a constant stream of Warning: detected OpenGL error 'invalid operation' at after RenderBin::draw(..). If I let CAVElib determine my view frustrum and look at matrix I get a screen of garbage because both frustrum and view matrixes are identity matrixes which I attribute to the OpenGL issues.
the simple code I'm running to show a .iv file is as follows Code: osg::Node* node = NULL; osg::PositionAttitudeTransform* pat = NULL; std::vector<osgViewer::Viewer*> viewVec; OpenThreads::Mutex m; osg::GraphicsContext* gc = NULL; void init() { osgViewer::Viewer* viewer = NULL; { OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m); viewer = new osgViewer::Viewer(); viewer->setReleaseContextAtEndOfFrameHint(false); osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = viewer->setUpViewerAsEmbeddedInWindow(100, 100, 500, 500); viewer->getCamera()->setGraphicsContext(gw); viewer->setSceneData(pat); viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded); viewer->setCameraManipulator(new osgGA::TrackballManipulator); viewer->setThreadSafeRefUnref(true); viewer->realize(); viewVec.push_back(viewer); } CAVEDisplayBarrier(); } void display() { //GLenum errorNo; //glPushAttrib(GL_ALL_ATTRIB_BITS); //glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); //glShadeModel(GL_SMOOTH); //glMatrixMode(GL_TEXTURE); //glPushMatrix(); //glLoadIdentity(); //glMatrixMode(GL_PROJECTION); //glPushMatrix(); //glLoadIdentity(); //glMatrixMode(GL_MODELVIEW); //glPushMatrix(); //glLoadIdentity(); int num = CAVEPipeNumber(); osgViewer::Viewer* viewer = viewVec[num]; viewer->frame(); //glMatrixMode(GL_TEXTURE); //glPopMatrix(); //glMatrixMode(GL_PROJECTION); //glPopMatrix(); //glMatrixMode(GL_MODELVIEW); //glPopMatrix(); //glPopAttrib(); //glPopClientAttrib(); //errorNo = glGetError(); CAVEDisplayBarrier(); } void frame() { if(CAVEMasterDisplay()) { pat->setAttitude(pat->getAttitude() * osg::Quat(3.14 / 180.0, osg::Y_AXIS)); } pat->setPosition(osg::Vec3(-100, -100, -100)); int num = CAVEPipeNumber(); osgViewer::Viewer* viewer = viewVec[num]; osg::Camera* cam = viewer->getCamera(); int height = 0; int width = 0; int x = 0; int y = 0; CAVEGetViewport(&x, &y, &width, &height); cam->setViewport(x, y, width, height); float viewMatrixGL[16] = {0}; float projMatrixGL[16] = {0}; CAVENavTransform(); glGetFloatv( GL_MODELVIEW_MATRIX , (float*)viewMatrixGL ); glGetFloatv( GL_PROJECTION_MATRIX, (float*)projMatrixGL ); osg::Matrix viewMatrix(viewMatrixGL); osg::Matrix projMatrix(projMatrixGL); // set theproj cam->setProjectionMatrix(projMatrix); // set the view cam->setViewMatrix(viewMatrix); CAVEDisplayBarrier(); } int main(int argv, char** argc) { node = osgDB::readNodeFile("test.iv"); pat = new osg::PositionAttitudeTransform(); pat->addChild(node); CAVEConfigure(NULL, NULL, NULL); CAVEInitApplication(init, 0); CAVEDisplay(display, 0); CAVEFrameFunction(frame, 0); CAVEInit(); while(1) { OpenThreads::Thread::microSleep(1000); } } I can't find a solution to my problem and I've scoured the forums, net, contacted Mechdyne who owns CAVElib, prayed, and even contemplated sacrificing a virgin but the alter is in for cleaning. So, any help, insite, or the like would be greatly appreciated. soulsabr[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43802#43802 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org