X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Fcamera.cpp;h=8f681a74bd19d843130e8bdccea6272e5808d506;hp=3bba0eaf38e00385e68a077474095a980a10f340;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266 diff --git a/source/render/camera.cpp b/source/render/camera.cpp index 3bba0eaf..8f681a74 100644 --- a/source/render/camera.cpp +++ b/source/render/camera.cpp @@ -2,20 +2,12 @@ #include "camera.h" #include "matrix.h" +using namespace std; + namespace Msp { namespace GL { -Camera::Camera(): - fov(Geometry::Angle::from_turns(0.125)), - height(0), - aspect(4.0/3.0), - clip_near(0.1), - clip_far(10), - frustum_x(0), - frustum_y(0), - position(0, 0, 0), - look_dir(0, 0, -1), - up_dir(0, 1, 0) +Camera::Camera() { update_projection_matrix(); update_object_matrix(); @@ -129,6 +121,9 @@ void Camera::update_projection_matrix() else proj_matrix = Matrix::ortho(left, right, bottom, top, clip_near, clip_far); proj_matrix = Matrix::rotation(rotate, Vector3(0, 0, 1))*proj_matrix; + + shdata.uniform("clip_eye_matrix", proj_matrix); + shdata.uniform("eye_clip_matrix", invert(proj_matrix)); } void Camera::update_object_matrix() @@ -141,6 +136,18 @@ void Camera::update_object_matrix() columns[3] = compose(position, 1.0f); matrix = Matrix::from_columns(columns); view_matrix = invert(matrix); + + shdata.uniform("world_eye_matrix", matrix); + shdata.uniform("eye_world_matrix", view_matrix); +} + +void Camera::set_debug_name(const string &name) +{ +#ifdef DEBUG + shdata.set_debug_name(name+" [UBO]"); +#else + (void)name; +#endif }