diff options
author | Brian Paul <[email protected]> | 2004-04-23 14:16:46 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2004-04-23 14:16:46 +0000 |
commit | 6d460af6af77a0d5a5b568bcd6094b98e249ba93 (patch) | |
tree | 08656028582b357d5c9730c521cc3e1770604c50 /src/mesa/main/state.c | |
parent | 384800fe12e368f3489111de4572dbc8846a7dea (diff) |
Added ctx->Vertex/FragmentProgram._Enable flags. Set when vertex/fragment
program is enabled AND the currently bound program is valid.
Check _Enable instead of Enable to prevent things from blowing up
when someone calls glEnable(GL_VERTEX_PROGRAM_ARB) without actually
defining a program.
Diffstat (limited to 'src/mesa/main/state.c')
-rw-r--r-- | src/mesa/main/state.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index b8a67d0ee38..c894241a739 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,11 +1,3 @@ -/** - * \file state.c - * State management. - * - * This file manages recalculation of derived values in the __GLcontextRec. - * Also, this is where we initialize the API dispatch table. - */ - /* * Mesa 3-D graphics library * Version: 6.1 @@ -31,6 +23,14 @@ */ +/** + * \file state.c + * State management. + * + * This file manages recalculation of derived values in the __GLcontextRec. + * Also, this is where we initialize the API dispatch table. + */ + #include "glheader.h" #include "accum.h" #include "api_loopback.h" @@ -762,7 +762,7 @@ update_arrays( GLcontext *ctx ) /* find min of _MaxElement values for all enabled arrays */ /* 0 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) { min = ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement; } @@ -775,14 +775,14 @@ update_arrays( GLcontext *ctx ) } /* 1 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement); } /* no conventional vertex weight array */ /* 2 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement); } @@ -791,7 +791,7 @@ update_arrays( GLcontext *ctx ) } /* 3 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement); } @@ -800,7 +800,7 @@ update_arrays( GLcontext *ctx ) } /* 4 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement); } @@ -809,7 +809,7 @@ update_arrays( GLcontext *ctx ) } /* 5 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]._MaxElement); } @@ -818,20 +818,20 @@ update_arrays( GLcontext *ctx ) } /* 6 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_SIX].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SIX]._MaxElement); } /* 7 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement); } /* 8..15 */ for (i = VERT_ATTRIB_TEX0; i < VERT_ATTRIB_MAX; i++) { - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[i].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement); } @@ -854,6 +854,22 @@ update_arrays( GLcontext *ctx ) } +/** + * Update derived vertex/fragment program state. + */ +static void +update_program(GLcontext *ctx) +{ + /* For now, just set the _Enabled (really enabled) flags. + * In the future we may have to check other state to be sure we really + * have a runable program or shader. + */ + ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled + && ctx->VertexProgram.Current->Instructions; + ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled + && ctx->FragmentProgram.Current->Instructions; +} + /* * If __GLcontextRec::NewState is non-zero then this function \b must be called @@ -875,6 +891,9 @@ void _mesa_update_state( GLcontext *ctx ) if (MESA_VERBOSE & VERBOSE_STATE) _mesa_print_state("_mesa_update_state", new_state); + if (new_state & _NEW_PROGRAM) + update_program( ctx ); + if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) _mesa_update_modelview_project( ctx, new_state ); |