Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2007-01-17 06:57:01 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2007-01-17 06:57:01 +0300
commit5f798002c9ca6b9532862ea14fdad27a4c136a12 (patch)
treed10af1e80b96d2102c5614d3f3fe1050d78e29a1 /source/blender/src/glutil.c
parenta3c9ae8a8819d08f47234f0c065fbdb5fd385c59 (diff)
Added a new function+struct to glutil that takes care of reading in the OpenGL data needed for gluProject/gluUnProject. This allows retopo and sculptmode to share some of the same code, and is probably useful elsewhere as well.
Diffstat (limited to 'source/blender/src/glutil.c')
-rw-r--r--source/blender/src/glutil.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/src/glutil.c b/source/blender/src/glutil.c
index 9a4a67c7f35..eef5e41dee2 100644
--- a/source/blender/src/glutil.c
+++ b/source/blender/src/glutil.c
@@ -596,6 +596,29 @@ void bglEnd(void)
}
+/* Uses current OpenGL state to get view matrices for gluProject/gluUnProject */
+void bgl_get_mats(bglMats *mats)
+{
+ const double badvalue= 1.0e-6;
+
+ glGetDoublev(GL_MODELVIEW_MATRIX, mats->modelview);
+ glGetDoublev(GL_PROJECTION_MATRIX, mats->projection);
+ glGetIntegerv(GL_VIEWPORT, (GLint *)mats->viewport);
+
+ /* Very strange code here - it seems that certain bad values in the
+ modelview matrix can cause gluUnProject to give bad results. */
+ if(mats->modelview[0] < badvalue &&
+ mats->modelview[0] > -badvalue)
+ mats->modelview[0]= 0;
+ if(mats->modelview[5] < badvalue &&
+ mats->modelview[5] > -badvalue)
+ mats->modelview[5]= 0;
+
+ /* Set up viewport so that gluUnProject will give correct values */
+ mats->viewport[0] = 0;
+ mats->viewport[1] = 0;
+}
+
/* *************** glPolygonOffset hack ************* */
// both temporal, so here for now (ton)