]> git.tdb.fi Git - libs/gl.git/commitdiff
Adjust depth clip according to camera distance
authorMikko Rasa <tdb@tdb.fi>
Sun, 30 Jan 2011 09:44:36 +0000 (09:44 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 30 Jan 2011 09:44:36 +0000 (09:44 +0000)
viewer.cpp

index 43036209b50b68c171060c7d19afc588f475cbc7..d89b34bd3472a210d4167e9e75c477154e3f1259 100644 (file)
@@ -107,8 +107,7 @@ Viewer::Viewer(int argc, char **argv):
        lighting.attach(0, light);
 
        camera.set_up_direction(GL::Vector3(0, 0, 1));
-       camera.set_position(GL::Vector3(distance, 0, 0));
-       camera.look_at(GL::Vector3(0, 0, 0));
+       update_camera();
 }
 
 Viewer::~Viewer()
@@ -227,6 +226,7 @@ void Viewer::update_camera()
        float cp = cos(pitch);
        float sp = sin(pitch);
        camera.set_position(GL::Vector3(-cy*cp*distance, -sy*cp*distance, -sp*distance));
+       camera.set_depth_clip(distance*0.02, distance*50);
        camera.look_at(GL::Vector3(0, 0, 0));
 }
 
@@ -236,5 +236,5 @@ void Viewer::update_light()
        float sy = sin(light_yaw);
        float cp = cos(light_pitch);
        float sp = sin(light_pitch);
-       light.set_position(GL::Vector4(-cy*cp, -sy*cp, -sp));
+       light.set_position(GL::Vector4(-cy*cp, -sy*cp, -sp, 0));
 }