OSG: Group * Group = new OSG: group;
OSG: node * node = osgdb: readnodefile ("d :\\ cow. OSG ");
OSG: Camera * camera = new OSG: camera;
Camera-> setviewport (0, 0,256,256 );
OSG: Image * IMG = new OSG: image;
IMG-> allocateimage (256,256, 1, gl_rgba, gl_float );
OSG: texture2d * texture2d = new OSG: texture2d;
Texture2d-> settexturesize (256,256 );
Texture2d-> setinternalformat (gl_rgba );
// Camera-> attach (Camera: color_buffer, texture2d, 0, 0 );
Camera-> attach (Camera: color_buffer, IMG, 0, 0 );
Texture2d-> setimage (0, IMG );
Const OSG: boundingsphere & BS = node-> getbound (); // OSG: Group = new OSG: Group
Float znear = 1.0f * BS. radius ();
Float zfar = 3.0f * BS. radius ();
Float proj_top = 0.25f * znear;
Float proj_right = 0.5f * znear;
Znear * = 0.9f;
Zfar * = 1.1f;
// Set up projection.
Camera-> setprojectionmatrixasfrustum (-proj_right, proj_right,-proj_top, proj_top, znear, zfar );
// Set view // set up projection
Camera-> setreferenceframe (OSG: Transform: absolute_rf );
Camera-> setviewmatrixaslookat (BS. center ()-OSG: vec3 (0.0f, 2.0f, 0.0f) * BS. radius (), BS. center (), OSG: vec3 (0.0f, 0.0f, 1.0f ));
Camera-> setrenderorder (OSG: Camera: pre_render );
Camera-> setrendertargetimplementation (Camera: frame_buffer_object );
Camera-> addchild (node );
Group-> addchild (CAMERA );
OSG: geometry * geometry = new OSG: geometry;
OSG: vec3array * vertex = new OSG: vec3array;
OSG: vec2array * coord = new OSG: vec2array;
Vertex-> push_back (OSG: vec3 (0.0, 0.0, 0.0 ));
Vertex-> push_back (OSG: vec3 (10.0, 0.0, 0.0 ));
Vertex-> push_back (OSG: vec3 (10.0, 10.0, 0.0 ));
Vertex-> push_back (OSG: vec3 (0.0, 10.0, 0.0 ));
Coord-> push_back (OSG: vec2 (0.0, 0.0 ));
Coord-> push_back (OSG: vec2 (1.0, 0.0 ));
Coord-> push_back (OSG: vec2 (1.0, 1.0 ));
Coord-> push_back (OSG: vec2 (0.0, 1.0 ));
Geometry-> settexcoordarray (0, coord );
Geometry-> setvertexarray (vertex );
Geometry-> addprimitiveset (New OSG: drawarrays (OSG: drawarrays: quads, 0, vertex-> size ()));
OSG: geode * geode = new OSG: geode;
Geode-> adddrawable (geometry );
OSG: stateset * statsset = new OSG: stateset;
Statsset-> settextureattributeandmodes (0, texture2d, OSG: stateattribute: On );
Geometry-> setstateset (statsset );
Group-> addchild (geode );
Osgviewer: viewer;
Viewer. setscenedata (group );
Return viewer. Run ();