Move all the code for computing ctx->_TriangleCaps into state.c.

ctx->_TriangleCaps should probably go away altogether someday...
This commit is contained in:
Brian
2006-12-13 15:31:14 -07:00
parent 6c305c0831
commit 8dcfcad7a2
8 changed files with 129 additions and 166 deletions

View File

@@ -49,8 +49,11 @@
} }
/**
* Helper to enable/disable client-side state.
*/
static void static void
client_state( GLcontext *ctx, GLenum cap, GLboolean state ) client_state(GLcontext *ctx, GLenum cap, GLboolean state)
{ {
GLuint flag; GLuint flag;
GLuint *var; GLuint *var;
@@ -134,17 +137,14 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->Array.ArrayObj->_Enabled &= ~flag; ctx->Array.ArrayObj->_Enabled &= ~flag;
if (ctx->Driver.Enable) { if (ctx->Driver.Enable) {
(*ctx->Driver.Enable)( ctx, cap, state ); ctx->Driver.Enable( ctx, cap, state );
} }
} }
/** /**
* Enable GL capability. * Enable GL capability.
* * \param cap state to enable/disable.
* \param cap capability.
*
* \sa glEnable().
* *
* Get's the current context, assures that we're outside glBegin()/glEnd() and * Get's the current context, assures that we're outside glBegin()/glEnd() and
* calls client_state(). * calls client_state().
@@ -160,10 +160,7 @@ _mesa_EnableClientState( GLenum cap )
/** /**
* Disable GL capability. * Disable GL capability.
* * \param cap state to enable/disable.
* \param cap capability.
*
* \sa glDisable().
* *
* Get's the current context, assures that we're outside glBegin()/glEnd() and * Get's the current context, assures that we're outside glBegin()/glEnd() and
* calls client_state(). * calls client_state().
@@ -195,10 +192,10 @@ _mesa_DisableClientState( GLenum cap )
/** /**
* Perform glEnable() and glDisable() calls. * Helper function to enable or disable state.
* *
* \param ctx GL context. * \param ctx GL context.
* \param cap capability. * \param cap the state to enable/disable
* \param state whether to enable or disable the specified capability. * \param state whether to enable or disable the specified capability.
* *
* Updates the current context and flushes the vertices as needed. For * Updates the current context and flushes the vertices as needed. For
@@ -206,7 +203,8 @@ _mesa_DisableClientState( GLenum cap )
* are effectivly present before updating. Notifies the driver via * are effectivly present before updating. Notifies the driver via
* dd_function_table::Enable. * dd_function_table::Enable.
*/ */
void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) void
_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
{ {
if (MESA_VERBOSE & VERBOSE_API) if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "%s %s (newstate is %x)\n", _mesa_debug(ctx, "%s %s (newstate is %x)\n",
@@ -285,7 +283,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
FLUSH_VERTICES(ctx, _NEW_POLYGON); FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.CullFlag = state; ctx->Polygon.CullFlag = state;
break; break;
case GL_CULL_VERTEX_EXT: case GL_CULL_VERTEX_EXT:
CHECK_EXTENSION(EXT_cull_vertex, cap); CHECK_EXTENSION(EXT_cull_vertex, cap);
if (ctx->Transform.CullVertexFlag == state) if (ctx->Transform.CullVertexFlag == state)
@@ -293,13 +290,12 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
FLUSH_VERTICES(ctx, _NEW_TRANSFORM); FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
ctx->Transform.CullVertexFlag = state; ctx->Transform.CullVertexFlag = state;
break; break;
case GL_DEPTH_TEST: case GL_DEPTH_TEST:
if (state && ctx->DrawBuffer->Visual.depthBits == 0) { if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
_mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
return; return;
} }
if (ctx->Depth.Test==state) if (ctx->Depth.Test == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_DEPTH); FLUSH_VERTICES(ctx, _NEW_DEPTH);
ctx->Depth.Test = state; ctx->Depth.Test = state;
@@ -308,13 +304,13 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
if (ctx->NoDither) { if (ctx->NoDither) {
state = GL_FALSE; /* MESA_NO_DITHER env var */ state = GL_FALSE; /* MESA_NO_DITHER env var */
} }
if (ctx->Color.DitherFlag==state) if (ctx->Color.DitherFlag == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_COLOR); FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.DitherFlag = state; ctx->Color.DitherFlag = state;
break; break;
case GL_FOG: case GL_FOG:
if (ctx->Fog.Enabled==state) if (ctx->Fog.Enabled == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_FOG); FLUSH_VERTICES(ctx, _NEW_FOG);
ctx->Fog.Enabled = state; ctx->Fog.Enabled = state;
@@ -351,26 +347,18 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
return; return;
FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Enabled = state; ctx->Light.Enabled = state;
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
else
ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
break; break;
case GL_LINE_SMOOTH: case GL_LINE_SMOOTH:
if (ctx->Line.SmoothFlag == state) if (ctx->Line.SmoothFlag == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_LINE); FLUSH_VERTICES(ctx, _NEW_LINE);
ctx->Line.SmoothFlag = state; ctx->Line.SmoothFlag = state;
ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
break; break;
case GL_LINE_STIPPLE: case GL_LINE_STIPPLE:
if (ctx->Line.StippleFlag == state) if (ctx->Line.StippleFlag == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_LINE); FLUSH_VERTICES(ctx, _NEW_LINE);
ctx->Line.StippleFlag = state; ctx->Line.StippleFlag = state;
ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
break; break;
case GL_INDEX_LOGIC_OP: case GL_INDEX_LOGIC_OP:
if (ctx->Color.IndexLogicOpEnabled == state) if (ctx->Color.IndexLogicOpEnabled == state)
@@ -505,41 +493,38 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->Transform.Normalize = state; ctx->Transform.Normalize = state;
break; break;
case GL_POINT_SMOOTH: case GL_POINT_SMOOTH:
if (ctx->Point.SmoothFlag==state) if (ctx->Point.SmoothFlag == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_POINT); FLUSH_VERTICES(ctx, _NEW_POINT);
ctx->Point.SmoothFlag = state; ctx->Point.SmoothFlag = state;
ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
break; break;
case GL_POLYGON_SMOOTH: case GL_POLYGON_SMOOTH:
if (ctx->Polygon.SmoothFlag==state) if (ctx->Polygon.SmoothFlag == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_POLYGON); FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.SmoothFlag = state; ctx->Polygon.SmoothFlag = state;
ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
break; break;
case GL_POLYGON_STIPPLE: case GL_POLYGON_STIPPLE:
if (ctx->Polygon.StippleFlag==state) if (ctx->Polygon.StippleFlag == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_POLYGON); FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.StippleFlag = state; ctx->Polygon.StippleFlag = state;
ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
break; break;
case GL_POLYGON_OFFSET_POINT: case GL_POLYGON_OFFSET_POINT:
if (ctx->Polygon.OffsetPoint==state) if (ctx->Polygon.OffsetPoint == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_POLYGON); FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.OffsetPoint = state; ctx->Polygon.OffsetPoint = state;
break; break;
case GL_POLYGON_OFFSET_LINE: case GL_POLYGON_OFFSET_LINE:
if (ctx->Polygon.OffsetLine==state) if (ctx->Polygon.OffsetLine == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_POLYGON); FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.OffsetLine = state; ctx->Polygon.OffsetLine = state;
break; break;
case GL_POLYGON_OFFSET_FILL: case GL_POLYGON_OFFSET_FILL:
/*case GL_POLYGON_OFFSET_EXT:*/ /*case GL_POLYGON_OFFSET_EXT:*/
if (ctx->Polygon.OffsetFill==state) if (ctx->Polygon.OffsetFill == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_POLYGON); FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.OffsetFill = state; ctx->Polygon.OffsetFill = state;
@@ -551,7 +536,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->Transform.RescaleNormals = state; ctx->Transform.RescaleNormals = state;
break; break;
case GL_SCISSOR_TEST: case GL_SCISSOR_TEST:
if (ctx->Scissor.Enabled==state) if (ctx->Scissor.Enabled == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_SCISSOR); FLUSH_VERTICES(ctx, _NEW_SCISSOR);
ctx->Scissor.Enabled = state; ctx->Scissor.Enabled = state;
@@ -568,7 +553,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
"glEnable(GL_STENCIL_TEST) but no stencil buffer"); "glEnable(GL_STENCIL_TEST) but no stencil buffer");
return; return;
} }
if (ctx->Stencil.Enabled==state) if (ctx->Stencil.Enabled == state)
return; return;
FLUSH_VERTICES(ctx, _NEW_STENCIL); FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.Enabled = state; ctx->Stencil.Enabled = state;
@@ -916,11 +901,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
return; return;
FLUSH_VERTICES(ctx, _NEW_STENCIL); FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.TestTwoSide = state; ctx->Stencil.TestTwoSide = state;
if (state) {
ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
} else {
ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL;
}
break; break;
#if FEATURE_ARB_fragment_program #if FEATURE_ARB_fragment_program
@@ -973,20 +953,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
} }
if (ctx->Driver.Enable) { if (ctx->Driver.Enable) {
(*ctx->Driver.Enable)( ctx, cap, state ); ctx->Driver.Enable( ctx, cap, state );
} }
} }
/** /**
* Enable GL capability. * Enable GL capability. Called by glEnable()
* * \param cap state to enable.
* \param cap capability.
*
* \sa glEnable().
*
* Get's the current context, assures that we're outside glBegin()/glEnd() and
* calls _mesa_set_enable().
*/ */
void GLAPIENTRY void GLAPIENTRY
_mesa_Enable( GLenum cap ) _mesa_Enable( GLenum cap )
@@ -999,14 +973,8 @@ _mesa_Enable( GLenum cap )
/** /**
* Disable GL capability. * Disable GL capability. Called by glDisable()
* * \param cap state to disable.
* \param cap capability.
*
* \sa glDisable().
*
* Get's the current context, assures that we're outside glBegin()/glEnd() and
* calls _mesa_set_enable().
*/ */
void GLAPIENTRY void GLAPIENTRY
_mesa_Disable( GLenum cap ) _mesa_Disable( GLenum cap )
@@ -1032,10 +1000,11 @@ _mesa_Disable( GLenum cap )
return GL_FALSE; \ return GL_FALSE; \
} }
/** /**
* Test whether a capability is enabled. * Return simple enable/disable state.
* *
* \param cap capability. * \param cap state variable to query.
* *
* Returns the state of the specified capability from the current GL context. * Returns the state of the specified capability from the current GL context.
* For the capabilities associated with extensions verifies that those * For the capabilities associated with extensions verifies that those

View File

@@ -409,7 +409,9 @@ _mesa_enable_2_1_extensions(GLcontext *ctx)
#if FEATURE_EXT_texture_sRGB #if FEATURE_EXT_texture_sRGB
ctx->Extensions.EXT_texture_sRGB = GL_TRUE; ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
#endif #endif
/* plus: shading language extensions, non-square uniform matrices */ #ifdef FEATURE_ARB_shading_language_120
ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
#endif
} }

