summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2006-03-21 10:37:40 +0000
committerMichal Krol <mjkrol@gmail.org>2006-03-21 10:37:40 +0000
commit071357096e682e9af59ad45ea5abc444ab431837 (patch)
tree99fba2183fe97981f7c309d99b206b39e43f5bec /src/mesa/main
parent519b23b21f9cd6945fd17cdb26e7a6f531cdeec0 (diff)
GLSL fixes:
- generate error on NULL pointers in glShaderSourceARB; - reinstall program object, if current, in glLinkProgramARB; - vertex and fragment shaders are optional in program object; - floor asm was wrongly computed for x86 back-end; - allow for (void) idiom in function prototypes; - all fixed-state uniforms are updated; - local variable initializers are working; - implement texture* and shadow* functions for vertex processor; - generate error if too many arguments in general constructor; - trim unused data in general constructor; - struct r-value field select was badly relocated; Changes: - add derived state gl_fog_attrib::_Scale; - add derived state gl_light::_CosCutoffNeg;
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/fog.c35
-rw-r--r--src/mesa/main/light.c19
-rw-r--r--src/mesa/main/mtypes.h10
-rw-r--r--src/mesa/main/texstate.c6
4 files changed, 44 insertions, 26 deletions
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index d3b8a923aa..df99c6519f 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -70,7 +70,15 @@ _mesa_Fogiv(GLenum pname, const GLint *params )
;
}
_mesa_Fogfv(pname, p);
-}
+}
+
+
+#define UPDATE_FOG_SCALE(ctx) do {\
+ if (ctx->Fog.End == ctx->Fog.Start)\
+ ctx->Fog._Scale = 1.0f;\
+ else\
+ ctx->Fog._Scale = 1.0f / (ctx->Fog.End - ctx->Fog.Start);\
+ } while(0)
void GLAPIENTRY
@@ -108,17 +116,19 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
ctx->Fog.Density = *params;
break;
case GL_FOG_START:
- if (ctx->Fog.Start == *params)
- return;
- FLUSH_VERTICES(ctx, _NEW_FOG);
- ctx->Fog.Start = *params;
- break;
+ if (ctx->Fog.Start == *params)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Start = *params;
+ UPDATE_FOG_SCALE(ctx);
+ break;
case GL_FOG_END:
- if (ctx->Fog.End == *params)
- return;
- FLUSH_VERTICES(ctx, _NEW_FOG);
- ctx->Fog.End = *params;
- break;
+ if (ctx->Fog.End == *params)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.End = *params;
+ UPDATE_FOG_SCALE(ctx);
+ break;
case GL_FOG_INDEX:
if (ctx->Fog.Index == *params)
return;
@@ -173,5 +183,6 @@ void _mesa_init_fog( GLcontext * ctx )
ctx->Fog.Start = 0.0;
ctx->Fog.End = 1.0;
ctx->Fog.ColorSumEnabled = GL_FALSE;
- ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
+ ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
+ ctx->Fog._Scale = 1.0f;
}
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 8fa62eb873..35ec1547e9 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -123,16 +123,18 @@ _mesa_light(GLcontext *ctx, GLuint lnum, GLenum pname, const GLfloat *params)
case GL_SPOT_CUTOFF:
ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0));
if (light->SpotCutoff == params[0])
- return;
+ return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
- light->SpotCutoff = params[0];
- light->_CosCutoff = (GLfloat) _mesa_cos(params[0]*DEG2RAD);
- if (light->_CosCutoff < 0)
- light->_CosCutoff = 0;
+ light->SpotCutoff = params[0];
+ light->_CosCutoffNeg = (GLfloat) (_mesa_cos(light->SpotCutoff * DEG2RAD));
+ if (light->_CosCutoffNeg < 0)
+ light->_CosCutoff = 0;
+ else
+ light->_CosCutoff = light->_CosCutoffNeg;
if (light->SpotCutoff != 180.0F)
- light->_Flags |= LIGHT_SPOT;
+ light->_Flags |= LIGHT_SPOT;
else
- light->_Flags &= ~LIGHT_SPOT;
+ light->_Flags &= ~LIGHT_SPOT;
break;
case GL_CONSTANT_ATTENUATION:
ASSERT(params[0] >= 0.0);
@@ -1263,7 +1265,8 @@ init_light( struct gl_light *l, GLuint n )
ASSIGN_3V( l->EyeDirection, 0.0, 0.0, -1.0 );
l->SpotExponent = 0.0;
_mesa_invalidate_spot_exp_table( l );
- l->SpotCutoff = 180.0;
+ l->SpotCutoff = 180.0;
+ l->_CosCutoffNeg = -1.0f;
l->_CosCutoff = 0.0; /* KW: -ve values not admitted */
l->ConstantAttenuation = 1.0;
l->LinearAttenuation = 0.0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 82d45f3592..c69b4a48b5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -429,7 +429,8 @@ struct gl_light
GLfloat EyePosition[4]; /**< position in eye coordinates */
GLfloat EyeDirection[4]; /**< spotlight dir in eye coordinates */
GLfloat SpotExponent;
- GLfloat SpotCutoff; /**< in degrees */
+ GLfloat SpotCutoff; /**< in degrees */
+ GLfloat _CosCutoffNeg; /**< = cos(SpotCutoff) */
GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
GLfloat ConstantAttenuation;
GLfloat LinearAttenuation;
@@ -727,7 +728,8 @@ struct gl_fog_attrib
GLfloat Index; /**< Fog index */
GLenum Mode; /**< Fog mode */
GLboolean ColorSumEnabled;
- GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
+ GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
+ GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
};
@@ -1949,7 +1951,9 @@ struct gl_query_state
*/
struct gl_shader_objects_state
{
- struct gl2_program_intf **CurrentProgram;
+ struct gl2_program_intf **CurrentProgram;
+ GLboolean _VertexShaderPresent;
+ GLboolean _FragmentShaderPresent;
};
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index a8cb8a7bcf..5de5f6815a 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -2812,7 +2812,7 @@ update_texture_state( GLcontext *ctx )
* uniform sampler changes, so maybe there is a better place to perform these rather
* expensive computations.
*/
- if (prog != NULL) {
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
(**prog).GetTextureImageUsage (prog, progteximageusage);
}
@@ -2829,7 +2829,7 @@ update_texture_state( GLcontext *ctx )
texUnit->_GenFlags = 0;
/* Get the bitmask of texture enables */
- if (prog != NULL) {
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
enableBits = progteximageusage[unit];
}
else if (ctx->FragmentProgram._Enabled) {
@@ -2948,7 +2948,7 @@ update_texture_state( GLcontext *ctx )
/* Fragment programs may need texture coordinates but not the
* corresponding texture images.
*/
- if (prog != NULL) {
+ if (ctx->ShaderObjects.CurrentProgram != NULL) {
ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;
}
else if (ctx->FragmentProgram._Enabled) {