replace color table FloatTable boolean with Type enum
[mesa.git] / src / mesa / main / rastpos.c
index 8184a25b975b2e82878662b3d37fa7368bd25b9b..5e7ef50b46ba70954c30f02f57505634a6db0ebd 100644 (file)
@@ -129,7 +129,7 @@ shade_rastpos(GLcontext *ctx,
               const GLfloat normal[3],
               GLfloat Rcolor[4],
               GLfloat Rspec[4],
-              GLuint *Rindex)
+              GLfloat *Rindex)
 {
    GLfloat (*base)[3] = ctx->Light._BaseColor;
    struct gl_light *light;
@@ -140,7 +140,8 @@ shade_rastpos(GLcontext *ctx,
       _mesa_validate_all_lighting_tables( ctx );
 
    COPY_3V(diffuseColor, base[0]);
-   diffuseColor[3] = CLAMP( ctx->Light.Material[0].Diffuse[3], 0.0F, 1.0F );
+   diffuseColor[3] = CLAMP( 
+      ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F );
    ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0);
 
    foreach (light, &ctx->Light.EnabledList) {
@@ -223,9 +224,9 @@ shade_rastpos(GLcontext *ctx,
         n_dot_h = DOT3(normal, h);
 
         if (n_dot_h > 0.0F) {
-           const struct gl_material *mat = &ctx->Light.Material[0];
+           GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
            GLfloat spec_coef;
-           GLfloat shininess = mat->Shininess;
+           GLfloat shininess = mat[MAT_ATTRIB_FRONT_SHININESS][0];
 
            if (!normalized) {
               n_dot_h *= n_dot_h;
@@ -264,16 +265,16 @@ shade_rastpos(GLcontext *ctx,
       Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
    }
    else {
-      struct gl_material *mat = &ctx->Light.Material[0];
-      GLfloat d_a = mat->DiffuseIndex - mat->AmbientIndex;
-      GLfloat s_a = mat->SpecularIndex - mat->AmbientIndex;
-      GLfloat ind = mat->AmbientIndex
-                  + diffuse * (1.0F-specular) * d_a
-                  + specular * s_a;
-      if (ind > mat->SpecularIndex) {
-        ind = mat->SpecularIndex;
+      GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES];
+      GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
+      GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
+      GLfloat i = (ind[MAT_INDEX_AMBIENT]
+                  + diffuse * (1.0F-specular) * d_a
+                  + specular * s_a);
+      if (i > ind[MAT_INDEX_SPECULAR]) {
+        i = ind[MAT_INDEX_SPECULAR];
       }
-      *Rindex = (GLuint) (GLint) ind;
+      *Rindex = i;
    }
 }
 
@@ -379,7 +380,7 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
       }
 
       /* ndc = clip / W */
-      d = (clip[3] == 0.0) ? 1.0 : 1.0F / clip[3];
+      d = (clip[3] == 0.0F) ? 1.0F : 1.0F / clip[3];
       ndc[0] = clip[0] * d;
       ndc[1] = clip[1] * d;
       ndc[2] = clip[2] * d;
@@ -410,70 +411,70 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2d(GLdouble x, GLdouble y)
 {
    _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2f(GLfloat x, GLfloat y)
 {
    _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2i(GLint x, GLint y)
 {
    _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2s(GLshort x, GLshort y)
 {
    _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
 {
    _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
 {
    _mesa_RasterPos4f(x, y, z, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3i(GLint x, GLint y, GLint z)
 {
    _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3s(GLshort x, GLshort y, GLshort z)
 {
    _mesa_RasterPos4f(x, y, z, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
    _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 /** Calls raster_pos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -481,77 +482,77 @@ _mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
 {
    _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
 {
    _mesa_RasterPos4f(x, y, z, w);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2dv(const GLdouble *v)
 {
    _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2fv(const GLfloat *v)
 {
    _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2iv(const GLint *v)
 {
    _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos2sv(const GLshort *v)
 {
    _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3dv(const GLdouble *v)
 {
    _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3fv(const GLfloat *v)
 {
    _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3iv(const GLint *v)
 {
    _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos3sv(const GLshort *v)
 {
    _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4dv(const GLdouble *v)
 {
    _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
@@ -559,14 +560,14 @@ _mesa_RasterPos4dv(const GLdouble *v)
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4fv(const GLfloat *v)
 {
    _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4iv(const GLint *v)
 {
    _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
@@ -574,7 +575,7 @@ _mesa_RasterPos4iv(const GLint *v)
 }
 
 /** Calls _mesa_RasterPos4f() */
-void
+void GLAPIENTRY
 _mesa_RasterPos4sv(const GLshort *v)
 {
    _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
@@ -663,147 +664,147 @@ window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 }
 
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2dMESA(GLdouble x, GLdouble y)
 {
    window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2fMESA(GLfloat x, GLfloat y)
 {
    window_pos4f(x, y, 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2iMESA(GLint x, GLint y)
 {
    window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2sMESA(GLshort x, GLshort y)
 {
    window_pos4f(x, y, 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
 {
    window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
 {
    window_pos4f(x, y, z, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3iMESA(GLint x, GLint y, GLint z)
 {
    window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
 {
    window_pos4f(x, y, z, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
    window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 {
    window_pos4f(x, y, z, w);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
 {
    window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
 {
    window_pos4f(x, y, z, w);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2dvMESA(const GLdouble *v)
 {
    window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2fvMESA(const GLfloat *v)
 {
    window_pos4f(v[0], v[1], 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2ivMESA(const GLint *v)
 {
    window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos2svMESA(const GLshort *v)
 {
    window_pos4f(v[0], v[1], 0.0F, 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3dvMESA(const GLdouble *v)
 {
    window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3fvMESA(const GLfloat *v)
 {
    window_pos4f(v[0], v[1], v[2], 1.0);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3ivMESA(const GLint *v)
 {
    window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos3svMESA(const GLshort *v)
 {
    window_pos4f(v[0], v[1], v[2], 1.0F);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4dvMESA(const GLdouble *v)
 {
    window_pos4f((GLfloat) v[0], (GLfloat) v[1], 
                         (GLfloat) v[2], (GLfloat) v[3]);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4fvMESA(const GLfloat *v)
 {
    window_pos4f(v[0], v[1], v[2], v[3]);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4ivMESA(const GLint *v)
 {
    window_pos4f((GLfloat) v[0], (GLfloat) v[1], 
                         (GLfloat) v[2], (GLfloat) v[3]);
 }
 
-void
+void GLAPIENTRY
 _mesa_WindowPos4svMESA(const GLshort *v)
 {
    window_pos4f(v[0], v[1], v[2], v[3]);
@@ -871,7 +872,7 @@ void _mesa_init_rastpos( GLcontext * ctx )
    ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 );
    ctx->Current.RasterDistance = 0.0;
    ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
-   ctx->Current.RasterIndex = 1;
+   ctx->Current.RasterIndex = 1.0;
    for (i=0; i<MAX_TEXTURE_UNITS; i++)
       ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 );
    ctx->Current.RasterPosValid = GL_TRUE;