From 689fdad0acfd17aa2676bd5bcf34ebba29c383a5 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 3 Mar 2013 20:08:04 -0600 Subject: [PATCH] move FAR_FAR_AWAY (gl clipping limit) to rendersettings --- src/GLView.cc | 9 +++++---- src/GLView.h | 27 +++++++++++++-------------- src/rendersettings.cc | 1 + src/rendersettings.h | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/GLView.cc b/src/GLView.cc index aff35838..9f51cd08 100644 --- a/src/GLView.cc +++ b/src/GLView.cc @@ -17,6 +17,7 @@ GLView::GLView() showcrosshairs = false; renderer = NULL; cam = Camera(); + far_far_away = RenderSettings->inst()->far_gl_clip_limit; #ifdef ENABLE_OPENCSG is_opencsg_capable = false; has_shaders = false; @@ -48,7 +49,7 @@ void GLView::setupGimbalCamPerspective() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum(-w_h_ratio, +w_h_ratio, -(1/w_h_ratio), +(1/w_h_ratio), +10.0, +FAR_FAR_AWAY); + glFrustum(-w_h_ratio, +w_h_ratio, -(1/w_h_ratio), +(1/w_h_ratio), +10.0, +far_far_away); gluLookAt(0.0, -cam.viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); } @@ -61,7 +62,7 @@ void GLView::setupGimbalCamOrtho(double distance, bool offset) double l = distance/10; glOrtho(-w_h_ratio*l, +w_h_ratio*l, -(1/w_h_ratio)*l, +(1/w_h_ratio)*l, - -FAR_FAR_AWAY, +FAR_FAR_AWAY); + -far_far_away, +far_far_away); gluLookAt(0.0, -cam.viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); } @@ -81,7 +82,7 @@ void GLView::setupVectorCamOrtho(bool offset) double l = (cam.center - cam.eye).norm() / 10; glOrtho(-w_h_ratio*l, +w_h_ratio*l, -(1/w_h_ratio)*l, +(1/w_h_ratio)*l, - -FAR_FAR_AWAY, +FAR_FAR_AWAY); + -far_far_away, +far_far_away); } void GLView::setCamera( Camera &cam ) @@ -249,7 +250,7 @@ void GLView::enable_opencsg_shaders() void GLView::initializeGL() { glEnable(GL_DEPTH_TEST); - glDepthRange(-FAR_FAR_AWAY, +FAR_FAR_AWAY); + glDepthRange(-far_far_away, +far_far_away); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/GLView.h b/src/GLView.h index e06296bc..b3d4f3c1 100644 --- a/src/GLView.h +++ b/src/GLView.h @@ -28,8 +28,6 @@ Some actions (showCrossHairs) only work properly on Gimbal Camera. #include "renderer.h" #include "Camera.h" -#define FAR_FAR_AWAY 100000.0 - class GLView { public: @@ -58,25 +56,26 @@ public: virtual bool save(const char *filename) = 0; virtual std::string getRendererInfo() const = 0; + size_t far_far_away; size_t width; size_t height; - double w_h_ratio; - bool orthomode; - bool showaxes; - bool showfaces; - bool showedges; - bool showcrosshairs; + double w_h_ratio; + bool orthomode; + bool showaxes; + bool showfaces; + bool showedges; + bool showcrosshairs; Camera cam; #ifdef ENABLE_OPENCSG - GLint shaderinfo[11]; - bool is_opencsg_capable; - bool has_shaders; - void enable_opencsg_shaders(); + GLint shaderinfo[11]; + bool is_opencsg_capable; + bool has_shaders; + void enable_opencsg_shaders(); virtual void display_opencsg_warning() = 0; - bool opencsg_support; - int opencsg_id; + bool opencsg_support; + int opencsg_id; #endif }; diff --git a/src/rendersettings.cc b/src/rendersettings.cc index 07773243..e9c2f63e 100644 --- a/src/rendersettings.cc +++ b/src/rendersettings.cc @@ -13,6 +13,7 @@ RenderSettings *RenderSettings::inst(bool erase) RenderSettings::RenderSettings() { openCSGTermLimit = 2000; + far_gl_clip_limit = 100000.0; img_width = 512; img_height = 512; this->colors[BACKGROUND_COLOR] = Color4f(0xff, 0xff, 0xe5); diff --git a/src/rendersettings.h b/src/rendersettings.h index cb33981b..3d514950 100644 --- a/src/rendersettings.h +++ b/src/rendersettings.h @@ -25,7 +25,7 @@ public: void setColors(const std::map &colors); Color4f color(RenderColor idx); - unsigned int openCSGTermLimit, img_width, img_height; + unsigned int openCSGTermLimit, img_width, img_height, far_gl_clip_limit; private: RenderSettings();