summaryrefslogtreecommitdiff
path: root/src/glu
diff options
context:
space:
mode:
Diffstat (limited to 'src/glu')
-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);
}