From: Mikko Rasa Date: Wed, 20 Dec 2017 10:54:39 +0000 (+0200) Subject: Rename various get/set_aspect functions to aspect_ratio X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7cf5ebbc9d91d09d0664598d3fb88606c3307deb;p=libs%2Fgl.git Rename various get/set_aspect functions to aspect_ratio That's the correct term. The old versions have been left in and marked as deprecated for now. --- diff --git a/source/camera.cpp b/source/camera.cpp index e15d1cfe..6ae162ae 100644 --- a/source/camera.cpp +++ b/source/camera.cpp @@ -36,7 +36,7 @@ void Camera::set_orthographic(float w, float h) update_projection_matrix(); } -void Camera::set_aspect(float a) +void Camera::set_aspect_ratio(float a) { aspect = a; update_projection_matrix(); diff --git a/source/camera.h b/source/camera.h index d96ada81..1c13e67d 100644 --- a/source/camera.h +++ b/source/camera.h @@ -29,7 +29,7 @@ public: void set_field_of_view(const Geometry::Angle &); void set_orthographic(float, float); - void set_aspect(float); + void set_aspect_ratio(float); void set_depth_clip(float, float); void set_frustum_axis(float, float); void set_frustum_rotation(const Geometry::Angle &); @@ -37,11 +37,15 @@ public: bool is_orthographic() const { return fov==Geometry::Angle::zero(); } float get_orthographic_width() const { return height*aspect; } float get_orthographic_height() const { return height; } - float get_aspect() const { return aspect; } + float get_aspect_ratio() const { return aspect; } float get_near_clip() const { return clip_near; } float get_far_clip() const { return clip_far; } const Geometry::Angle &get_frustum_rotation() const { return rotate; } + // Deprecated, use set/get_aspect_ratio instead + void set_aspect(float a) { set_aspect_ratio(a); } + float get_aspect() const { return get_aspect_ratio(); } + void set_position(const Vector3 &); void set_look_direction(const Vector3 &); void look_at(const Vector3 &); diff --git a/source/environmentmap.cpp b/source/environmentmap.cpp index 94ae5150..b55dd2c7 100644 --- a/source/environmentmap.cpp +++ b/source/environmentmap.cpp @@ -25,7 +25,7 @@ EnvironmentMap::EnvironmentMap(unsigned s, Renderable &r, Renderable &e): // XXX Make the depth range configurable camera.set_field_of_view(Geometry::Angle::right()); - camera.set_aspect(1); + camera.set_aspect_ratio(1); camera.set_depth_clip(0.1, 100); } diff --git a/source/scene.cpp b/source/scene.cpp index 9d301fbf..fbde0cd3 100644 --- a/source/scene.cpp +++ b/source/scene.cpp @@ -40,7 +40,7 @@ bool Scene::setup_frustum(const Renderer &renderer) const frustum_edges[0] = Vector4(0, 1/s, y/s, 0); frustum_edges[1] = Vector4(0, -1/s, y/s, 0); - float x = y*camera->get_aspect(); + float x = y*camera->get_aspect_ratio(); s = sqrt(x*x+1); frustum_edges[2] = Vector4(1/s, 0, x/s, 0); frustum_edges[3] = Vector4(-1/s, 0, x/s, 0); diff --git a/source/view.cpp b/source/view.cpp index f531905f..074967cf 100644 --- a/source/view.cpp +++ b/source/view.cpp @@ -16,7 +16,7 @@ void View::set_camera(Camera *c) { camera = c; if(camera) - camera->set_aspect(get_aspect()); + camera->set_aspect_ratio(get_aspect_ratio()); } void View::set_content(Renderable *r) @@ -27,7 +27,7 @@ void View::set_content(Renderable *r) void View::synchronize_camera_aspect(Camera &c) { synced_cameras.push_back(&c); - c.set_aspect(get_aspect()); + c.set_aspect_ratio(get_aspect_ratio()); } void View::render() diff --git a/source/view.h b/source/view.h index 08629fa0..6aca12f1 100644 --- a/source/view.h +++ b/source/view.h @@ -26,12 +26,13 @@ protected: public: virtual unsigned get_width() const { return target.get_width(); } virtual unsigned get_height() const { return target.get_height(); } - float get_aspect() const { return static_cast(get_width())/get_height(); } + float get_aspect_ratio() const { return static_cast(get_width())/get_height(); } void set_camera(Camera *); void set_content(Renderable *); // Deprecated + float get_aspect() const { return get_aspect_ratio(); } void synchronize_camera_aspect(Camera &); virtual void render(); diff --git a/source/windowview.cpp b/source/windowview.cpp index 61027acc..6a0eebda 100644 --- a/source/windowview.cpp +++ b/source/windowview.cpp @@ -25,9 +25,9 @@ void WindowView::window_resized(unsigned w, unsigned h) target.viewport(0, 0, w, h); float aspect = static_cast(w)/h; if(camera) - camera->set_aspect(aspect); + camera->set_aspect_ratio(aspect); for(list::iterator i=synced_cameras.begin(); i!=synced_cameras.end(); ++i) - (*i)->set_aspect(aspect); + (*i)->set_aspect_ratio(aspect); } } // namespace GL