Fix quite a few texturing problems and cases where text isn't being

correctly displated.
This commit is contained in:
Oliver Stieber 2005-08-22 10:07:10 +00:00 committed by Alexandre Julliard
parent 4c9f013f8b
commit 3f24b9164d
4 changed files with 44 additions and 145 deletions

View File

@ -283,7 +283,7 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
} else {
glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
glBindTexture(textureDimensions, This->baseTexture.textureName);
checkGLcall("glBindTexture");
@ -294,11 +294,7 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
} else {
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
}
}
} else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n");

View File

@ -3382,6 +3382,8 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, DWORD S
}
TRACE("Setting sampler %ld %d to %ld \n", Sampler, Type, Value);
This->updateStateBlock->samplerState[Sampler][Type] = Value;
This->updateStateBlock->set.samplerState[Sampler][Type] = Value;
This->updateStateBlock->changed.samplerState[Sampler][Type] = Value;
/* Handle recording of state blocks */
if (This->isRecordingState) {
@ -3703,131 +3705,20 @@ static void WINAPI IWineD3DDeviceImpl_ApplyTextureUnitState(IWineD3DDevice *ifac
switch (Type) {
case WINED3DTSS_ALPHAOP :
case WINED3DTSS_COLOROP :
{
if ((Value == D3DTOP_DISABLE) && (Type == WINED3DTSS_COLOROP)) {
/* TODO: Disable by making this and all later levels disabled */
glDisable(GL_TEXTURE_1D);
checkGLcall("Disable GL_TEXTURE_1D");
glDisable(GL_TEXTURE_2D);
checkGLcall("Disable GL_TEXTURE_2D");
glDisable(GL_TEXTURE_3D);
checkGLcall("Disable GL_TEXTURE_3D");
break; /* Don't bother setting the texture operations */
} else {
/* Enable only the appropriate texture dimension */
if (Type == WINED3DTSS_COLOROP) {
if (This->stateBlock->textureDimensions[Stage] == GL_TEXTURE_1D) {
glEnable(GL_TEXTURE_1D);
checkGLcall("Enable GL_TEXTURE_1D");
} else {
glDisable(GL_TEXTURE_1D);
checkGLcall("Disable GL_TEXTURE_1D");
}
if (This->stateBlock->textureDimensions[Stage] == GL_TEXTURE_2D) {
if (GL_SUPPORT(NV_TEXTURE_SHADER) && This->texture_shader_active) {
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
checkGLcall("Enable GL_TEXTURE_2D");
} else {
glEnable(GL_TEXTURE_2D);
checkGLcall("Enable GL_TEXTURE_2D");
}
} else {
glDisable(GL_TEXTURE_2D);
checkGLcall("Disable GL_TEXTURE_2D");
}
if (This->stateBlock->textureDimensions[Stage] == GL_TEXTURE_3D) {
glEnable(GL_TEXTURE_3D);
checkGLcall("Enable GL_TEXTURE_3D");
} else {
glDisable(GL_TEXTURE_3D);
checkGLcall("Disable GL_TEXTURE_3D");
}
if (This->stateBlock->textureDimensions[Stage] == GL_TEXTURE_CUBE_MAP_ARB) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("Enable GL_TEXTURE_CUBE_MAP");
} else {
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("Disable GL_TEXTURE_CUBE_MAP");
}
}
}
/* Drop through... (Except disable case) */
case WINED3DTSS_COLORARG0 :
case WINED3DTSS_COLORARG1 :
case WINED3DTSS_COLORARG2 :
case WINED3DTSS_ALPHAARG0 :
case WINED3DTSS_ALPHAARG1 :
case WINED3DTSS_ALPHAARG2 :
{
BOOL isAlphaArg = (Type == WINED3DTSS_ALPHAOP || Type == WINED3DTSS_ALPHAARG1 ||
Type == WINED3DTSS_ALPHAARG2 || Type == WINED3DTSS_ALPHAARG0);
if (isAlphaArg) {
set_tex_op(iface, TRUE, Stage, This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAOP],
This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAARG1],
This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAARG2],
This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAARG0]);
} else {
set_tex_op(iface, FALSE, Stage, This->stateBlock->textureState[Stage][WINED3DTSS_COLOROP],
This->stateBlock->textureState[Stage][WINED3DTSS_COLORARG1],
This->stateBlock->textureState[Stage][WINED3DTSS_COLORARG2],
This->stateBlock->textureState[Stage][WINED3DTSS_COLORARG0]);
}
}
break;
}
case WINED3DTSS_ADDRESSW :
{
GLint wrapParm = GL_REPEAT;
switch (Value) {
case D3DTADDRESS_WRAP: wrapParm = GL_REPEAT; break;
case D3DTADDRESS_CLAMP: wrapParm = GL_CLAMP_TO_EDGE; break;
case D3DTADDRESS_BORDER:
{
if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
wrapParm = GL_CLAMP_TO_BORDER_ARB;
} else {
/* FIXME: Not right, but better */
FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
wrapParm = GL_REPEAT;
}
}
break;
case D3DTADDRESS_MIRROR:
{
if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
wrapParm = GL_MIRRORED_REPEAT_ARB;
} else {
/* Unsupported in OpenGL pre-1.4 */
FIXME("Unsupported D3DTADDRESS_MIRROR (needs GL_ARB_texture_mirrored_repeat) state %d\n", Type);
wrapParm = GL_REPEAT;
}
}
break;
case D3DTADDRESS_MIRRORONCE:
{
if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
wrapParm = GL_MIRROR_CLAMP_TO_EDGE_ATI;
} else {
FIXME("Unsupported D3DTADDRESS_MIRRORONCE (needs GL_ATI_texture_mirror_once) state %d\n", Type);
wrapParm = GL_REPEAT;
}
}
break;
default:
FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
wrapParm = GL_REPEAT;
}
TRACE("Setting WRAP_R to %d for %x\n", wrapParm, This->stateBlock->textureDimensions[Stage]);
glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_WRAP_R, wrapParm);
checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_R, wrapParm)");
}
/* nothing to do as moved to drawprim for now */
break;
case WINED3DTSS_ADDRESSW :
#if 0 /* I'm not sure what D3D does about ADDRESSW appearing twice */
if (Value < minLookup[WINELOOKUP_WARPPARAM] || Value > maxLookup[WINELOOKUP_WARPPARAM]) {
FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
} else {
GLint wrapParm = stateLookup[WINELOOKUP_WARPPARAM][Value - minLookup[WINELOOKUP_WARPPARAM]];
TRACE("Setting WRAP_R to %d for %x\n", wrapParm, This->stateBlock->textureDimensions[Stage]);
glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_WRAP_R, wrapParm);
checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_R, wrapParm)");
}
#endif
case WINED3DTSS_TEXCOORDINDEX :
{
/* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive */
@ -4025,6 +3916,8 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DW
return D3DERR_INVALIDCALL;
}
This->updateStateBlock->changed.textureState[Stage][Type] = TRUE;
This->updateStateBlock->set.textureState[Stage][Type] = TRUE;
This->updateStateBlock->textureState[Stage][Type] = Value;
return D3D_OK;

