summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-02-08 20:11:58 -0700
committerBrian Paul <[email protected]>2012-02-10 08:06:57 -0700
commit9d9111108eadd65708899284b1cfa9ca425f3ac8 (patch)
tree7c1dadd69f9bd5e2f3758e091a322ded49092b0c /src/mesa/main
parentd1b79672425115b0f6f9fc3aadcf3800f5f3a7dc (diff)
mesa: replace GET_SHINE_TAB_ENTRY() macro with an inline function
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/light.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h
index 26e604bc523..996698793f5 100644
--- a/src/mesa/main/light.h
+++ b/src/mesa/main/light.h
@@ -87,22 +87,24 @@ extern void
_mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params);
-/* Lerp between adjacent values in the f(x) lookup table, giving a
- * continuous function, with adequeate overall accuracy. (Though
- * still pretty good compared to a straight lookup).
- * Result should be a GLfloat.
+/*
+ * Compute dp ^ SpecularExponent.
+ * Lerp between adjacent values in the f(x) lookup table, giving a
+ * continuous function, with adequate overall accuracy. (Though still
+ * pretty good compared to a straight lookup).
*/
-#define GET_SHINE_TAB_ENTRY( table, dp, result ) \
-do { \
- struct gl_shine_tab *_tab = table; \
- float f = (dp * (SHINE_TABLE_SIZE-1)); \
- int k = (int) f; \
- if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \
- || k > SHINE_TABLE_SIZE-2) \
- result = (GLfloat) pow( dp, _tab->shininess ); \
- else \
- result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
-} while (0)
+static inline GLfloat
+_mesa_lookup_shininess(const struct gl_context *ctx, GLuint face, GLfloat dp)
+{
+ const struct gl_shine_tab *tab = ctx->_ShineTable[face];
+ float f = dp * (SHINE_TABLE_SIZE - 1);
+ int k = (int) f;
+ if (k < 0 /* gcc may cast an overflow float value to negative int value */
+ || k > SHINE_TABLE_SIZE - 2)
+ return powf(dp, tab->shininess);
+ else
+ return tab->tab[k] + (f - k) * (tab->tab[k+1] - tab->tab[k]);
+}
extern GLuint _mesa_material_bitmask( struct gl_context *ctx,