clean up the shine table lookup macro.
-/* $Id: xm_tri.c,v 1.17 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: xm_tri.c,v 1.18 2001/02/06 04:06:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
#endif
-
+
static swrast_tri_func get_triangle_func( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
-/* $Id: dd.h,v 1.49 2001/01/29 20:47:39 keithw Exp $ */
+/* $Id: dd.h,v 1.50 2001/02/06 04:06:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
#define PRIM_UNKNOWN GL_POLYGON+3
GLuint CurrentExecPrimitive;
- /* Set by the driver-supplied t&l engine. Set to GL_POLYGON+1 when
- * outside begin/end.
+ /* Set by the driver-supplied t&l engine. Set to
+ * PRIM_OUTSIDE_BEGIN_END when outside begin/end.
*/
GLuint CurrentSavePrimitive;
- /* Current state of an inprogress compilation.
+ /* Current state of an in-progress compilation. May take on any of
+ * the additional values defined above.
*/
* if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
* if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
* and ctx->Light.Material
- * returns GL_TRUE.
*
* Note that the default t&l engine never clears the
* FLUSH_UPDATE_CURRENT bit, even after performing the update.
-/* $Id: imports.c,v 1.4 2001/01/08 04:09:41 keithw Exp $ */
+/* $Id: imports.c,v 1.5 2001/02/06 04:06:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
imports->warning = _mesa_warning;
imports->fatal = _mesa_fatal;
imports->getenv = _mesa_getenv;
-/* imports->atoi = _mesa_atoi; */
+ imports->atoi = _mesa_atoi;
imports->sprintf = _mesa_sprintf;
imports->fopen = _mesa_fopen;
imports->fclose = _mesa_fclose;
-/* $Id: light.h,v 1.8 2000/12/26 05:09:29 keithw Exp $ */
+/* $Id: light.h,v 1.9 2001/02/06 04:06:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
#define GET_SHINE_TAB_ENTRY( table, dp, result ) \
do { \
struct gl_shine_tab *_tab = table; \
- if (dp>1.0) \
+ float f = (dp * (SHINE_TABLE_SIZE-1)); \
+ int k = (int) f; \
+ if (k > SHINE_TABLE_SIZE-2) \
result = pow( dp, _tab->shininess ); \
- else { \
- float f = (dp * (SHINE_TABLE_SIZE-1)); \
- int k = (int) f; \
+ else \
result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
- } \
} while (0)
-/* $Id: t_vb_fog.c,v 1.2 2001/01/03 22:56:23 brianp Exp $ */
+/* $Id: t_vb_fog.c,v 1.3 2001/02/06 04:06:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->private)
+#define FOG_EXP_TABLE_SIZE 256
+#define FOG_MAX (5.0)
+#define EXP_FOG_MAX .0006595
+#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
+static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
+static GLfloat inited = 0;
+
+#if 1
+#define NEG_EXP( result, narg ) \
+do { \
+ float f = (narg * (1.0/FOG_INCR)); \
+ int k = (int) f; \
+ if (k > FOG_EXP_TABLE_SIZE-2) \
+ result = EXP_FOG_MAX; \
+ else \
+ result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \
+} while (0)
+#else
+#define NEG_EXP( result, narg ) \
+do { \
+ result = exp(-narg); \
+} while (0)
+#endif
+
+
+static void init_static_data( void )
+{
+ float f = 0;
+ int i = 0;
+ for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
+ exp_table[i] = exp(-f);
+ }
+ inited = 1;
+}
-/* Use lookup table & interpolation?
- */
static void make_win_fog_coords( GLcontext *ctx, GLvector1f *out,
const GLvector1f *in )
{
data[i] = (end - ABSF(*v)) * d;
break;
case GL_EXP:
- d = -ctx->Fog.Density;
+ d = ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride))
- data[i] = exp( d*ABSF(*v) );
+ NEG_EXP( data[i], d*ABSF(*v) );
break;
case GL_EXP2:
- d = -(ctx->Fog.Density*ctx->Fog.Density);
+ d = ctx->Fog.Density*ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
GLfloat z = *v;
- data[i] = exp( d*z*z );
+ NEG_EXP( data[i], d*z*z );
}
break;
default:
gl_vector1f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 );
gl_vector1f_init( &store->input, 0, 0 );
+ if (!inited)
+ init_static_data();
+
/* Now run the stage.
*/
stage->run = run_fog_stage;