summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-01-30 18:08:51 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-01-30 18:08:51 +0000
commiteeb861df0b1843ffd765b969ed80394f663a7dc9 (patch)
tree2667531b20a6d668e58fc808ef77139dfac58325 /src
parentd68b699291097b49cac0d5c0f3ec4cb6ac14b972 (diff)
make gluPerspective() call glMultMatrix() instead of glFrustum() to get correct error semantics
Diffstat (limited to 'src')
-rw-r--r--src/glu/mesa/glu.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/glu/mesa/glu.c b/src/glu/mesa/glu.c
index c3772e786c..d7d8b93bdb 100644
--- a/src/glu/mesa/glu.c
+++ b/src/glu/mesa/glu.c
@@ -1,9 +1,9 @@
-/* $Id: glu.c,v 1.22 2000/11/13 15:33:17 brianp Exp $ */
+/* $Id: glu.c,v 1.23 2001/01/30 18:08:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
- * Copyright (C) 1995-2000 Brian Paul
+ * Version: 3.5
+ * Copyright (C) 1995-2001 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -137,6 +137,32 @@ gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top)
+static void
+frustum(GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval)
+{
+ GLdouble x, y, a, b, c, d;
+ GLdouble m[16];
+
+ x = (2.0 * nearval) / (right - left);
+ y = (2.0 * nearval) / (top - bottom);
+ a = (right + left) / (right - left);
+ b = (top + bottom) / (top - bottom);
+ c = -(farval + nearval) / ( farval - nearval);
+ d = -(2.0 * farval * nearval) / (farval - nearval);
+
+#define M(row,col) m[col*4+row]
+ M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
+ M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
+ M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
+ M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
+#undef M
+
+ glMultMatrixd(m);
+}
+
+
void GLAPIENTRY
gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
@@ -144,11 +170,11 @@ gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
ymax = zNear * tan(fovy * M_PI / 360.0);
ymin = -ymax;
-
xmin = ymin * aspect;
xmax = ymax * aspect;
- glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
+ /* don't call glFrustum() because of error semantics (covglu) */
+ frustum(xmin, xmax, ymin, ymax, zNear, zFar);
}