aboutsummaryrefslogtreecommitdiff
path: root/samples/OpenGL/frustum/frustum.c
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-05-12 03:21:47 +0200
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-05-12 03:21:47 +0200
commit9cbea9d27344e8bcfc0b6eae193fb1e4fd97c1c5 (patch)
treed3a24f296f6a69ecd81b1bd11b47c3d0e0ed9ed3 /samples/OpenGL/frustum/frustum.c
parent023bc0f9a7d34735aefac0d95608a210441147fc (diff)
downloadcodesamples-9cbea9d27344e8bcfc0b6eae193fb1e4fd97c1c5.tar.gz
codesamples-9cbea9d27344e8bcfc0b6eae193fb1e4fd97c1c5.tar.bz2
frustum view aspect now influences observer frustum drawing
Diffstat (limited to 'samples/OpenGL/frustum/frustum.c')
-rw-r--r--samples/OpenGL/frustum/frustum.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/samples/OpenGL/frustum/frustum.c b/samples/OpenGL/frustum/frustum.c
index f74b6a5..493d2eb 100644
--- a/samples/OpenGL/frustum/frustum.c
+++ b/samples/OpenGL/frustum/frustum.c
@@ -125,6 +125,9 @@ void draw_arrow(
};
normalize_v(d);
+ double r[3] = { mv[0], mv[4], mv[8] };
+ int rev = scalarproduct_v(d, r) < 0.;
+
double n[3] = { mv[2], mv[6], mv[10] };
{
double const s = scalarproduct_v(d,n);
@@ -173,9 +176,9 @@ void draw_arrow(
w += glutStrokeWidth(GLUT_STROKE_ROMAN, *c);
w *= annot_size / 100.;
- float tx = (ax + bx - w*d[0])/2.;
- float ty = (ay + by - w*d[1])/2.;
- float tz = (az + bz - w*d[2])/2.;
+ float tx = (ax + bx)/2.;
+ float ty = (ay + by)/2.;
+ float tz = (az + bz)/2.;
GLdouble r[16] = {
d[0], d[1], d[2], 0,
@@ -186,7 +189,9 @@ void draw_arrow(
glPushMatrix();
glTranslatef(tx, ty, tz);
glMultMatrixd(r);
- glTranslatef(0, annot_size*0.1, 0);
+ if(rev)
+ glScalef(-1, -1, 1);
+ glTranslatef(-w/2., annot_size*0.1, 0);
draw_strokestring(GLUT_STROKE_ROMAN, annot_size, annotation);
glPopMatrix();
}