diff options
-rw-r--r-- | src/mesa/main/mtypes.h | 4 | ||||
-rw-r--r-- | src/mesa/main/state.c | 9 | ||||
-rw-r--r-- | src/mesa/main/texenvprogram.c | 11 |
3 files changed, 19 insertions, 5 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 832166d2c07..374f1c85a26 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2784,8 +2784,8 @@ struct __GLcontextRec struct gl_fragment_program_state FragmentProgram; /**< GL_NV_fragment_program */ struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */ - struct fragment_program _TexEnvProgram; /**< Texture state as fragment program */ - struct vertex_program _TnlProgram; /**< Fixed func TNL state as vertex program */ + struct fragment_program *_TexEnvProgram; /**< Texture state as fragment program */ + struct vertex_program *_TnlProgram; /**< Fixed func TNL state as vertex program */ GLboolean _MaintainTexEnvProgram; GLboolean _MaintainTnlProgram; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 561f5763a20..13b6a7d80c4 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -90,6 +90,7 @@ #include "nvfragprog.h" #include "nvprogram.h" #include "program.h" +#include "texenvprogram.h" #endif #if FEATURE_ARB_shader_objects #include "shaderobjects.h" @@ -939,7 +940,11 @@ update_program(GLcontext *ctx) ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled; if (ctx->_MaintainTexEnvProgram && !ctx->FragmentProgram._Enabled) { - ctx->FragmentProgram._Current = &ctx->_TexEnvProgram; + if (!ctx->_TexEnvProgram) + ctx->_TexEnvProgram = (struct fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); + + ctx->FragmentProgram._Current = ctx->_TexEnvProgram; ctx->FragmentProgram._Active = GL_TRUE; } } @@ -997,7 +1002,7 @@ _mesa_update_state( GLcontext *ctx ) update_arrays( ctx ); if (ctx->_MaintainTexEnvProgram) { - if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR)) + if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG)) _mesa_UpdateTexEnvProgram(ctx); } diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 187526e6775..efc406b72a3 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -651,14 +651,19 @@ void _mesa_UpdateTexEnvProgram( GLcontext *ctx ) if (ctx->FragmentProgram._Enabled) return; + if (!ctx->_TexEnvProgram) + ctx->_TexEnvProgram = (struct fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); + p.ctx = ctx; - p.program = &ctx->_TexEnvProgram; + p.program = ctx->_TexEnvProgram; if (p.program->Instructions == NULL) { p.program->Instructions = MALLOC(sizeof(struct fp_instruction) * 100); } p.program->Base.NumInstructions = 0; + p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; p.program->NumTexIndirections = 1; /* correct? */ p.program->NumTexInstructions = 0; p.program->NumAluInstructions = 0; @@ -702,6 +707,10 @@ void _mesa_UpdateTexEnvProgram( GLcontext *ctx ) */ emit_arith( &p, FP_OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef); + if (ctx->Fog.Enabled) + p.program->FogOption = ctx->Fog.Mode; + else + p.program->FogOption = GL_NONE; if (p.program->NumTexIndirections > ctx->Const.MaxFragmentProgramTexIndirections) program_error(&p, "Exceeded max nr indirect texture lookups"); |