wined3d: Move material applying to the state table.
This commit is contained in:
parent
dfeb40cbff
commit
9b4920996e
@ -90,37 +90,6 @@ static DWORD primitiveToGl(WINED3DPRIMITIVETYPE PrimitiveType,
|
||||
return NumVertexes;
|
||||
}
|
||||
|
||||
/* Ensure the appropriate material states are set up - only change
|
||||
state if really required */
|
||||
static void init_materials(IWineD3DDevice *iface, BOOL isDiffuseSupplied) {
|
||||
|
||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
|
||||
if (This->tracking_color == NEEDS_TRACKING && isDiffuseSupplied) {
|
||||
/* If we have not set up the material color tracking, do it now as required */
|
||||
glDisable(GL_COLOR_MATERIAL); /* Note: Man pages state must enable AFTER calling glColorMaterial! Required?*/
|
||||
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
||||
TRACE("glColorMaterial Parm=%x\n", This->tracking_parm);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, This->tracking_parm);
|
||||
checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
checkGLcall("glEnable GL_COLOR_MATERIAL");
|
||||
This->tracking_color = IS_TRACKING;
|
||||
} else if ((This->tracking_color == IS_TRACKING && !isDiffuseSupplied) ||
|
||||
(This->tracking_color == NEEDS_TRACKING && !isDiffuseSupplied)) {
|
||||
/* If we are tracking the current color but one isn't supplied, don't! */
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
||||
This->tracking_color = NEEDS_TRACKING;
|
||||
} else if (This->tracking_color == IS_TRACKING && isDiffuseSupplied) {
|
||||
/* No need to reset material colors since no change to gl_color_material */
|
||||
} else if (This->tracking_color == NEEDS_DISABLE) {
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
||||
This->tracking_color = DISABLED_TRACKING;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL fixed_get_input(
|
||||
BYTE usage, BYTE usage_idx,
|
||||
unsigned int* regnum) {
|
||||
@ -1248,9 +1217,6 @@ void drawPrimitive(IWineD3DDevice *iface,
|
||||
}
|
||||
This->depth_copy_state = WINED3D_DCS_INITIAL;
|
||||
|
||||
/* Now initialize the materials state */
|
||||
init_materials(iface, (This->strided_streams.u.s.diffuse.lpData != NULL || This->strided_streams.u.s.diffuse.VBO != 0));
|
||||
|
||||
{
|
||||
GLenum glPrimType;
|
||||
/* Ok, Work out which primitive is requested and how many vertexes that
|
||||
|
@ -806,7 +806,18 @@ static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
||||
|
||||
/* TODO: Merge with primitive type + init_materials()!! */
|
||||
static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
||||
GLenum Parm = GL_AMBIENT_AND_DIFFUSE;
|
||||
GLenum Parm = -1;
|
||||
WineDirect3DStridedData *diffuse = &stateblock->wineD3DDevice->strided_streams.u.s.diffuse;
|
||||
BOOL isDiffuseSupplied;
|
||||
|
||||
/* Depends on the decoded vertex declaration to read the existance of diffuse data.
|
||||
* The vertex declaration will call this function if the fixed function pipeline is used.
|
||||
*/
|
||||
if(isStateDirty(stateblock->wineD3DDevice, STATE_VDECL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
isDiffuseSupplied = diffuse->lpData || diffuse->VBO;
|
||||
|
||||
if (stateblock->renderState[WINED3DRS_COLORVERTEX]) {
|
||||
TRACE("diff %d, amb %d, emis %d, spec %d\n",
|
||||
@ -827,19 +838,17 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
||||
Parm = GL_EMISSION;
|
||||
} else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) {
|
||||
Parm = GL_SPECULAR;
|
||||
} else {
|
||||
Parm = -1;
|
||||
}
|
||||
|
||||
if (Parm == -1) {
|
||||
if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
|
||||
} else {
|
||||
stateblock->wineD3DDevice->tracking_color = NEEDS_TRACKING;
|
||||
stateblock->wineD3DDevice->tracking_parm = Parm;
|
||||
}
|
||||
}
|
||||
|
||||
if(Parm == -1 || !isDiffuseSupplied) {
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
||||
} else {
|
||||
if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
|
||||
glColorMaterial(GL_FRONT_AND_BACK, Parm);
|
||||
checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
checkGLcall("glEnable(GL_COLOR_MATERIAL)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2678,6 +2687,10 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
||||
!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_VIEW))) {
|
||||
transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock);
|
||||
}
|
||||
|
||||
if(!isStateDirty(stateblock->wineD3DDevice, STATE_RENDER(WINED3DRS_COLORVERTEX))) {
|
||||
state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX), stateblock);
|
||||
}
|
||||
} else {
|
||||
/* We compile the shader here because we need the vertex declaration
|
||||
* in order to determine if we need to do any swizzling for D3DCOLOR
|
||||
|
Loading…
x
Reference in New Issue
Block a user