|
我运行osg的QT例子,跟踪发现
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
中的gc为0,不知大家是否也遇到此问题?我用的是osg2.2,下面是示例中的源文件
void QOSGWidget::createContext() {
31
32 osg:isplaySettings* ds = osg::DisplaySettings::instance();
33
34 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
35
36 traits->readDISPLAY();
37 if (traits->displayNum<0) traits->displayNum = 0;
38
39 traits->windowName = "osgViewerQt";
40 traits->screenNum = 0;
41 traits->x = x();
42 traits->y = y();
43 traits->width = width();
44 traits->height = height();
45 traits->alpha = ds->getMinimumNumAlphaBits();
46 traits->stencil = ds->getMinimumNumStencilBits();
47 traits->windowDecoration = false;
48 traits->doubleBuffer = true;
49 traits->sharedContext = 0;
50 traits->sampleBuffers = ds->getMultiSamples();
51 traits->samples = ds->getNumMultiSamples();
52
53 traits->inheritedWindowData = new WindowData(winId());
54
55 if (ds->getStereo ()) {
56
57 switch(ds->getStereoMode()) {
58
59 case(osg::DisplaySettings:UAD_BUFFER):
60 traits->quadBufferStereo = true; break;
61 case(osg::DisplaySettings::VERTICAL_INTERLACE):
62 case(osg::DisplaySettings::CHECKERBOARD):
63 case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;
64 default: break;
65 }
66 }
67
68 osg::ref_ptr<osg::GraphicsContext> gc =
69 osg::GraphicsContext::createGraphicsContext(traits.get());
70 _gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
71 } |
|