*/
-
+#include "c99_math.h"
#include "main/glheader.h"
-#include "main/colormac.h"
#include "main/light.h"
#include "main/macros.h"
#include "main/imports.h"
-#include "main/simple_list.h"
+#include "util/simple_list.h"
#include "main/mtypes.h"
#include "math/m_translate.h"
+#include "util/bitscan.h"
+
#include "t_context.h"
#include "t_pipeline.h"
#include "tnl.h"
struct tnl_shine_tab *list = tnl->_ShineTabList;
struct tnl_shine_tab *s;
- ASSERT(side < 2);
+ assert(side < 2);
foreach(s, list)
if ( s->shininess == shininess )
break;
m = s->tab;
- m[0] = 0.0;
- if (shininess == 0.0) {
+ m[0] = 0.0F;
+ if (shininess == 0.0F) {
for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++)
- m[j] = 1.0;
+ m[j] = 1.0F;
}
else {
for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) {
- GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1);
- if (x < 0.005) /* underflow check */
- x = 0.005;
- t = pow(x, shininess);
- if (t > 1e-20)
- m[j] = (GLfloat) t;
+ GLfloat t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1);
+ if (x < 0.005F) /* underflow check */
+ x = 0.005F;
+ t = powf(x, shininess);
+ if (t > 1e-20F)
+ m[j] = t;
else
- m[j] = 0.0;
+ m[j] = 0.0F;
}
- m[SHINE_TABLE_SIZE] = 1.0;
+ m[SHINE_TABLE_SIZE] = 1.0F;
}
s->shininess = shininess;
* with the color pointer for each one.
*/
if (ctx->Light.ColorMaterialEnabled) {
- const GLuint bitmask = ctx->Light._ColorMaterialBitmask;
- for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
- if (bitmask & (1<<i))
- VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
+ while (bitmask) {
+ const int i = u_bit_scan(&bitmask);
+ VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] =
+ VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ }
}
/* Now, for each material attribute that's tracking vertex color, save
tab = _tnl_light_tab;
}
else {
- if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
+ /* Power of two means only a single active light. */
+ if (_mesa_is_pow_two(ctx->Light._EnabledLights))
tab = _tnl_light_fast_single_tab;
else
tab = _tnl_light_fast_tab;