Commit b081cbaf authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Emulate tracking of multiple material properties.

parent 35ee1e96
......@@ -510,6 +510,19 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
D3DCOLOR_B_G(diffuseColor),
D3DCOLOR_B_B(diffuseColor),
D3DCOLOR_B_A(diffuseColor)));
if(This->activeContext->num_untracked_materials) {
unsigned char i;
float color[4];
color[0] = D3DCOLOR_B_R(diffuseColor) / 255.0;
color[1] = D3DCOLOR_B_G(diffuseColor) / 255.0;
color[2] = D3DCOLOR_B_B(diffuseColor) / 255.0;
color[3] = D3DCOLOR_B_A(diffuseColor) / 255.0;
for(i = 0; i < This->activeContext->num_untracked_materials; i++) {
glMaterialfv(GL_FRONT_AND_BACK, This->activeContext->untracked_materials[i], color);
}
}
}
/* Specular ------------------------------- */
......@@ -1030,15 +1043,55 @@ void drawPrimitive(IWineD3DDevice *iface,
{
GLenum glPrimType;
BOOL emulation = FALSE;
WineDirect3DVertexStridedData *strided = &This->strided_streams;
WineDirect3DVertexStridedData stridedlcl;
/* Ok, Work out which primitive is requested and how many vertexes that
will be */
UINT calculatedNumberOfindices = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
if (numberOfVertices == 0 )
numberOfVertices = calculatedNumberOfindices;
if (This->useDrawStridedSlow) {
if(!This->strided_streams.u.s.position_transformed && !use_vs(This)) {
if(This->activeContext->num_untracked_materials &&
This->stateBlock->renderState[WINED3DRS_LIGHTING]) {
IWineD3DVertexBufferImpl *vb;
FIXME("Using software emulation because not all material properties could be tracked\n");
emulation = TRUE;
strided = &stridedlcl;
memcpy(&stridedlcl, &This->strided_streams, sizeof(stridedlcl));
#define FIXVBO(type) \
if(stridedlcl.u.s.type.VBO) { \
vb = (IWineD3DVertexBufferImpl *) This->stateBlock->streamSource[stridedlcl.u.s.type.streamNo]; \
stridedlcl.u.s.type.VBO = 0; \
stridedlcl.u.s.type.lpData = (BYTE *) ((unsigned long) stridedlcl.u.s.type.lpData + (unsigned long) vb->resource.allocatedMemory); \
}
FIXVBO(position);
FIXVBO(blendWeights);
FIXVBO(blendMatrixIndices);
FIXVBO(normal);
FIXVBO(pSize);
FIXVBO(diffuse);
FIXVBO(specular);
for(i = 0; i < WINED3DDP_MAXTEXCOORD; i++) FIXVBO(texCoords[i]);
FIXVBO(position2);
FIXVBO(normal2);
FIXVBO(tangent);
FIXVBO(binormal);
FIXVBO(tessFactor);
FIXVBO(fog);
FIXVBO(depth);
FIXVBO(sample);
#undef FIXVBO
}
}
if (This->useDrawStridedSlow || emulation) {
/* Immediate mode drawing */
drawStridedSlow(iface, &This->strided_streams, calculatedNumberOfindices,
drawStridedSlow(iface, strided, calculatedNumberOfindices,
glPrimType, idxData, idxSize, minIndex, StartIdx, StartVertexIndex);
} else if(This->instancedDraw) {
/* Instancing emulation with mixing immediate mode and arrays */
......
......@@ -980,6 +980,7 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
isDiffuseSupplied = diffuse->lpData || diffuse->VBO;
context->num_untracked_materials = 0;
if (isDiffuseSupplied && stateblock->renderState[WINED3DRS_COLORVERTEX]) {
TRACE("diff %d, amb %d, emis %d, spec %d\n",
stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
......@@ -993,10 +994,30 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
} else {
Parm = GL_DIFFUSE;
}
if(stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == WINED3DMCS_COLOR1) {
context->untracked_materials[context->num_untracked_materials] = GL_EMISSION;
context->num_untracked_materials++;
}
if(stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == WINED3DMCS_COLOR1) {
context->untracked_materials[context->num_untracked_materials] = GL_SPECULAR;
context->num_untracked_materials++;
}
} else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Parm = GL_AMBIENT;
if(stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == WINED3DMCS_COLOR1) {
context->untracked_materials[context->num_untracked_materials] = GL_EMISSION;
context->num_untracked_materials++;
}
if(stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == WINED3DMCS_COLOR1) {
context->untracked_materials[context->num_untracked_materials] = GL_SPECULAR;
context->num_untracked_materials++;
}
} else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Parm = GL_EMISSION;
if(stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == WINED3DMCS_COLOR1) {
context->untracked_materials[context->num_untracked_materials] = GL_SPECULAR;
context->num_untracked_materials++;
}
} else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Parm = GL_SPECULAR;
}
......
......@@ -507,6 +507,8 @@ struct WineD3DContext {
BOOL namedArraysLoaded, numberedArraysLoaded;
BOOL lastWasPow2Texture[MAX_TEXTURES];
GLenum tracking_parm; /* Which source is tracking current colour */
unsigned char num_untracked_materials;
GLenum untracked_materials[2];
BOOL last_was_blit, last_was_ckey;
char texShaderBumpMap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment