Beispiel #1
0
void MonitorWidget::onEnabledChanged(bool enabled)
{
    output->setEnabled(enabled);

    // If we're enabling a disabled output for the first time
    if (enabled && !output->currentMode())
    {
        // order here matters
        onResolutionChanged(ui.resolutionCombo->currentIndex());
        onOrientationChanged(ui.orientationCombo->currentIndex());
        onBehaviorChanged(ui.behaviorCombo->currentIndex());
    }
}
//------------------------------------------------------------------------------
void HudTextureElement::init()
{
    Texture * tex_object = s_texturemanager.getResource(texture_name_);
    if (!tex_object) return;
    
    osg::ref_ptr<osg::Texture2D> tex = tex_object->getOsgTexture();
    osg::ref_ptr<osg::Image> image = tex->getImage();

    aspect_ratio_ = (float)image->s() / image->t();

    tex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
    tex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

    tex->setBorderColor(osg::Vec4(0,0,0,0));
    tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
    tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
    
    getOrCreateStateSet()->setTextureAttributeAndModes(0,tex.get(),osg::StateAttribute::ON);

    setUseDisplayList(false);
    setUseVertexBufferObjects(true);

    addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));

    Color color  = s_params.get<Color>   ("hud." + section_ + ".color");
    
    osg::Vec2Array* texcoord = new osg::Vec2Array(4);
    setTexCoordArray(0,texcoord);
        
    osg::Vec4Array * osg_color = new osg::Vec4Array(1);
    (*osg_color)[0].set(color.r_, color.g_, color.b_, color.a_);
    setColorArray(osg_color);
    setColorBinding(osg::Geometry::BIND_OVERALL);

    (*texcoord)[0].set(0,0);
    (*texcoord)[1].set(1,0);
    (*texcoord)[2].set(1,1);
    (*texcoord)[3].set(0,1);


    s_scene_manager.addObserver(ObserverCallbackFun0(this, &HudTextureElement::onResolutionChanged),
                                SOE_RESOLUTION_CHANGED,
                                &fp_group_);    
    onResolutionChanged();
}