|
- int main()
- {
- /*osg::ref_ptr<osgViewer::CompositeViewer>viewer=new osgViewer::CompositeViewer();*/
- //
- osg::ref_ptr<osgViewer::Viewer>viewer1=new osgViewer::Viewer();
- osg::ref_ptr<osgViewer::Viewer>viewer2=new osgViewer::Viewer();
- int xoffset=50;
- int yoffset=200;
- osg::ref_ptr<osg::Node>viewer1Node=osgDB::readNodeFile("D:/lianxi_houhuaiyu/database/database/moon_500.ive");/*cow.osg*//**/
- {
- osg::ref_ptr<osg::GraphicsContext::Traits>traits=new osg::GraphicsContext::Traits();
- traits->x=xoffset+0;
- traits->y=yoffset+0;
- traits->width=600;
- traits->height=480;
- traits->windowDecoration=true;
- traits->doubleBuffer=true;
- traits->sharedContext=0;
- osg::ref_ptr<osg::GraphicsContext>gc=osg::GraphicsContext::createGraphicsContext(traits.get());
- osg::ref_ptr<osg::Camera>camera1=viewer1->getCamera();
- camera1->setGraphicsContext(gc.get());
- camera1->setViewport(new osg::Viewport(0,0,traits->width,traits->height));
- GLenum buffer=traits->doubleBuffer?GL_BACK:GL_FRONT;
- camera1->setDrawBuffer(buffer);
- camera1->setReadBuffer(buffer);
- viewer1->setSceneData(viewer1Node.get());
- }
- viewer1->realize();
- viewer1->run();
- return 0;
- }
复制代码
运行时会出现内存错误
如果去掉图形环境模型能够显示出来,但有一个警告:
detected opengl error ‘out of memory ’ at after renderer::complie
如果不去掉图形环境换一个模型也能能正常显示,没有警告。
请高手指点一下是 可能是哪里处理问题 是模型还是图形环境或者是其他的,有什么解决的办法? |
|