+ camera = new osg::Camera;
+ camera->setProjectionMatrix(osg::Matrix::ortho2D(-256.0, 256.0, -256.0,
+ 256.0));
+ camera->setViewport(0, 0, textureWH, textureWH);
+ camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
+ camera->setRenderOrder(osg::Camera::PRE_RENDER);
+ camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ camera->setClearColor(osg::Vec4(0.0f, 0.0f, 0.0f , 0.0f));
+ camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::FRAME_BUFFER);
+ osg::StateSet* stateSet = camera->getOrCreateStateSet();
+ stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
+ stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
+ stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
+ stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
+ stateSet->setAttributeAndModes(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK,
+ osg::PolygonMode::FILL),
+ osg::StateAttribute::ON);
+ stateSet->setAttributeAndModes(new osg::AlphaFunc(osg::AlphaFunc::GREATER,
+ 0.0f),
+ osg::StateAttribute::ON);
+ stateSet->setAttribute(new osg::ShadeModel(osg::ShadeModel::FLAT));
+ stateSet->setAttributeAndModes(new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
+ osg::BlendFunc::ONE_MINUS_SRC_ALPHA),
+ osg::StateAttribute::ON);
+ if (!texture.valid()) {
+ texture = new osg::Texture2D;
+ texture->setTextureSize(textureWH, textureWH);
+ texture->setInternalFormat(GL_RGBA);
+ texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
+ texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
+ }
+ camera->attach(osg::Camera::COLOR_BUFFER, texture.get());
+ globals->get_renderer()->addCamera(camera.get(), false);
+ rtAvailable = true;
+
+ // GLint colorBits = 0;