glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
{
final Vec3 camPos = resolveCamPosition();
MatrixStack camMatrix = new MatrixStack();
camMatrix.setMatrix( calcLookAtMatrix( camPos, camTarget, new Vec3( 0.0f, 1.0f, 0.0f ) ) );
glUseProgram( uniformColor.theProgram );
glUniformMatrix4( uniformColor.worldToCameraMatrixUnif, false,
camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
glUseProgram( objectColor.theProgram );
glUniformMatrix4( objectColor.worldToCameraMatrixUnif, false,
camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
glUseProgram( uniformColorTint.theProgram );
glUniformMatrix4( uniformColorTint.worldToCameraMatrixUnif, false,
camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
glUseProgram( 0 );
MatrixStack modelMatrix = new MatrixStack();
// Render the ground plane.
{
modelMatrix.push();
modelMatrix.scale( 100.0f, 1.0f, 100.0f );
glUseProgram( uniformColor.theProgram );
glUniformMatrix4( uniformColor.modelToWorldMatrixUnif, false,
modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
glUniform4f( uniformColor.baseColorUnif, 0.302f, 0.416f, 0.0589f, 1.0f );
planeMesh.render();
glUseProgram( 0 );
modelMatrix.pop();
}
// Draw the trees.
drawForest( modelMatrix );
// Draw the building.
{
modelMatrix.push();
modelMatrix.translate( 20.0f, 0.0f, -10.0f );
drawParthenon( modelMatrix );
modelMatrix.pop();
}
if ( drawLookatPoint ) {
glDisable( GL_DEPTH_TEST );
modelMatrix.push();
Vec3 cameraAimVec = Vec3.sub( camTarget, camPos );
modelMatrix.translate( 0.0f, 0.0f, -Glm.length( cameraAimVec ) );
modelMatrix.scale( 1.0f, 1.0f, 1.0f );
Mat4 identity = new Mat4( 1.0f );