wined3d: Fix specular color handling for register combiners.

By default the FinalCombiner is setup to add the specular color to the
final result of the combiner operations. However, it should only do
this when the WINED3DRS_SPECULARENABLE renderstate is enabled.
This commit is contained in:
H. Verbeet 2006-07-12 00:44:15 +02:00 committed by Alexandre Julliard
parent 0dd13f2cb7
commit 7090259545
2 changed files with 31 additions and 0 deletions

View File

@ -3842,6 +3842,26 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, D
NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
running 1.4 yet!
*/
/*
* If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
* Instead, we need to setup the FinalCombiner properly.
*
* The default setup for the FinalCombiner is:
*
* <variable> <input> <mapping> <usage>
* GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
* GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
* GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
* GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
* GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
* GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
* GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
*
* That's pretty much fine as it is, except for variable B, which needs to take
* either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
* whether WINED3DRS_SPECULARENABLE is enabled or not.
*/
if (Value) {
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->updateStateBlock->material.Specular);
checkGLcall("glMaterialfv");
@ -3851,6 +3871,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, D
TRACE("Specular colors cannot be enabled in this version of opengl\n");
}
checkGLcall("glEnable(GL_COLOR_SUM)");
if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
checkGLcall("glFinalCombinerInputNV()");
}
} else {
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
@ -3865,6 +3890,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, D
TRACE("Specular colors cannot be disabled in this version of opengl\n");
}
checkGLcall("glDisable(GL_COLOR_SUM)");
if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
checkGLcall("glFinalCombinerInputNV()");
}
}
}
break;

View File

@ -1537,6 +1537,7 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC, glCombinerParameterfvNV); \
USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC, glCombinerParameteriNV); \
USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC, glCombinerParameterivNV); \
USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, glFinalCombinerInputNV); \
/* OpenGL 2.0 functions */
#define GL2_FUNCS_GEN \