码迷,mamicode.com
首页 > Windows程序 > 详细

VC3DGraphicsWindowQt

时间:2019-07-27 23:45:23      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:phi   div   graphic   getc   rap   lag   nim   use   ilb   

 

VC3DGraphicsWindowQt::VC3DGraphicsWindowQt(QWidget* parent, Qt::WindowFlags f)
{
    osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
    osg::setNotifyLevel(osg::NotifySeverity::FATAL);

    _traits = new osg::GraphicsContext::Traits();
    _traits->windowDecoration = false;
    _traits->x = 0;
    _traits->y = 0;
    _traits->width = 100;
    _traits->height = 100;
    _traits->doubleBuffer = true;
    if (ds)
    {
        _traits->alpha = ds->getMinimumNumAlphaBits();
        _traits->stencil = ds->getMinimumNumStencilBits();
        _traits->sampleBuffers = ds->getMultiSamples();
        _traits->samples = ds->getNumMultiSamples();
    }
    if (parent)
    {
        _traits->width = parent->width();
        _traits->height = parent->height();
    }

    // create widget if it does not exist
    if (!m_opengl_widget)
    {
        // WindowFlags
        Qt::WindowFlags flags = f | Qt::Widget;
        // create widget
        m_opengl_widget = new VC3DQtOSGWidget(parent, flags);
    }

    m_opengl_widget->setMouseTracking(true);
    m_opengl_widget->setFocusPolicy(Qt::WheelFocus);
    m_opengl_widget->setGraphicsWindow(this);
    useCursor(_traits->useCursor);

    // initialize State
    setState(new osg::State);
    getState()->setGraphicsContext(this);

    // initialize contextID
    if (_traits.valid() && _traits->sharedContext.valid())
    {
        getState()->setContextID(_traits->sharedContext->getState()->getContextID());
        incrementContextIDUsageCount(getState()->getContextID());
    }
    else
    {
        getState()->setContextID(osg::GraphicsContext::createNewContextID());
    }

    // make sure the event queue has the correct window rectangle size and input range
#if (OPENSCENEGRAPH_MAJOR_VERSION == 3) && (OPENSCENEGRAPH_MINOR_VERSION == 2)
    getEventQueue()->syncWindowRectangleWithGraphcisContext();
#else
    getEventQueue()->syncWindowRectangleWithGraphicsContext();
#endif
}

 

VC3DGraphicsWindowQt

标签:phi   div   graphic   getc   rap   lag   nim   use   ilb   

原文地址:https://www.cnblogs.com/herd/p/11257278.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!