View File

@@ -1,6 +1,6 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.5 * Version: 6.5.3
* *
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
* *
@@ -44,7 +44,7 @@ _mesa_ShadeModel( GLenum mode )
_mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode));
if (mode != GL_FLAT && mode != GL_SMOOTH) { if (mode != GL_FLAT && mode != GL_SMOOTH) {
_mesa_error( ctx, GL_INVALID_ENUM, "glShadeModel" ); _mesa_error(ctx, GL_INVALID_ENUM, "glShadeModel");
return; return;
} }
@@ -53,9 +53,8 @@ _mesa_ShadeModel( GLenum mode )
FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.ShadeModel = mode; ctx->Light.ShadeModel = mode;
ctx->_TriangleCaps ^= DD_FLATSHADE;
if (ctx->Driver.ShadeModel) if (ctx->Driver.ShadeModel)
(*ctx->Driver.ShadeModel)( ctx, mode ); ctx->Driver.ShadeModel( ctx, mode );
} }
@@ -442,11 +441,6 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
return; return;
FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Model.TwoSide = newbool; ctx->Light.Model.TwoSide = newbool;
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
else
ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
break; break;
case GL_LIGHT_MODEL_COLOR_CONTROL: case GL_LIGHT_MODEL_COLOR_CONTROL:
if (params[0] == (GLfloat) GL_SINGLE_COLOR) if (params[0] == (GLfloat) GL_SINGLE_COLOR)
@@ -728,7 +722,7 @@ _mesa_ColorMaterial( GLenum face, GLenum mode )
} }
if (ctx->Driver.ColorMaterial) if (ctx->Driver.ColorMaterial)
(*ctx->Driver.ColorMaterial)( ctx, face, mode ); ctx->Driver.ColorMaterial( ctx, face, mode );
} }

