wined3d: Move the material to wined3d_state.
This commit is contained in:
parent
cde699b286
commit
5f6ced2767
dlls/wined3d
|
@ -2873,7 +2873,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONS
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
|
|
||||||
This->updateStateBlock->changed.material = TRUE;
|
This->updateStateBlock->changed.material = TRUE;
|
||||||
This->updateStateBlock->material = *pMaterial;
|
This->updateStateBlock->state.material = *pMaterial;
|
||||||
|
|
||||||
/* Handle recording of state blocks */
|
/* Handle recording of state blocks */
|
||||||
if (This->isRecordingState) {
|
if (This->isRecordingState) {
|
||||||
|
@ -2887,7 +2887,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONS
|
||||||
|
|
||||||
static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL* pMaterial) {
|
static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL* pMaterial) {
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
*pMaterial = This->updateStateBlock->material;
|
*pMaterial = This->updateStateBlock->state.material;
|
||||||
TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
|
TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
|
||||||
pMaterial->Diffuse.b, pMaterial->Diffuse.a);
|
pMaterial->Diffuse.b, pMaterial->Diffuse.a);
|
||||||
TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
|
TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
|
||||||
|
|
|
@ -716,10 +716,10 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock
|
||||||
TRACE("Setting specular enable state and materials\n");
|
TRACE("Setting specular enable state and materials\n");
|
||||||
if (stateblock->state.render_states[WINED3DRS_SPECULARENABLE])
|
if (stateblock->state.render_states[WINED3DRS_SPECULARENABLE])
|
||||||
{
|
{
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float *)&stateblock->state.material.Specular);
|
||||||
checkGLcall("glMaterialfv");
|
checkGLcall("glMaterialfv");
|
||||||
|
|
||||||
if (stateblock->material.Power > gl_info->limits.shininess)
|
if (stateblock->state.material.Power > gl_info->limits.shininess)
|
||||||
{
|
{
|
||||||
/* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
|
/* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
|
||||||
* and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
|
* and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
|
||||||
|
@ -727,10 +727,12 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock
|
||||||
* value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
|
* value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
|
||||||
* them, it should be safe to do so without major visual distortions.
|
* them, it should be safe to do so without major visual distortions.
|
||||||
*/
|
*/
|
||||||
WARN("Material power = %f, limit %f\n", stateblock->material.Power, gl_info->limits.shininess);
|
WARN("Material power = %f, limit %f\n", stateblock->state.material.Power, gl_info->limits.shininess);
|
||||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, gl_info->limits.shininess);
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, gl_info->limits.shininess);
|
||||||
} else {
|
}
|
||||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->material.Power);
|
else
|
||||||
|
{
|
||||||
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->state.material.Power);
|
||||||
}
|
}
|
||||||
checkGLcall("glMaterialf(GL_SHININESS)");
|
checkGLcall("glMaterialf(GL_SHININESS)");
|
||||||
|
|
||||||
|
@ -775,23 +777,23 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("(%p) : Diffuse {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
TRACE("(%p) : Diffuse {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
||||||
stateblock->material.Diffuse.r, stateblock->material.Diffuse.g,
|
stateblock->state.material.Diffuse.r, stateblock->state.material.Diffuse.g,
|
||||||
stateblock->material.Diffuse.b, stateblock->material.Diffuse.a);
|
stateblock->state.material.Diffuse.b, stateblock->state.material.Diffuse.a);
|
||||||
TRACE("(%p) : Ambient {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
TRACE("(%p) : Ambient {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
||||||
stateblock->material.Ambient.r, stateblock->material.Ambient.g,
|
stateblock->state.material.Ambient.r, stateblock->state.material.Ambient.g,
|
||||||
stateblock->material.Ambient.b, stateblock->material.Ambient.a);
|
stateblock->state.material.Ambient.b, stateblock->state.material.Ambient.a);
|
||||||
TRACE("(%p) : Specular {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
TRACE("(%p) : Specular {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
||||||
stateblock->material.Specular.r, stateblock->material.Specular.g,
|
stateblock->state.material.Specular.r, stateblock->state.material.Specular.g,
|
||||||
stateblock->material.Specular.b, stateblock->material.Specular.a);
|
stateblock->state.material.Specular.b, stateblock->state.material.Specular.a);
|
||||||
TRACE("(%p) : Emissive {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
TRACE("(%p) : Emissive {%.8e, %.8e, %.8e, %.8e}\n", stateblock->device,
|
||||||
stateblock->material.Emissive.r, stateblock->material.Emissive.g,
|
stateblock->state.material.Emissive.r, stateblock->state.material.Emissive.g,
|
||||||
stateblock->material.Emissive.b, stateblock->material.Emissive.a);
|
stateblock->state.material.Emissive.b, stateblock->state.material.Emissive.a);
|
||||||
|
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*) &stateblock->material.Ambient);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float *)&stateblock->state.material.Ambient);
|
||||||
checkGLcall("glMaterialfv(GL_AMBIENT)");
|
checkGLcall("glMaterialfv(GL_AMBIENT)");
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*) &stateblock->material.Diffuse);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float *)&stateblock->state.material.Diffuse);
|
||||||
checkGLcall("glMaterialfv(GL_DIFFUSE)");
|
checkGLcall("glMaterialfv(GL_DIFFUSE)");
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*) &stateblock->material.Emissive);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float *)&stateblock->state.material.Emissive);
|
||||||
checkGLcall("glMaterialfv(GL_EMISSION)");
|
checkGLcall("glMaterialfv(GL_EMISSION)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,23 +1319,23 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
|
||||||
* tracking with glColorMaterial, so apply those here. */
|
* tracking with glColorMaterial, so apply those here. */
|
||||||
switch (context->tracking_parm) {
|
switch (context->tracking_parm) {
|
||||||
case GL_AMBIENT_AND_DIFFUSE:
|
case GL_AMBIENT_AND_DIFFUSE:
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float *)&device->updateStateBlock->state.material.Ambient);
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float *)&device->updateStateBlock->state.material.Diffuse);
|
||||||
checkGLcall("glMaterialfv");
|
checkGLcall("glMaterialfv");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_DIFFUSE:
|
case GL_DIFFUSE:
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float *)&device->updateStateBlock->state.material.Diffuse);
|
||||||
checkGLcall("glMaterialfv");
|
checkGLcall("glMaterialfv");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_AMBIENT:
|
case GL_AMBIENT:
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float *)&device->updateStateBlock->state.material.Ambient);
|
||||||
checkGLcall("glMaterialfv");
|
checkGLcall("glMaterialfv");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_EMISSION:
|
case GL_EMISSION:
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*)&device->updateStateBlock->material.Emissive);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float *)&device->updateStateBlock->state.material.Emissive);
|
||||||
checkGLcall("glMaterialfv");
|
checkGLcall("glMaterialfv");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1341,7 +1343,8 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
|
||||||
/* Only change material color if specular is enabled, otherwise it is set to black */
|
/* Only change material color if specular is enabled, otherwise it is set to black */
|
||||||
if (device->stateBlock->state.render_states[WINED3DRS_SPECULARENABLE])
|
if (device->stateBlock->state.render_states[WINED3DRS_SPECULARENABLE])
|
||||||
{
|
{
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*)&device->updateStateBlock->material.Specular);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,
|
||||||
|
(float *)&device->updateStateBlock->state.material.Specular);
|
||||||
checkGLcall("glMaterialfv");
|
checkGLcall("glMaterialfv");
|
||||||
} else {
|
} else {
|
||||||
static const GLfloat black[] = {0.0f, 0.0f, 0.0f, 0.0f};
|
static const GLfloat black[] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
|
|
@ -739,12 +739,12 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
||||||
This->vertexDecl = targetStateBlock->vertexDecl;
|
This->vertexDecl = targetStateBlock->vertexDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (This->changed.material
|
if (This->changed.material && memcmp(&targetStateBlock->state.material,
|
||||||
&& memcmp(&targetStateBlock->material, &This->material, sizeof(This->material)))
|
&This->state.material, sizeof(This->state.material)))
|
||||||
{
|
{
|
||||||
TRACE("Updating material.\n");
|
TRACE("Updating material.\n");
|
||||||
|
|
||||||
This->material = targetStateBlock->material;
|
This->state.material = targetStateBlock->state.material;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (This->changed.viewport && memcmp(&targetStateBlock->state.viewport,
|
if (This->changed.viewport && memcmp(&targetStateBlock->state.viewport,
|
||||||
|
@ -990,7 +990,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
|
||||||
|
|
||||||
if (This->changed.material)
|
if (This->changed.material)
|
||||||
{
|
{
|
||||||
IWineD3DDevice_SetMaterial(device, &This->material);
|
IWineD3DDevice_SetMaterial(device, &This->state.material);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (This->changed.viewport)
|
if (This->changed.viewport)
|
||||||
|
|
|
@ -2349,6 +2349,7 @@ struct wined3d_stream_state
|
||||||
|
|
||||||
struct wined3d_state
|
struct wined3d_state
|
||||||
{
|
{
|
||||||
|
WINED3DMATERIAL material;
|
||||||
WINED3DVIEWPORT viewport;
|
WINED3DVIEWPORT viewport;
|
||||||
RECT scissor_rect;
|
RECT scissor_rect;
|
||||||
|
|
||||||
|
@ -2405,9 +2406,6 @@ struct IWineD3DStateBlockImpl
|
||||||
double clipplane[MAX_CLIPPLANES][4];
|
double clipplane[MAX_CLIPPLANES][4];
|
||||||
WINED3DCLIPSTATUS clip_status;
|
WINED3DCLIPSTATUS clip_status;
|
||||||
|
|
||||||
/* Material */
|
|
||||||
WINED3DMATERIAL material;
|
|
||||||
|
|
||||||
/* Pixel Shader */
|
/* Pixel Shader */
|
||||||
IWineD3DPixelShader *pixelShader;
|
IWineD3DPixelShader *pixelShader;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue