zoukankan      html  css  js  c++  java
  • [osg]osg背景图设置

    转自:https://blog.csdn.net/qq_30754211/article/details/61190698

    #include <osg/Geometry>  
    #include <osg/Geode>  
    #include <osg/Depth>  
    #include <osg/Texture2D>  
    #include <osgDB/ReadFile>  
    #include <osgViewer/Viewer>  
      
    int main( int argc, char** argv )  
    {  
        osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;  
        osg::ref_ptr<osg::Image> image = osgDB::readImageFile( "D:/background1.png" );  
        texture->setImage( image.get() );  
          
        osg::ref_ptr<osg::Drawable> quad = osg::createTexturedQuadGeometry(osg::Vec3(), osg::Vec3(1.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 1.0f, 0.0f) );  
        quad->getOrCreateStateSet()->setTextureAttributeAndModes( 0,texture.get());  
          
        osg::ref_ptr<osg::Geode> geode = new osg::Geode;  
        geode->addDrawable( quad.get() );  
          
        osg::ref_ptr<osg::Camera> camera = new osg::Camera;  
        camera->setClearMask( 0 );  
        camera->setCullingActive( false );  
        camera->setAllowEventFocus( false );  
        camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );  
        camera->setRenderOrder( osg::Camera::POST_RENDER );  
        camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );  
        camera->addChild( geode.get() );  
          
        osg::StateSet* ss = camera->getOrCreateStateSet();  
        ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF );  
        ss->setAttributeAndModes( new osg::Depth(osg::Depth::LEQUAL, 1.0, 1.0) );  
          
        osg::ref_ptr<osg::Group> root = new osg::Group;  
        root->addChild( camera.get() );  
        root->addChild( osgDB::readNodeFile("cessna.osg") );  
          
        osgViewer::Viewer viewer;  
        viewer.setSceneData( root.get() );  
        return viewer.run();  
  • 相关阅读:
    python操作Excel读写--使用xlrd
    python 使用pymssql连接sql server数据库
    python pdb调试
    sqlser生成guid与复制造数
    sqlser游标与for循环
    bat写循环
    Jenkins配置多任务
    git命令行与Jenkins
    Jenkins执行python脚本
    Windows环境Jenkins配置免密登录Linux
  • 原文地址:https://www.cnblogs.com/lyggqm/p/9505448.html
Copyright © 2011-2022 走看看