Fixed osgsimplegl3 example's set up of the main camera.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14524 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-11-24 14:09:14 +00:00
parent fce7137525
commit 2a8d894168

View File

@ -20,7 +20,7 @@
void configureShaders( osg::StateSet* stateSet ) void configureShaders( osg::StateSet* stateSet )
{ {
const std::string vertexSource = const std::string vertexSource =
"#version 140 \n" "#version 140 \n"
" \n" " \n"
"uniform mat4 osg_ModelViewProjectionMatrix; \n" "uniform mat4 osg_ModelViewProjectionMatrix; \n"
@ -41,7 +41,7 @@ void configureShaders( osg::StateSet* stateSet )
"} \n"; "} \n";
osg::Shader* vShader = new osg::Shader( osg::Shader::VERTEX, vertexSource ); osg::Shader* vShader = new osg::Shader( osg::Shader::VERTEX, vertexSource );
const std::string fragmentSource = const std::string fragmentSource =
"#version 140 \n" "#version 140 \n"
" \n" " \n"
"in vec4 color; \n" "in vec4 color; \n"
@ -90,16 +90,16 @@ int main( int argc, char** argv )
return( 1 ); return( 1 );
} }
osgViewer::Viewer viewer;
// Create a Camera that uses the above OpenGL context. // Create a Camera that uses the above OpenGL context.
osg::Camera* cam = new osg::Camera; osg::Camera* cam = viewer.getCamera();
cam->setGraphicsContext( gc.get() ); cam->setGraphicsContext( gc.get() );
// Must set perspective projection for fovy and aspect. // Must set perspective projection for fovy and aspect.
cam->setProjectionMatrix( osg::Matrix::perspective( 30., (double)width/(double)height, 1., 100. ) ); cam->setProjectionMatrix( osg::Matrix::perspective( 30., (double)width/(double)height, 1., 100. ) );
// Unlike OpenGL, OSG viewport does *not* default to window dimensions. // Unlike OpenGL, OSG viewport does *not* default to window dimensions.
cam->setViewport( new osg::Viewport( 0, 0, width, height ) ); cam->setViewport( new osg::Viewport( 0, 0, width, height ) );
osgViewer::Viewer viewer;
viewer.setCamera( cam );
viewer.setSceneData( root ); viewer.setSceneData( root );
// for non GL3/GL4 and non GLES2 platforms we need enable the osg_ uniforms that the shaders will use, // for non GL3/GL4 and non GLES2 platforms we need enable the osg_ uniforms that the shaders will use,