View File

@@ -1,13 +1,8 @@
/**
* \file lines.c
* Line operations.
*/
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 5.1 * Version: 6.5.3
* *
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -43,12 +38,6 @@
* \param width line width in pixels. * \param width line width in pixels.
* *
* \sa glLineWidth(). * \sa glLineWidth().
*
* Verifies the parameter and updates gl_line_attrib::Width. On a change,
* flushes the vertices, updates the clamped line width and marks the
* DD_LINE_WIDTH flag in __GLcontextRec::_TriangleCaps for the drivers if the
* width is different from one. Notifies the driver via the
* dd_function_table::LineWidth callback.
*/ */
void GLAPIENTRY void GLAPIENTRY
_mesa_LineWidth( GLfloat width ) _mesa_LineWidth( GLfloat width )
@@ -70,14 +59,8 @@ _mesa_LineWidth( GLfloat width )
ctx->Const.MinLineWidth, ctx->Const.MinLineWidth,
ctx->Const.MaxLineWidth); ctx->Const.MaxLineWidth);
if (width != 1.0)
ctx->_TriangleCaps |= DD_LINE_WIDTH;
else
ctx->_TriangleCaps &= ~DD_LINE_WIDTH;
if (ctx->Driver.LineWidth) if (ctx->Driver.LineWidth)
(*ctx->Driver.LineWidth)(ctx, width); ctx->Driver.LineWidth(ctx, width);
} }

