summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/eval.c549
-rw-r--r--src/mesa/main/light.c21
2 files changed, 198 insertions, 372 deletions
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 0c0d950751..98add17c19 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -1,8 +1,8 @@
-/* $Id: eval.c,v 1.7 1999/11/11 01:22:26 brianp Exp $ */
+/* $Id: eval.c,v 1.6.2.1 2000/07/17 12:49:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.1
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -41,11 +41,16 @@
#ifdef PC_HEADER
#include "all.h"
#else
-#include "glheader.h"
+#ifndef XFree86Server
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
#include "context.h"
#include "eval.h"
#include "macros.h"
-#include "mem.h"
#include "mmath.h"
#include "types.h"
#include "vbcull.h"
@@ -523,9 +528,9 @@ de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
/*
* Return the number of components per control point for any type of
* evaluator. Return 0 if bad target.
- * See table 5.1 in the OpenGL 1.2 spec.
*/
-GLuint _mesa_evaluator_components( GLenum target )
+
+static GLint components( GLenum target )
{
switch (target) {
case GL_MAP1_VERTEX_3: return 3;
@@ -563,11 +568,12 @@ GLuint _mesa_evaluator_components( GLenum target )
* Return: pointer to buffer of contiguous control points or NULL if out
* of memory.
*/
-GLfloat *gl_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
+GLfloat *gl_copy_map_points1f( GLenum target,
+ GLint ustride, GLint uorder,
const GLfloat *points )
{
GLfloat *buffer, *p;
- GLint i, k, size = _mesa_evaluator_components(target);
+ GLint i, k, size = components(target);
if (!points || size==0) {
return NULL;
@@ -588,11 +594,12 @@ GLfloat *gl_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
/*
* Same as above but convert doubles to floats.
*/
-GLfloat *gl_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
- const GLdouble *points )
+GLfloat *gl_copy_map_points1d( GLenum target,
+ GLint ustride, GLint uorder,
+ const GLdouble *points )
{
GLfloat *buffer, *p;
- GLint i, k, size = _mesa_evaluator_components(target);
+ GLint i, k, size = components(target);
if (!points || size==0) {
return NULL;
@@ -621,15 +628,15 @@ GLfloat *gl_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
* of memory.
*/
GLfloat *gl_copy_map_points2f( GLenum target,
- GLint ustride, GLint uorder,
- GLint vstride, GLint vorder,
- const GLfloat *points )
+ GLint ustride, GLint uorder,
+ GLint vstride, GLint vorder,
+ const GLfloat *points )
{
GLfloat *buffer, *p;
GLint i, j, k, size, dsize, hsize;
GLint uinc;
- size = _mesa_evaluator_components(target);
+ size = components(target);
if (!points || size==0) {
return NULL;
@@ -672,7 +679,7 @@ GLfloat *gl_copy_map_points2d(GLenum target,
GLint i, j, k, size, hsize, dsize;
GLint uinc;
- size = _mesa_evaluator_components(target);
+ size = components(target);
if (!points || size==0) {
return NULL;
@@ -702,7 +709,6 @@ GLfloat *gl_copy_map_points2d(GLenum target,
}
-#if 00
/*
* This function is called by the display list deallocator function to
* specify that a given set of control points are no longer needed.
@@ -798,7 +804,6 @@ void gl_free_control_points( GLcontext* ctx, GLenum target, GLfloat *data )
}
}
-#endif
@@ -808,130 +813,154 @@ void gl_free_control_points( GLcontext* ctx, GLenum target, GLfloat *data )
/*
- * This does the work of glMap1[fd].
+ * Note that the array of control points must be 'unpacked' at this time.
+ * Input: retain - if TRUE, this control point data is also in a display
+ * list and can't be freed until the list is freed.
*/
-static void
-map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
- GLint uorder, const GLvoid *points, GLenum type )
+void gl_Map1f( GLcontext* ctx, GLenum target,
+ GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat *points, GLboolean retain )
{
- GET_CURRENT_CONTEXT(ctx);
GLint k;
- GLfloat *pnts;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap1");
+ if (!points) {
+ gl_error( ctx, GL_OUT_OF_MEMORY, "glMap1f" );
+ return;
+ }
- assert(type == GL_FLOAT || type == GL_DOUBLE);
+ /* may be a new stride after copying control points */
+ stride = components( target );
- if (u1 == u2) {
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap1");
+
+ if (u1==u2) {
gl_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" );
return;
}
- if (uorder < 1 || uorder > MAX_EVAL_ORDER) {
+
+ if (order<1 || order>MAX_EVAL_ORDER) {
gl_error( ctx, GL_INVALID_VALUE, "glMap1(order)" );
return;
}
- if (!points) {
- gl_error( ctx, GL_INVALID_VALUE, "glMap1(points)" );
- return;
- }
- k = _mesa_evaluator_components( target );
- if (k == 0) {
+ k = components( target );
+ if (k==0) {
gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
}
- if (ustride < k) {
+ if (stride < k) {
gl_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" );
return;
}
- /* make copy of the control points */
- if (type == GL_FLOAT)
- pnts = gl_copy_map_points1f(target, ustride, uorder, (GLfloat*) points);
- else
- pnts = gl_copy_map_points1d(target, ustride, uorder, (GLdouble*) points);
-
switch (target) {
case GL_MAP1_VERTEX_3:
- ctx->EvalMap.Map1Vertex3.Order = uorder;
+ ctx->EvalMap.Map1Vertex3.Order = order;
ctx->EvalMap.Map1Vertex3.u1 = u1;
ctx->EvalMap.Map1Vertex3.u2 = u2;
ctx->EvalMap.Map1Vertex3.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Vertex3.Points)
+ if (ctx->EvalMap.Map1Vertex3.Points
+ && !ctx->EvalMap.Map1Vertex3.Retain) {
FREE( ctx->EvalMap.Map1Vertex3.Points );
- ctx->EvalMap.Map1Vertex3.Points = pnts;
+ }
+ ctx->EvalMap.Map1Vertex3.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Vertex3.Retain = retain;
break;
case GL_MAP1_VERTEX_4:
- ctx->EvalMap.Map1Vertex4.Order = uorder;
+ ctx->EvalMap.Map1Vertex4.Order = order;
ctx->EvalMap.Map1Vertex4.u1 = u1;
ctx->EvalMap.Map1Vertex4.u2 = u2;
ctx->EvalMap.Map1Vertex4.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Vertex4.Points)
+ if (ctx->EvalMap.Map1Vertex4.Points
+ && !ctx->EvalMap.Map1Vertex4.Retain) {
FREE( ctx->EvalMap.Map1Vertex4.Points );
- ctx->EvalMap.Map1Vertex4.Points = pnts;
+ }
+ ctx->EvalMap.Map1Vertex4.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Vertex4.Retain = retain;
break;
case GL_MAP1_INDEX:
- ctx->EvalMap.Map1Index.Order = uorder;
+ ctx->EvalMap.Map1Index.Order = order;
ctx->EvalMap.Map1Index.u1 = u1;
ctx->EvalMap.Map1Index.u2 = u2;
ctx->EvalMap.Map1Index.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Index.Points)
+ if (ctx->EvalMap.Map1Index.Points
+ && !ctx->EvalMap.Map1Index.Retain) {
FREE( ctx->EvalMap.Map1Index.Points );
- ctx->EvalMap.Map1Index.Points = pnts;
+ }
+ ctx->EvalMap.Map1Index.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Index.Retain = retain;
break;
case GL_MAP1_COLOR_4:
- ctx->EvalMap.Map1Color4.Order = uorder;
+ ctx->EvalMap.Map1Color4.Order = order;
ctx->EvalMap.Map1Color4.u1 = u1;
ctx->EvalMap.Map1Color4.u2 = u2;
ctx->EvalMap.Map1Color4.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Color4.Points)
+ if (ctx->EvalMap.Map1Color4.Points
+ && !ctx->EvalMap.Map1Color4.Retain) {
FREE( ctx->EvalMap.Map1Color4.Points );
- ctx->EvalMap.Map1Color4.Points = pnts;
+ }
+ ctx->EvalMap.Map1Color4.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Color4.Retain = retain;
break;
case GL_MAP1_NORMAL:
- ctx->EvalMap.Map1Normal.Order = uorder;
+ ctx->EvalMap.Map1Normal.Order = order;
ctx->EvalMap.Map1Normal.u1 = u1;
ctx->EvalMap.Map1Normal.u2 = u2;
ctx->EvalMap.Map1Normal.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Normal.Points)
+ if (ctx->EvalMap.Map1Normal.Points
+ && !ctx->EvalMap.Map1Normal.Retain) {
FREE( ctx->EvalMap.Map1Normal.Points );
- ctx->EvalMap.Map1Normal.Points = pnts;
+ }
+ ctx->EvalMap.Map1Normal.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Normal.Retain = retain;
break;
case GL_MAP1_TEXTURE_COORD_1:
- ctx->EvalMap.Map1Texture1.Order = uorder;
+ ctx->EvalMap.Map1Texture1.Order = order;
ctx->EvalMap.Map1Texture1.u1 = u1;
ctx->EvalMap.Map1Texture1.u2 = u2;
ctx->EvalMap.Map1Texture1.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Texture1.Points)
+ if (ctx->EvalMap.Map1Texture1.Points
+ && !ctx->EvalMap.Map1Texture1.Retain) {
FREE( ctx->EvalMap.Map1Texture1.Points );
- ctx->EvalMap.Map1Texture1.Points = pnts;
+ }
+ ctx->EvalMap.Map1Texture1.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Texture1.Retain = retain;
break;
case GL_MAP1_TEXTURE_COORD_2:
- ctx->EvalMap.Map1Texture2.Order = uorder;
+ ctx->EvalMap.Map1Texture2.Order = order;
ctx->EvalMap.Map1Texture2.u1 = u1;
ctx->EvalMap.Map1Texture2.u2 = u2;
ctx->EvalMap.Map1Texture2.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Texture2.Points)
+ if (ctx->EvalMap.Map1Texture2.Points
+ && !ctx->EvalMap.Map1Texture2.Retain) {
FREE( ctx->EvalMap.Map1Texture2.Points );
- ctx->EvalMap.Map1Texture2.Points = pnts;
+ }
+ ctx->EvalMap.Map1Texture2.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Texture2.Retain = retain;
break;
case GL_MAP1_TEXTURE_COORD_3:
- ctx->EvalMap.Map1Texture3.Order = uorder;
+ ctx->EvalMap.Map1Texture3.Order = order;
ctx->EvalMap.Map1Texture3.u1 = u1;
ctx->EvalMap.Map1Texture3.u2 = u2;
ctx->EvalMap.Map1Texture3.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Texture3.Points)
+ if (ctx->EvalMap.Map1Texture3.Points
+ && !ctx->EvalMap.Map1Texture3.Retain) {
FREE( ctx->EvalMap.Map1Texture3.Points );
- ctx->EvalMap.Map1Texture3.Points = pnts;
+ }
+ ctx->EvalMap.Map1Texture3.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Texture3.Retain = retain;
break;
case GL_MAP1_TEXTURE_COORD_4:
- ctx->EvalMap.Map1Texture4.Order = uorder;
+ ctx->EvalMap.Map1Texture4.Order = order;
ctx->EvalMap.Map1Texture4.u1 = u1;
ctx->EvalMap.Map1Texture4.u2 = u2;
ctx->EvalMap.Map1Texture4.du = 1.0 / (u2 - u1);
- if (ctx->EvalMap.Map1Texture4.Points)
+ if (ctx->EvalMap.Map1Texture4.Points
+ && !ctx->EvalMap.Map1Texture4.Retain) {
FREE( ctx->EvalMap.Map1Texture4.Points );
- ctx->EvalMap.Map1Texture4.Points = pnts;
+ }
+ ctx->EvalMap.Map1Texture4.Points = (GLfloat *) points;
+ ctx->EvalMap.Map1Texture4.Retain = retain;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
@@ -940,30 +969,18 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
-void
-_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
- GLint order, const GLfloat *points )
-{
- map1(target, u1, u2, stride, order, points, GL_FLOAT);
-}
-
-
-void
-_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
- GLint order, const GLdouble *points )
-{
- map1(target, u1, u2, stride, order, points, GL_DOUBLE);
-}
-
-static void
-map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
- GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
- const GLvoid *points, GLenum type )
+/*
+ * Note that the array of control points must be 'unpacked' at this time.
+ * Input: retain - if TRUE, this control point data is also in a display
+ * list and can't be freed until the list is freed.
+ */
+void gl_Map2f( GLcontext* ctx, GLenum target,
+ GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLfloat *points, GLboolean retain )
{
- GET_CURRENT_CONTEXT(ctx);
GLint k;
- GLfloat *pnts;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap2");
@@ -987,7 +1004,7 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
return;
}
- k = _mesa_evaluator_components( target );
+ k = components( target );
if (k==0) {
gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
}
@@ -1001,14 +1018,6 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
return;
}
- /* make copy of the control points */
- if (type == GL_FLOAT)
- pnts = gl_copy_map_points2f(target, ustride, uorder,
- vstride, vorder, (GLfloat*) points);
- else
- pnts = gl_copy_map_points2d(target, ustride, uorder,
- vstride, vorder, (GLdouble*) points);
-
switch (target) {
case GL_MAP2_VERTEX_3:
ctx->EvalMap.Map2Vertex3.Uorder = uorder;
@@ -1019,9 +1028,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Vertex3.v1 = v1;
ctx->EvalMap.Map2Vertex3.v2 = v2;
ctx->EvalMap.Map2Vertex3.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Vertex3.Points)
+ if (ctx->EvalMap.Map2Vertex3.Points
+ && !ctx->EvalMap.Map2Vertex3.Retain) {
FREE( ctx->EvalMap.Map2Vertex3.Points );
- ctx->EvalMap.Map2Vertex3.Points = pnts;
+ }
+ ctx->EvalMap.Map2Vertex3.Retain = retain;
+ ctx->EvalMap.Map2Vertex3.Points = (GLfloat *) points;
break;
case GL_MAP2_VERTEX_4:
ctx->EvalMap.Map2Vertex4.Uorder = uorder;
@@ -1032,9 +1044,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Vertex4.v1 = v1;
ctx->EvalMap.Map2Vertex4.v2 = v2;
ctx->EvalMap.Map2Vertex4.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Vertex4.Points)
+ if (ctx->EvalMap.Map2Vertex4.Points
+ && !ctx->EvalMap.Map2Vertex4.Retain) {
FREE( ctx->EvalMap.Map2Vertex4.Points );
- ctx->EvalMap.Map2Vertex4.Points = pnts;
+ }
+ ctx->EvalMap.Map2Vertex4.Points = (GLfloat *) points;
+ ctx->EvalMap.Map2Vertex4.Retain = retain;
break;
case GL_MAP2_INDEX:
ctx->EvalMap.Map2Index.Uorder = uorder;
@@ -1045,9 +1060,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Index.v1 = v1;
ctx->EvalMap.Map2Index.v2 = v2;
ctx->EvalMap.Map2Index.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Index.Points)
+ if (ctx->EvalMap.Map2Index.Points
+ && !ctx->EvalMap.Map2Index.Retain) {
FREE( ctx->EvalMap.Map2Index.Points );
- ctx->EvalMap.Map2Index.Points = pnts;
+ }
+ ctx->EvalMap.Map2Index.Retain = retain;
+ ctx->EvalMap.Map2Index.Points = (GLfloat *) points;
break;
case GL_MAP2_COLOR_4:
ctx->EvalMap.Map2Color4.Uorder = uorder;
@@ -1058,9 +1076,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Color4.v1 = v1;
ctx->EvalMap.Map2Color4.v2 = v2;
ctx->EvalMap.Map2Color4.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Color4.Points)
+ if (ctx->EvalMap.Map2Color4.Points
+ && !ctx->EvalMap.Map2Color4.Retain) {
FREE( ctx->EvalMap.Map2Color4.Points );
- ctx->EvalMap.Map2Color4.Points = pnts;
+ }
+ ctx->EvalMap.Map2Color4.Retain = retain;
+ ctx->EvalMap.Map2Color4.Points = (GLfloat *) points;
break;
case GL_MAP2_NORMAL:
ctx->EvalMap.Map2Normal.Uorder = uorder;
@@ -1071,9 +1092,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Normal.v1 = v1;
ctx->EvalMap.Map2Normal.v2 = v2;
ctx->EvalMap.Map2Normal.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Normal.Points)
+ if (ctx->EvalMap.Map2Normal.Points
+ && !ctx->EvalMap.Map2Normal.Retain) {
FREE( ctx->EvalMap.Map2Normal.Points );
- ctx->EvalMap.Map2Normal.Points = pnts;
+ }
+ ctx->EvalMap.Map2Normal.Retain = retain;
+ ctx->EvalMap.Map2Normal.Points = (GLfloat *) points;
break;
case GL_MAP2_TEXTURE_COORD_1:
ctx->EvalMap.Map2Texture1.Uorder = uorder;
@@ -1084,9 +1108,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Texture1.v1 = v1;
ctx->EvalMap.Map2Texture1.v2 = v2;
ctx->EvalMap.Map2Texture1.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Texture1.Points)
+ if (ctx->EvalMap.Map2Texture1.Points
+ && !ctx->EvalMap.Map2Texture1.Retain) {
FREE( ctx->EvalMap.Map2Texture1.Points );
- ctx->EvalMap.Map2Texture1.Points = pnts;
+ }
+ ctx->EvalMap.Map2Texture1.Retain = retain;
+ ctx->EvalMap.Map2Texture1.Points = (GLfloat *) points;
break;
case GL_MAP2_TEXTURE_COORD_2:
ctx->EvalMap.Map2Texture2.Uorder = uorder;
@@ -1097,9 +1124,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Texture2.v1 = v1;
ctx->EvalMap.Map2Texture2.v2 = v2;
ctx->EvalMap.Map2Texture2.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Texture2.Points)
+ if (ctx->EvalMap.Map2Texture2.Points
+ && !ctx->EvalMap.Map2Texture2.Retain) {
FREE( ctx->EvalMap.Map2Texture2.Points );
- ctx->EvalMap.Map2Texture2.Points = pnts;
+ }
+ ctx->EvalMap.Map2Texture2.Retain = retain;
+ ctx->EvalMap.Map2Texture2.Points = (GLfloat *) points;
break;
case GL_MAP2_TEXTURE_COORD_3:
ctx->EvalMap.Map2Texture3.Uorder = uorder;
@@ -1110,9 +1140,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Texture3.v1 = v1;
ctx->EvalMap.Map2Texture3.v2 = v2;
ctx->EvalMap.Map2Texture3.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Texture3.Points)
+ if (ctx->EvalMap.Map2Texture3.Points
+ && !ctx->EvalMap.Map2Texture3.Retain) {
FREE( ctx->EvalMap.Map2Texture3.Points );
- ctx->EvalMap.Map2Texture3.Points = pnts;
+ }
+ ctx->EvalMap.Map2Texture3.Retain = retain;
+ ctx->EvalMap.Map2Texture3.Points = (GLfloat *) points;
break;
case GL_MAP2_TEXTURE_COORD_4:
ctx->EvalMap.Map2Texture4.Uorder = uorder;
@@ -1123,9 +1156,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
ctx->EvalMap.Map2Texture4.v1 = v1;
ctx->EvalMap.Map2Texture4.v2 = v2;
ctx->EvalMap.Map2Texture4.dv = 1.0 / (v2 - v1);
- if (ctx->EvalMap.Map2Texture4.Points)
+ if (ctx->EvalMap.Map2Texture4.Points
+ && !ctx->EvalMap.Map2Texture4.Retain) {
FREE( ctx->EvalMap.Map2Texture4.Points );
- ctx->EvalMap.Map2Texture4.Points = pnts;
+ }
+ ctx->EvalMap.Map2Texture4.Retain = retain;
+ ctx->EvalMap.Map2Texture4.Points = (GLfloat *) points;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
@@ -1133,33 +1169,11 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
}
-void
-_mesa_Map2f( GLenum target,
- GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
- GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
- const GLfloat *points)
-{
- map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
- points, GL_FLOAT);
-}
-
-
-void
-_mesa_Map2d( GLenum target,
- GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
- GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
- const GLdouble *points )
-{
- map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
- points, GL_DOUBLE);
-}
+
-
-void
-_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
+void gl_GetMapdv( GLcontext* ctx, GLenum target, GLenum query, GLdouble *v )
{
- GET_CURRENT_CONTEXT(ctx);
GLint i, n;
GLfloat *data;
@@ -1429,10 +1443,8 @@ _mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
}
-void
-_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
+void gl_GetMapfv( GLcontext* ctx, GLenum target, GLenum query, GLfloat *v )
{
- GET_CURRENT_CONTEXT(ctx);
GLint i, n;
GLfloat *data;
@@ -1702,10 +1714,8 @@ _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
}
-void
-_mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
+void gl_GetMapiv( GLcontext* ctx, GLenum target, GLenum query, GLint *v )
{
- GET_CURRENT_CONTEXT(ctx);
GLuint i, n;
GLfloat *data;
@@ -2482,8 +2492,8 @@ void gl_eval_vb( struct vertex_buffer *VB )
VB->NormalPtr = eval2_norm( out_normal, coord, flags, IM->Start,
&ctx->EvalMap.Map2Normal );
+ new_flags |= VERT_NORM;
if (VB->NormalPtr != in_normal) {
- new_flags |= VERT_NORM;
if (!all_eval)
VB->NormalPtr = copy_3f( out_normal, in_normal, flags, IM->Start );
}
@@ -2551,26 +2561,43 @@ void gl_eval_vb( struct vertex_buffer *VB )
}
if (any_eval2) {
+ GLvector3f *in_normal = VB->NormalPtr;
+ GLvector3f *out_normal = &IM->v.Normal;
+
if (ctx->Eval.Map2Vertex4)
{
- if (ctx->Eval.AutoNormal && (req & VERT_NORM))
- obj = eval2_obj_norm( out, VB->NormalPtr, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map2Vertex4 );
+ if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
+ obj = eval2_obj_norm( out, out_normal, coord, flags,
+ IM->Start, 4, &ctx->EvalMap.Map2Vertex4 );
+ VB->NormalPtr = out_normal;
+ new_flags |= VERT_NORM;
+ }
else
obj = eval2_4f( out, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map2Vertex4);
+ 4, &ctx->EvalMap.Map2Vertex4 );
}
else if (ctx->Eval.Map2Vertex3)
{
- if (ctx->Eval.AutoNormal && (req & VERT_NORM))
- obj = eval2_obj_norm( out, VB->NormalPtr, coord, flags, IM->Start,
- 3, &ctx->EvalMap.Map2Vertex3 );
+ if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
+ obj = eval2_obj_norm( out, out_normal, coord, flags,
+ IM->Start, 3, &ctx->EvalMap.Map2Vertex3 );
+ VB->NormalPtr = out_normal;
+ new_flags |= VERT_NORM;
+ }
else
obj = eval2_4f( out, coord, flags, IM->Start,
3, &ctx->EvalMap.Map2Vertex3 );
}
- }
+
+ if (VB->NormalPtr != in_normal) {
+ if (!all_eval)
+ VB->NormalPtr = copy_3f( out_normal, in_normal, flags,
+ IM->Start );
+ }
+ }
+
+
if (obj != in && !all_eval)
obj = copy_4f( out, in, flags, IM->Start );
@@ -2582,6 +2609,7 @@ void gl_eval_vb( struct vertex_buffer *VB )
GLuint *flags = VB->Flag = VB->EvaluatedFlags;
GLuint i;
GLuint count = VB->Count;
+ GLuint andflag = VB->IM->AndFlag;
if (!flags) {
VB->EvaluatedFlags = (GLuint *) MALLOC(VB->Size * sizeof(GLuint));
@@ -2591,22 +2619,24 @@ void gl_eval_vb( struct vertex_buffer *VB )
if (all_eval) {
for (i = 0 ; i < count ; i++)
flags[i] = oldflags[i] | new_flags;
+ andflag |= new_flags;
} else {
- GLuint andflag = ~0;
+ andflag = ~0;
for (i = 0 ; i < count ; i++) {
if (oldflags[i] & VERT_EVAL_ANY)
flags[i] = oldflags[i] | new_flags;
andflag &= flags[i];
}
}
+
+ VB->OrFlag |= new_flags;
+ VB->CullMode = (GLubyte) ((andflag & VERT_NORM) ? 0 : COMPACTED_NORMALS);
}
}
-void
-_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
+void gl_MapGrid1f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2 )
{
- GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid1f");
if (un<1) {
@@ -2620,18 +2650,9 @@ _mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
}
-void
-_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
+void gl_MapGrid2f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2,
+ GLint vn, GLfloat v1, GLfloat v2 )
{
- _mesa_MapGrid1f( un, u1, u2 );
-}
-
-
-void
-_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
- GLint vn, GLfloat v1, GLfloat v2 )
-{
- GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid2f");
if (un<1) {
gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" );
@@ -2652,185 +2673,9 @@ _mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
}
-void
-_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
- GLint vn, GLdouble v1, GLdouble v2 )
-{
- _mesa_MapGrid2f( un, u1, u2, vn, v1, v2 );
-}
-
-
-
-
-/* KW: If are compiling, we don't know whether eval will produce a
- * vertex when it is run in the future. If this is pure immediate
- * mode, eval is a noop if neither vertex map is enabled.
- *
- * Thus we need to have a check in the display list code or
- * elsewhere for eval(1,2) vertices in the case where
- * map(1,2)_vertex is disabled, and to purge those vertices from
- * the vb. This is currently done
- * via modifications to the cull_vb and render_vb operations, and
- * by using the existing cullmask mechanism for all other operations.
- */
-
-
-/* KW: Because the eval values don't become 'current', fixup will flow
- * through these vertices, and then evaluation will write on top
- * of the fixup results.
- *
- * This is a little inefficient, but at least it is correct. This
- * could be short-circuited in the case where all vertices are
- * eval-vertices, or more generally by a cullmask in fixup.
- *
- * Note: using Obj to hold eval coord data. This data is actually
- * transformed if eval is disabled. But disabling eval & sending
- * eval coords is stupid, right?
- */
-
-
-#define EVALCOORD1(IM, x) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_C1; \
- ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
- if (count == VB_MAX-1) \
- IM->maybe_transform_vb( IM ); \
-}
-
-#define EVALCOORD2(IM, x, y) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_C2; \
- ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
- if (count == VB_MAX-1) \
- IM->maybe_transform_vb( IM ); \
-}
-
-#define EVALPOINT1(IM, x) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_P1; \
- ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
- if (count == VB_MAX-1) \
- IM->maybe_transform_vb( IM ); \
-}
-
-#define EVALPOINT2(IM, x, y) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_P2; \
- ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
- if (count == VB_MAX-1) \
- IM->maybe_transform_vb( IM ); \
-}
-
-/* Lame internal function:
- */
-void gl_EvalCoord1f( GLcontext *CC, GLfloat u )
-{
- struct immediate *i = CC->input;
- EVALCOORD1( i, u );
-}
-
-
-void
-_mesa_EvalCoord1d( GLdouble u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) u );
-}
-
-
-void
-_mesa_EvalCoord1f( GLfloat u )
+void gl_EvalMesh1( GLcontext* ctx, GLenum mode, GLint i1, GLint i2 )
{
- GET_IMMEDIATE;
- EVALCOORD1( IM, u );
-}
-
-
-void
-_mesa_EvalCoord1dv( const GLdouble *u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) *u );
-}
-
-
-void
-_mesa_EvalCoord1fv( const GLfloat *u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) *u );
-}
-
-
-void
-_mesa_EvalCoord2d( GLdouble u, GLdouble v )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, (GLfloat) u, (GLfloat) v );
-}
-
-
-void
-_mesa_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, u, v );
-}
-
-
-/* Lame internal function:
- */
-void gl_EvalCoord2f( GLcontext *CC, GLfloat u, GLfloat v )
-{
- struct immediate *i = CC->input;
- EVALCOORD2( i, u, v );
-}
-
-
-void
-_mesa_EvalCoord2dv( const GLdouble *u )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, (GLfloat) u[0], (GLfloat) u[1] );
-}
-
-
-void
-_mesa_EvalCoord2fv( const GLfloat *u )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, u[0], u[1] );
-}
-
-
-void
-_mesa_EvalPoint1( GLint i )
-{
- GET_IMMEDIATE;
- EVALPOINT1( IM, i );
-}
-
-
-void
-_mesa_EvalPoint2( GLint i, GLint j )
-{
- GET_IMMEDIATE;
- EVALPOINT2( IM, i, j );
-}
-
-
-
-
-
-void
-_mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
-{
- GET_CURRENT_CONTEXT(ctx);
GLint i;
GLfloat u, du;
GLenum prim;
@@ -2870,10 +2715,11 @@ _mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
-void
-_mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
+void gl_EvalMesh2( GLcontext* ctx,
+ GLenum mode,
+ GLint i1, GLint i2,
+ GLint j1, GLint j2 )
{
- GET_CURRENT_CONTEXT(ctx);
GLint i, j;
GLfloat u, du, v, dv, v1, u1;
@@ -2934,6 +2780,3 @@ _mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
return;
}
}
-
-
-
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index f86e7f1840..1287fb3f8c 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.8.2.9 2000/07/13 19:50:04 brianp Exp $ */
+/* $Id: light.c,v 1.8.2.10 2000/07/17 12:49:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1007,29 +1007,12 @@ static void compute_shine_table( struct gl_shine_tab *tab, GLfloat shininess )
double dp = i/(GLfloat)(SHINE_TABLE_SIZE-1);
double t = pow( dp, shininess );
if (t < 1e-20) t = 0;
- m[i*2] = (GLfloat) t;
-
- /* Also calculate the derivative of dp^shininess at this point,
- scaling for table lookup. (Actually, given f'(x0), it's easy
- to calculate f(x0), so maybe we only need this)
- */
- if (dp == 0.0)
- m[i*2+1] = pow((i+1) / (GLfloat)(SHINE_TABLE_SIZE-1), shininess);
- else
- m[i*2+1] = shininess * t / (dp * (SHINE_TABLE_SIZE-1) );
+ m[i] = (GLfloat) t;
}
tab->shininess = shininess;
}
-static void reset_shine_table( struct gl_shine_tab *tab, GLfloat shininess )
-{
- int i;
- for ( i = 0 ; i < SHINE_TABLE_SIZE ; i++)
- tab->tab[i] = -1;
- tab->shininess = shininess;
-}
-
void gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
{