int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); // set up the usage document, in case we need to print out how to use this program. arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " demonstrates the use of multiple render targets (MRT) with frame buffer objects (FBOs). A render to texture (RTT) camera is used to render to four textures using a single shader. The four textures are then combined to texture the viewed geometry."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] ..."); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information."); arguments.getApplicationUsage()->addCommandLineOption("--width","Set the width of the render to texture."); arguments.getApplicationUsage()->addCommandLineOption("--height","Set the height of the render to texture."); arguments.getApplicationUsage()->addCommandLineOption("--image","Render one of the targets to an image, then apply a post draw callback to modify it and use this image to update the final texture. Print some texture values when using HDR."); arguments.getApplicationUsage()->addCommandLineOption("--hdr","Use high dynamic range (HDR). Create floating point textures to render to."); // construct the viewer. osgViewer::Viewer viewer(arguments); // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { arguments.getApplicationUsage()->write(std::cout); return 1; } unsigned tex_width = 512; unsigned tex_height = 512; while (arguments.read("--width", tex_width)) {} while (arguments.read("--height", tex_height)) {} bool useHDR = false; while (arguments.read("--hdr")) { useHDR = true; } bool useImage = false; while (arguments.read("--image")) { useImage = true; } bool useMultiSample = false; while (arguments.read("--ms")) { useMultiSample = true; } osg::Group* subGraph = createRTTQuad(tex_width, tex_height, useHDR); osg::Group* rootNode = new osg::Group(); rootNode->addChild(createScene(subGraph, tex_width, tex_height, useHDR, useImage, useMultiSample)); // add model to the viewer. viewer.setSceneData( rootNode ); return viewer.run(); }
int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); // // // set up the usage document, in case we need to print out how to use this program. // arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " demonstrates the use of multiple render targets (MRT) with frame buffer objects (FBOs). A render to texture (RTT) camera is used to render to four textures using a single shader. The four textures are then combined to texture the viewed geometry."); // arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] ..."); // arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information."); // arguments.getApplicationUsage()->addCommandLineOption("--width","Set the width of the render to texture."); // arguments.getApplicationUsage()->addCommandLineOption("--height","Set the height of the render to texture."); // arguments.getApplicationUsage()->addCommandLineOption("--image","Render one of the targets to an image, then apply a post draw callback to modify it and use this image to update the final texture. Print some texture values when using HDR."); // arguments.getApplicationUsage()->addCommandLineOption("--hdr","Use high dynamic range (HDR). Create floating point textures to render to."); // construct the viewer. osgViewer::Viewer viewer(arguments); osg::GraphicsContext::Traits *pTraits = new osg::GraphicsContext::Traits; pTraits->x = 100; pTraits->y = 100; pTraits->width = 1024; pTraits->height = 768; pTraits->windowName = "Hive Application"; pTraits->windowDecoration = true; pTraits->doubleBuffer = true; osg::GraphicsContext* pGraphicsContext = osg::GraphicsContext::createGraphicsContext(pTraits); osg::Camera *pCamera = new osg::Camera; pCamera->setGraphicsContext(pGraphicsContext); pCamera->setViewport(new osg::Viewport(0, 0, pTraits->width, pTraits->height)); pCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); pCamera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); pCamera->setProjectionMatrixAsPerspective(45, (float)pTraits->width/pTraits->height, 0.1, 100); viewer.setCamera(pCamera); // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { arguments.getApplicationUsage()->write(std::cout); return 1; } unsigned tex_width = 512; unsigned tex_height = 512; // while (arguments.read("--width", tex_width)) {} // while (arguments.read("--height", tex_height)) {} bool useHDR = false; // while (arguments.read("--hdr")) { useHDR = true; } bool useImage = false; // while (arguments.read("--image")) { useImage = true; } bool useMultiSample = false; // while (arguments.read("--ms")) { useMultiSample = true; } osg::Group* subGraph = createRTTQuad(tex_width, tex_height, useHDR); osg::Group* rootNode = new osg::Group(); rootNode->addChild(createScene(subGraph, tex_width, tex_height, useHDR, useImage, useMultiSample)); // add model to the viewer. viewer.setSceneData( rootNode ); return viewer.run(); }