View File

@ -286,12 +286,14 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
for (j = 0; j < GL_LIMITS(textures); j++) {
/* TODO: move over to using memcpy */
for (i = 1; i <= WINED3D_HIGHEST_TEXTURE_STATE ; i++) {
TRACE("Updating texturestagestate %d,%d to %ld (was %ld)\n", j,i, targetStateBlock->textureState[j][i],
This->textureState[j][i]);
This->textureState[j][i] = targetStateBlock->textureState[j][i];
if (This->set.textureState[j][i]) {
TRACE("Updating texturestagestate %d,%d to %ld (was %ld)\n", j,i, targetStateBlock->textureState[j][i],
This->textureState[j][i]);
This->textureState[j][i] = targetStateBlock->textureState[j][i];
}
}
if ((This->set.textures[j] && (This->textures[j] != targetStateBlock->textures[j]))) {
if (This->set.textures[j]) {
TRACE("Updating texture %d to %p (was %p)\n", j, targetStateBlock->textures[j], This->textures[j]);
This->textures[j] = targetStateBlock->textures[j];
}
@ -302,10 +304,12 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
/* TODO: move over to using memcpy */
for (j = 0 ; j < GL_LIMITS(samplers); j++){
for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE ; i++){ /* States are 1 based */
TRACE("Updating sampler state %d,%d to %ld (was %ld)\n",
j, i, targetStateBlock->samplerState[j][i],
This->samplerState[j][i]);
This->samplerState[j][i] = targetStateBlock->samplerState[j][i];
if (This->set.samplerState[j][i]) {
TRACE("Updating sampler state %d,%d to %ld (was %ld)\n",
j, i, targetStateBlock->samplerState[j][i],
This->samplerState[j][i]);
This->samplerState[j][i] = targetStateBlock->samplerState[j][i];
}
}
}
}
@ -330,7 +334,7 @@ should really perform a delta so that only the changes get updated*/
/* FIXME: Only apply applicable states not all states */
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */This->blockType == WINED3DSBT_INIT || This->blockType == D3DSBT_ALL || This->blockType == D3DSBT_VERTEXSTATE) {
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */This->blockType == WINED3DSBT_INIT || This->blockType == WINED3DSBT_ALL || This->blockType == WINED3DSBT_VERTEXSTATE) {
PLIGHTINFOEL *toDo = This->lights;
@ -373,7 +377,7 @@ should really perform a delta so that only the changes get updated*/
IWineD3DDevice_SetSoftwareVertexProcessing(pDevice, This->softwareVertexProcessing);
/* Others + Render & Texture */
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */ This->blockType == D3DSBT_ALL) {
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */ This->blockType == WINED3DSBT_ALL || This->blockType == WINED3DSBT_INIT) {
for (i = 1; i <= HIGHEST_TRANSFORMSTATE; i++) {
if (This->set.transform[i] && This->changed.transform[i])
IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]);
@ -423,7 +427,11 @@ should really perform a delta so that only the changes get updated*/
}
/* TODO: move over to memcpy */
for (i = 1; i <= WINED3D_HIGHEST_TEXTURE_STATE; i++) {
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[j][i] = This->textureState[j][i];
if (This->set.textureState[j][i] && This->changed.textureState[j][i]) { /* tb_dx9_10 failes without this test */
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[j][i] = This->textureState[j][i];
((IWineD3DDeviceImpl *)pDevice)->stateBlock->set.textureState[j][i] = TRUE;
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[j][i] = TRUE;
}
}
}
@ -431,12 +439,16 @@ should really perform a delta so that only the changes get updated*/
/* TODO: move over to memcpy */
for (j = 0 ; j < GL_LIMITS(samplers); j++){
for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE; i++){
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][i] = This->samplerState[j][i];
if (This->set.samplerState[j][i] && This->changed.samplerState[j][i]) {
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][i] = This->samplerState[j][i];
((IWineD3DDeviceImpl *)pDevice)->stateBlock->set.samplerState[j][i] = TRUE;
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[j][i] = TRUE;
}
}
}
} else if (This->blockType == D3DSBT_PIXELSTATE) {
} else if (This->blockType == WINED3DSBT_PIXELSTATE) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
if (This->set.renderState[SavedPixelStates_R[i]] && This->changed.renderState[SavedPixelStates_R[i]])
@ -456,7 +468,7 @@ should really perform a delta so that only the changes get updated*/
}
}
} else if (This->blockType == D3DSBT_VERTEXSTATE) {
} else if (This->blockType == WINED3DSBT_VERTEXSTATE) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
if ( This->set.renderState[SavedVertexStates_R[i]] && This->changed.renderState[SavedVertexStates_R[i]])

View File

@ -859,10 +859,8 @@ typedef struct SAVEDSTATES {
BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
BOOL viewport;
BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
#if 0
BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
BOOL samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
#endif
BOOL clipplane[MAX_CLIPPLANES];
BOOL vertexDecl;
BOOL pixelShader;