View File

@@ -5,9 +5,9 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.5 * Version: 6.5.1
* *
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -244,19 +244,9 @@ _mesa_update_point(GLcontext *ctx)
ctx->Point.MinSize, ctx->Point.MinSize,
ctx->Point.MaxSize); ctx->Point.MaxSize);
if (ctx->Point._Size == 1.0F)
ctx->_TriangleCaps &= ~DD_POINT_SIZE;
else
ctx->_TriangleCaps |= DD_POINT_SIZE;
ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
ctx->Point.Params[1] != 0.0 || ctx->Point.Params[1] != 0.0 ||
ctx->Point.Params[2] != 0.0); ctx->Point.Params[2] != 0.0);
if (ctx->Point._Attenuated)
ctx->_TriangleCaps |= DD_POINT_ATTEN;
else
ctx->_TriangleCaps &= ~DD_POINT_ATTEN;
} }

View File

@@ -5,9 +5,9 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.3 * Version: 6.5.1
* *
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -166,14 +166,6 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
_mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
return; return;
} }
ctx->_TriangleCaps &= ~DD_TRI_UNFILLED;
if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL)
ctx->_TriangleCaps |= DD_TRI_UNFILLED;
if (ctx->Driver.PolygonMode) {
(*ctx->Driver.PolygonMode)( ctx, face, mode );
}
} }
#if _HAVE_FULL_GL #if _HAVE_FULL_GL
@@ -320,32 +312,6 @@ _mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
#endif #endif
/**********************************************************************/
/** \name State Management */
/*@{*/
/*
* Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
* in ctx->_TriangleCaps if needed.
*/
void _mesa_update_polygon( GLcontext *ctx )
{
ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET);
if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
/* Any Polygon offsets enabled? */
if (ctx->Polygon.OffsetPoint ||
ctx->Polygon.OffsetLine ||
ctx->Polygon.OffsetFill) {
ctx->_TriangleCaps |= DD_TRI_OFFSET;
}
}
/*@}*/
/**********************************************************************/ /**********************************************************************/
/** \name Initialization */ /** \name Initialization */
/*@{*/ /*@{*/

View File

@@ -5,9 +5,9 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.3 * Version: 6.5.1
* *
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -60,9 +60,6 @@ _mesa_PolygonStipple( const GLubyte *mask );
extern void GLAPIENTRY extern void GLAPIENTRY
_mesa_GetPolygonStipple( GLubyte *mask ); _mesa_GetPolygonStipple( GLubyte *mask );
extern void
_mesa_update_polygon( GLcontext *ctx );
extern void extern void
_mesa_init_polygon( GLcontext * ctx ); _mesa_init_polygon( GLcontext * ctx );

View File

