16,472
社区成员
发帖
与我相关
我的任务
分享
m_hWndParent = hWnd;
first_load=true;
Title_text = new osgText::Text;
Title_AirPort_Name=new osgText::Text;
Title_energy_type=new osgText::Text;
//osg::DisplaySettings::instance()->setNumMultiSamples(8);
m_osgRoot = new osg::Group(); //场景模型 根 的初始化
m_osgViewer = new osgViewer::Viewer(); //视口 初始化
osgViewer::Viewer& viewer1 = *m_osgViewer;
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)
<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return 1;
}
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(hWnd);
RECT rt;
GetWindowRect(hWnd,&rt);
int wnd_w = rt.right-rt.left;
int wnd_h = rt.bottom-rt.top;
int maxlen= wnd_w<wnd_h ? wnd_w : wnd_h;
traits->x = 0;
traits->y = 0;
traits->sharedContext = 0;
traits->setInheritedWindowPixelFormat = true;
traits->inheritedWindowData = windata;
traits->red = traits->green = traits->blue = 8;
traits->depth = 24;
//traits->alpha = 8;
//traits->stencil = 8;
traits->doubleBuffer = true;
traits->mipMapGeneration = true;
traits->sampleBuffers = 0;
traits->samples = msp;
if (bShowMax)
{
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->windowDecoration = false;
}
else
{
traits->width = width/2;
traits->height = height/2;
traits->windowDecoration = true;
}
m_gc = osg::GraphicsContext::createGraphicsContext(traits.get());//这块出的问题
if (m_gc.valid())
{
osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<<std::endl;
m_gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f));
m_gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else
{
osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<<std::endl;
return false;
}