osg Camera createOrthoCamera matrix_type width matrix_type height osg

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
osg::Camera* createOrthoCamera(matrix_type width, matrix_type height) {
osg::Camera* camera = new osg::Camera();
camera->getOrCreateStateSet()->setMode(
GL_LIGHTING,
osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF
);
camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0, width, 0.0f, height));
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->setRenderOrder(osg::Camera::POST_RENDER);
return camera;
}