summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2000-07-12 12:02:33 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2000-07-12 12:02:33 +0000
commit865b03207c62bc9fd4dcb552dd2567d52a251e39 (patch)
treefa509cc5f4147a748d3ecae7859f29da0ceab454
parent39be967b6db0330b28df4d89b5dff00961bf8a75 (diff)
Use 3.0 style on-the-fly computation of shine table values.
-rw-r--r--src/mesa/main/context.c7
-rw-r--r--src/mesa/main/light.c15
-rw-r--r--src/mesa/main/light.h4
3 files changed, 18 insertions, 8 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index e7da2d8ac8..1b55936bb5 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.18.2.12 2000/06/30 14:16:37 brianp Exp $ */
+/* $Id: context.c,v 1.18.2.13 2000/07/12 12:02:33 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1307,10 +1307,13 @@ GLcontext *gl_create_context( GLvisual *visual,
}
for (i = 0 ; i < 4 ; i++) {
- ctx->ShineTable[i] = ctx->ShineTabList->prev;
+ ctx->ShineTable[i] = ctx->ShineTabList->next;
ctx->ShineTable[i]->refcount++;
}
+ for (i = 0 ; i < 4 ; i++)
+ gl_compute_shine_table( ctx, i, 0.0 );
+
if (visual->DBflag) {
ctx->Color.DrawBuffer = GL_BACK;
ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 8b49e9d123..c9772d0781 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.8.2.6 2000/07/10 18:06:19 keithw Exp $ */
+/* $Id: light.c,v 1.8.2.7 2000/07/12 12:02:33 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1004,7 +1004,6 @@ static void compute_shine_table( struct gl_shine_tab *tab, GLfloat shininess )
GLfloat *m = tab->tab;
m[0] = pow(0, shininess); /* special case for [0,1) -- sample at zero */
-
for (i = 1 ; i < SHINE_TABLE_SIZE ; i++) {
double t = pow( (i+.5)/(GLfloat)(SHINE_TABLE_SIZE-1), shininess );
if (t < 1e-20) t = 0;
@@ -1014,7 +1013,14 @@ static void compute_shine_table( struct gl_shine_tab *tab, GLfloat shininess )
tab->shininess = shininess;
}
-#define DISTSQR(a,b) ((a-b)*(a-b))
+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 )
{
@@ -1030,9 +1036,10 @@ void gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
foreach(s, list)
if (s->refcount == 0) break;
- compute_shine_table( s, shininess );
+/* compute_shine_table( s, shininess ); */
}
+ reset_shine_table( s, shininess );
ctx->ShineTable[i]->refcount--;
ctx->ShineTable[i] = s;
move_to_tail( list, s );
diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h
index 006bead070..f3f6843ea4 100644
--- a/src/mesa/main/light.h
+++ b/src/mesa/main/light.h
@@ -1,4 +1,4 @@
-/* $Id: light.h,v 1.1.1.1.2.1 2000/06/27 15:04:20 brianp Exp $ */
+/* $Id: light.h,v 1.1.1.1.2.2 2000/07/12 12:02:33 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,7 +36,7 @@
struct gl_shine_tab {
struct gl_shine_tab *next, *prev;
- GLfloat tab[SHINE_TABLE_SIZE+1];
+ GLfloat tab[SHINE_TABLE_SIZE];
GLfloat shininess;
GLuint refcount;
};