Show
Ignore:
Timestamp:
07/25/05 15:05:57 (9 years ago)
Author:
robert
Message:

Added support for TextureCubeMap? into osgUtil::RenderToTextureStage?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgprerendercubemap/osgprerendercubemap.cpp

    r4395 r4414  
    188188 
    189189 
    190 osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::RefNodePath reflectorNodePath, unsigned int unit, const osg::Vec4& clearColor) 
     190osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::RefNodePath reflectorNodePath, unsigned int unit, const osg::Vec4& clearColor, unsigned tex_width, unsigned tex_height, osg::CameraNode::RenderTargetImplementation renderImplementation) 
    191191{ 
    192192 
    193193    osg::Group* group = new osg::Group; 
    194      
    195     unsigned int tex_width = 512; 
    196     unsigned int tex_height = 512; 
    197194     
    198195    osg::TextureCubeMap* texture = new osg::TextureCubeMap; 
     
    221218 
    222219        // tell the camera to use OpenGL frame buffer object where supported. 
    223         camera->setRenderTargetImplmentation(osg::CameraNode::FRAME_BUFFER_OBJECT); 
     220        camera->setRenderTargetImplmentation(renderImplementation); 
    224221 
    225222        // attach the texture and use it as the color buffer. 
     
    277274    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()); 
    278275    arguments.getApplicationUsage()->addCommandLineOption("-h or --help", "Display this information"); 
     276    arguments.getApplicationUsage()->addCommandLineOption("--fbo","Use Frame Buffer Object for render to texture, where supported."); 
     277    arguments.getApplicationUsage()->addCommandLineOption("--fb","Use FrameBuffer for render to texture."); 
     278    arguments.getApplicationUsage()->addCommandLineOption("--pbuffer","Use Pixel Buffer for render to texture, where supported."); 
     279    arguments.getApplicationUsage()->addCommandLineOption("--window","Use a seperate Window for render to texture."); 
     280    arguments.getApplicationUsage()->addCommandLineOption("--width","Set the width of the render to texture"); 
     281    arguments.getApplicationUsage()->addCommandLineOption("--height","Set the height of the render to texture"); 
    279282 
    280283    // construct the viewer. 
     
    293296        return 1; 
    294297    } 
     298     
     299    unsigned tex_width = 512; 
     300    unsigned tex_height = 512; 
     301    while (arguments.read("--width", tex_width)) {} 
     302    while (arguments.read("--height", tex_height)) {} 
     303 
     304    osg::CameraNode::RenderTargetImplementation renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT; 
     305     
     306    while (arguments.read("--fbo")) { renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT; } 
     307    while (arguments.read("--pbuffer")) { renderImplementation = osg::CameraNode::PIXEL_BUFFER; } 
     308    while (arguments.read("--fb")) { renderImplementation = osg::CameraNode::FRAME_BUFFER; } 
     309    while (arguments.read("--window")) { renderImplementation = osg::CameraNode::SEPERATE_WINDOW; } 
     310     
    295311 
    296312    // any option left unread are converted into errors to write out later. 
     
    310326    if (!reflectedSubgraph.valid()) return 1; 
    311327 
    312     ref_ptr<Group> reflectedScene = createShadowedScene(reflectedSubgraph.get(),createReflector(),0, viewer.getClearColor()); 
     328    ref_ptr<Group> reflectedScene = createShadowedScene(reflectedSubgraph.get(), createReflector(), 0, viewer.getClearColor(), 
     329                                                        tex_width, tex_height, renderImplementation); 
    313330 
    314331    scene->addChild(reflectedScene.get());