DirectX uses a R/Z transform to translate a texture but under OpenGL a
Q transform must be used instead.
This commit is contained in:
parent
6d8567824f
commit
052d108bf5
|
@ -1615,7 +1615,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetTransform(IWineD3DDevice *iface, D3DTRANS
|
||||||
int tex = d3dts - D3DTS_TEXTURE0;
|
int tex = d3dts - D3DTS_TEXTURE0;
|
||||||
GLACTIVETEXTURE(tex);
|
GLACTIVETEXTURE(tex);
|
||||||
set_texture_matrix((float *)lpmatrix,
|
set_texture_matrix((float *)lpmatrix,
|
||||||
This->updateStateBlock->textureState[tex][WINED3DTSS_TEXTURETRANSFORMFLAGS]);
|
This->updateStateBlock->textureState[tex][WINED3DTSS_TEXTURETRANSFORMFLAGS], (This->stateBlock->textureState[tex][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != D3DTSS_TCI_PASSTHRU);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (d3dts == D3DTS_VIEW) { /* handle the VIEW matrice */
|
} else if (d3dts == D3DTS_VIEW) { /* handle the VIEW matrice */
|
||||||
|
@ -3956,6 +3956,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DW
|
||||||
glDisable(GL_TEXTURE_GEN_S);
|
glDisable(GL_TEXTURE_GEN_S);
|
||||||
glDisable(GL_TEXTURE_GEN_T);
|
glDisable(GL_TEXTURE_GEN_T);
|
||||||
glDisable(GL_TEXTURE_GEN_R);
|
glDisable(GL_TEXTURE_GEN_R);
|
||||||
|
glDisable(GL_TEXTURE_GEN_Q);
|
||||||
checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R)");
|
checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R)");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -4070,6 +4071,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DW
|
||||||
glDisable(GL_TEXTURE_GEN_S);
|
glDisable(GL_TEXTURE_GEN_S);
|
||||||
glDisable(GL_TEXTURE_GEN_T);
|
glDisable(GL_TEXTURE_GEN_T);
|
||||||
glDisable(GL_TEXTURE_GEN_R);
|
glDisable(GL_TEXTURE_GEN_R);
|
||||||
|
glDisable(GL_TEXTURE_GEN_Q);
|
||||||
FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %lx\n", Value);
|
FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %lx\n", Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4078,7 +4080,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DW
|
||||||
|
|
||||||
/* Unhandled */
|
/* Unhandled */
|
||||||
case WINED3DTSS_TEXTURETRANSFORMFLAGS :
|
case WINED3DTSS_TEXTURETRANSFORMFLAGS :
|
||||||
set_texture_matrix((float *)&This->stateBlock->transforms[D3DTS_TEXTURE0 + Stage].u.m[0][0], Value);
|
set_texture_matrix((float *)&This->stateBlock->transforms[D3DTS_TEXTURE0 + Stage].u.m[0][0], Value, (This->stateBlock->textureState[Stage][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != D3DTSS_TCI_PASSTHRU);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3DTSS_BUMPENVMAT00 :
|
case WINED3DTSS_BUMPENVMAT00 :
|
||||||
|
|
|
@ -1456,11 +1456,12 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Setup this textures matrix according to the texture flags*/
|
/* Setup this textures matrix according to the texture flags*/
|
||||||
void set_texture_matrix(const float *smat, DWORD flags)
|
void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords)
|
||||||
{
|
{
|
||||||
float mat[16];
|
float mat[16];
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
glMatrixMode(GL_TEXTURE);
|
||||||
|
checkGLcall("glMatrixMode(GL_TEXTURE)");
|
||||||
|
|
||||||
if (flags == D3DTTFF_DISABLE) {
|
if (flags == D3DTTFF_DISABLE) {
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -1470,28 +1471,38 @@ void set_texture_matrix(const float *smat, DWORD flags)
|
||||||
|
|
||||||
if (flags == (D3DTTFF_COUNT1|D3DTTFF_PROJECTED)) {
|
if (flags == (D3DTTFF_COUNT1|D3DTTFF_PROJECTED)) {
|
||||||
ERR("Invalid texture transform flags: D3DTTFF_COUNT1|D3DTTFF_PROJECTED\n");
|
ERR("Invalid texture transform flags: D3DTTFF_COUNT1|D3DTTFF_PROJECTED\n");
|
||||||
checkGLcall("glLoadIdentity()");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(mat, smat, 16*sizeof(float));
|
memcpy(mat, smat, 16 * sizeof(float));
|
||||||
|
|
||||||
switch (flags & ~D3DTTFF_PROJECTED) {
|
switch (flags & ~D3DTTFF_PROJECTED) {
|
||||||
case D3DTTFF_COUNT1: mat[1] = mat[5] = mat[9] = mat[13] = 0;
|
case D3DTTFF_COUNT1: mat[1] = mat[5] = mat[13] = 0;
|
||||||
case D3DTTFF_COUNT2: mat[2] = mat[6] = mat[10] = mat[14] = 0;
|
case D3DTTFF_COUNT2: mat[2] = mat[6] = mat[10] = mat[14] = 0;
|
||||||
default: mat[3] = mat[7] = mat[11] = 0, mat[15] = 1;
|
default: mat[3] = mat[7] = mat[11] = 0, mat[15] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & D3DTTFF_PROJECTED) switch (flags & ~D3DTTFF_PROJECTED) {
|
if (flags & D3DTTFF_PROJECTED) {
|
||||||
case D3DTTFF_COUNT2:
|
switch (flags & ~D3DTTFF_PROJECTED) {
|
||||||
mat[3] = mat[1], mat[7] = mat[5], mat[11] = mat[9], mat[15] = mat[13];
|
case D3DTTFF_COUNT1:
|
||||||
mat[1] = mat[5] = mat[9] = mat[13] = 0;
|
mat[9] = 0;
|
||||||
break;
|
|
||||||
case D3DTTFF_COUNT3:
|
|
||||||
mat[3] = mat[2], mat[7] = mat[6], mat[11] = mat[10], mat[15] = mat[14];
|
|
||||||
mat[2] = mat[6] = mat[10] = mat[14] = 0;
|
|
||||||
break;
|
break;
|
||||||
|
case D3DTTFF_COUNT2:
|
||||||
|
mat[3] = mat[1], mat[7] = mat[5], mat[11] = mat[9], mat[15] = mat[13];
|
||||||
|
mat[1] = mat[5] = mat[9] = mat[13] = 0;
|
||||||
|
break;
|
||||||
|
case D3DTTFF_COUNT3:
|
||||||
|
mat[3] = mat[2], mat[7] = mat[6], mat[11] = mat[10], mat[15] = mat[14];
|
||||||
|
mat[2] = mat[6] = mat[10] = mat[14] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if(!calculatedCoords) { /* under directx the R/Z coord can be used for translation, under opengl we use the Q coord instead */
|
||||||
|
mat[12] = mat[8];
|
||||||
|
mat[13] = mat[9];
|
||||||
|
mat[8] = 0;
|
||||||
|
mat[9] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
glLoadMatrixf(mat);
|
glLoadMatrixf(mat);
|
||||||
checkGLcall("glLoadMatrixf(mat)");
|
checkGLcall("glLoadMatrixf(mat)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -937,7 +937,7 @@ const char* debug_d3dpool(D3DPOOL pool);
|
||||||
/* Routines for GL <-> D3D values */
|
/* Routines for GL <-> D3D values */
|
||||||
GLenum StencilOp(DWORD op);
|
GLenum StencilOp(DWORD op);
|
||||||
void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
|
void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
|
||||||
void set_texture_matrix(const float *smat, DWORD flags);
|
void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords);
|
||||||
void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
|
void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
|
||||||
|
|
||||||
SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
|
SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
|
||||||
|
|
Loading…
Reference in New Issue