@@ -821,16 +821,6 @@ _mesa_init_exec_table(struct _glapi_table *exec)
/*@{*/ /*@{*/
static void
update_separate_specular( GLcontext *ctx )
{
if (NEED_SECONDARY_COLOR(ctx))
ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
else
ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
}
/** /**
* Update state dependent on vertex arrays. * Update state dependent on vertex arrays.
*/ */
@@ -1014,16 +1004,88 @@ update_color(GLcontext *ctx)
/** /**
* If __GLcontextRec::NewState is non-zero then this function \b must be called * Update the ctx->_TriangleCaps bitfield.
* before rendering any primitive. Basically, function pointers and * XXX that bitfield should really go away someday!
* miscellaneous flags are updated to reflect the current state of the state * This function must be called after other update_*() functions since
* machine. * there are dependencies on some other derived values.
*/
static void
update_tricaps(GLcontext *ctx, GLbitfield new_state)
{
ctx->_TriangleCaps = 0;
/*
* Points
*/
if (new_state & _NEW_POINT) {
if (ctx->Point.SmoothFlag)
ctx->_TriangleCaps |= DD_POINT_SMOOTH;
if (ctx->Point._Size != 1.0F)
ctx->_TriangleCaps |= DD_POINT_SIZE;
if (ctx->Point._Attenuated)
ctx->_TriangleCaps |= DD_POINT_ATTEN;
}
/*
* Lines
*/
if (new_state & _NEW_LINE) {
if (ctx->Line.SmoothFlag)
ctx->_TriangleCaps |= DD_LINE_SMOOTH;
if (ctx->Line.StippleFlag)
ctx->_TriangleCaps |= DD_LINE_STIPPLE;
if (ctx->Line._Width != 1.0)
ctx->_TriangleCaps |= DD_LINE_WIDTH;
}
/*
* Polygons
*/
if (new_state & _NEW_POLYGON) {
if (ctx->Polygon.SmoothFlag)
ctx->_TriangleCaps |= DD_TRI_SMOOTH;
if (ctx->Polygon.StippleFlag)
ctx->_TriangleCaps |= DD_TRI_STIPPLE;
if (ctx->Polygon.FrontMode != GL_FILL
|| ctx->Polygon.BackMode != GL_FILL)
ctx->_TriangleCaps |= DD_TRI_UNFILLED;
if (ctx->Polygon.CullFlag
&& ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
if (ctx->Polygon.OffsetPoint ||
ctx->Polygon.OffsetLine ||
ctx->Polygon.OffsetFill)
ctx->_TriangleCaps |= DD_TRI_OFFSET;
}
/*
* Lighting and shading
*/
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
if (ctx->Light.ShadeModel == GL_FLAT)
ctx->_TriangleCaps |= DD_FLATSHADE;
if (NEED_SECONDARY_COLOR(ctx))
ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
/*
* Stencil
*/
if (ctx->Stencil._TestTwoSide)
ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
}
/**
* Compute derived GL state.
* If __GLcontextRec::NewState is non-zero then this function \b must
* be called before rendering anything.
* *
* Calls dd_function_table::UpdateState to perform any internal state * Calls dd_function_table::UpdateState to perform any internal state
* management necessary. * management necessary.
* *
* \sa _mesa_update_modelview_project(), _mesa_update_texture(), * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
* _mesa_update_buffer_bounds(), _mesa_update_polygon(), * _mesa_update_buffer_bounds(),
* _mesa_update_lighting() and _mesa_update_tnl_spaces(). * _mesa_update_lighting() and _mesa_update_tnl_spaces().
*/ */
void void
@@ -1052,9 +1114,6 @@ _mesa_update_state_locked( GLcontext *ctx )
if (new_state & _NEW_POINT) if (new_state & _NEW_POINT)
_mesa_update_point( ctx ); _mesa_update_point( ctx );
if (new_state & _NEW_POLYGON)
_mesa_update_polygon( ctx );
if (new_state & _NEW_LIGHT) if (new_state & _NEW_LIGHT)
_mesa_update_lighting( ctx ); _mesa_update_lighting( ctx );
@@ -1064,9 +1123,6 @@ _mesa_update_state_locked( GLcontext *ctx )
if (new_state & _IMAGE_NEW_TRANSFER_STATE) if (new_state & _IMAGE_NEW_TRANSFER_STATE)
_mesa_update_pixel( ctx, new_state ); _mesa_update_pixel( ctx, new_state );
if (new_state & _DD_NEW_SEPARATE_SPECULAR)
update_separate_specular( ctx );
if (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
update_arrays( ctx ); update_arrays( ctx );
@@ -1076,6 +1132,10 @@ _mesa_update_state_locked( GLcontext *ctx )
if (new_state & _NEW_COLOR) if (new_state & _NEW_COLOR)
update_color( ctx ); update_color( ctx );
if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
| _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
update_tricaps( ctx, new_state );
if (ctx->_MaintainTexEnvProgram) { if (ctx->_MaintainTexEnvProgram) {
if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG)) if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
_mesa_UpdateTexEnvProgram(ctx); _mesa_UpdateTexEnvProgram(ctx);
@@ -1122,3 +1182,5 @@ _mesa_update_state( GLcontext *ctx )
/*@}*/ /*@}*/