- Dont set lighting during draw primitive, rely on the render state.
- Small fix for alpha testing. - Add support to enable/disable clipping as a whole. - Allow D3DRS_TEXTUREFACTOR to be changed once texture stage arg set up. - D3DTOP_DISABLE initial implementation.
This commit is contained in:
parent
b47c14aef9
commit
6fc8f9f399
|
@ -130,14 +130,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
||||||
TRACE("Drawing with FVF = %x, (n?%d, rhw?%d, ptSize(%d), diffuse?%d, specular?%d, numTextures=%d)\n",
|
TRACE("Drawing with FVF = %x, (n?%d, rhw?%d, ptSize(%d), diffuse?%d, specular?%d, numTextures=%d)\n",
|
||||||
fvf, normal, isRHW, isPtSize, isDiffuse, isSpecular, numTextures);
|
fvf, normal, isRHW, isPtSize, isDiffuse, isSpecular, numTextures);
|
||||||
|
|
||||||
/* Only add lighting for unlit vertices */
|
/* Note: Dont touch lighing anymore - it is set by the appropriate render state */
|
||||||
if (normal && !isRHW) {
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
checkGLcall("enable lighting");
|
|
||||||
} else {
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
checkGLcall("disable lighting");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRHW) {
|
if (isRHW) {
|
||||||
|
|
||||||
|
@ -470,7 +463,6 @@ int OPERANDx_ALPHA_EXT(DWORD arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* IDirect3D IUnknown parts follow: */
|
/* IDirect3D IUnknown parts follow: */
|
||||||
HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
|
HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
|
||||||
{
|
{
|
||||||
|
@ -1628,7 +1620,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
|
||||||
default:
|
default:
|
||||||
FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value);
|
FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value);
|
||||||
}
|
}
|
||||||
break;
|
TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref);
|
||||||
glAlphaFunc(glParm, ref);
|
glAlphaFunc(glParm, ref);
|
||||||
checkGLcall("glAlphaFunc");
|
checkGLcall("glAlphaFunc");
|
||||||
}
|
}
|
||||||
|
@ -1643,16 +1635,33 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
|
||||||
checkGLcall("glGetFloatv(GL_ALPHA_TEST_FUNC, &glParm);");
|
checkGLcall("glGetFloatv(GL_ALPHA_TEST_FUNC, &glParm);");
|
||||||
|
|
||||||
ref = ((float) Value) / 255.0;
|
ref = ((float) Value) / 255.0;
|
||||||
|
TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref);
|
||||||
glAlphaFunc(glParm, ref);
|
glAlphaFunc(glParm, ref);
|
||||||
checkGLcall("glAlphaFunc");
|
checkGLcall("glAlphaFunc");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3DRS_CLIPPLANEENABLE :
|
case D3DRS_CLIPPLANEENABLE :
|
||||||
|
case D3DRS_CLIPPING :
|
||||||
{
|
{
|
||||||
/* Ensure we only do the changed clip planes */
|
/* Ensure we only do the changed clip planes */
|
||||||
DWORD enable = Value & ~OldValue;
|
DWORD enable = 0xFFFFFFFF;
|
||||||
DWORD disable = ~Value & OldValue;
|
DWORD disable = 0x00000000;
|
||||||
|
|
||||||
|
/* If enabling / disabling all */
|
||||||
|
if (State == D3DRS_CLIPPING) {
|
||||||
|
if (Value) {
|
||||||
|
enable = This->StateBlock.renderstate[D3DRS_CLIPPLANEENABLE];
|
||||||
|
disable = 0x00;
|
||||||
|
} else {
|
||||||
|
disable = This->StateBlock.renderstate[D3DRS_CLIPPLANEENABLE];
|
||||||
|
enable = 0x00;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enable = Value & ~OldValue;
|
||||||
|
disable = ~Value & OldValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (enable & D3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
|
if (enable & D3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
|
||||||
if (enable & D3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
|
if (enable & D3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
|
||||||
if (enable & D3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
|
if (enable & D3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
|
||||||
|
@ -1689,12 +1698,31 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
|
||||||
|
|
||||||
case D3DRS_TEXTUREFACTOR :
|
case D3DRS_TEXTUREFACTOR :
|
||||||
{
|
{
|
||||||
/* noop - Just save away the texture color for now as it applies
|
int i;
|
||||||
to all textures whereas GL_TEXTURE_ENV_COLOR applies to active only */
|
|
||||||
|
/* Note the texture color applies to all textures whereas
|
||||||
|
GL_TEXTURE_ENV_COLOR applies to active only */
|
||||||
|
for (i=0; i<8; i++) {
|
||||||
|
float col[4];
|
||||||
|
|
||||||
|
if (This->StateBlock.textures[i]) {
|
||||||
|
glActiveTextureARB(GL_TEXTURE0_ARB + i);
|
||||||
|
checkGLcall("Activate texture.. to update const color");
|
||||||
|
|
||||||
|
/* Note the D3DRS value applies to all textures, but GL has one
|
||||||
|
per texture, so apply it now ready to be used! */
|
||||||
|
col[0] = ((Value >> 16) & 0xFF) / 255.0;
|
||||||
|
col[1] = ((Value >> 8 ) & 0xFF) / 255.0;
|
||||||
|
col[2] = ((Value >> 0 ) & 0xFF) / 255.0;
|
||||||
|
col[3] = ((Value >> 24 ) & 0xFF) / 255.0;
|
||||||
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
|
||||||
|
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3DRS_SPECULARENABLE : /* Can opengl do this? */
|
case D3DRS_SPECULARENABLE :
|
||||||
{
|
{
|
||||||
if (Value) {
|
if (Value) {
|
||||||
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);
|
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);
|
||||||
|
@ -1706,6 +1734,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/* Unhandled yet...! */
|
/* Unhandled yet...! */
|
||||||
case D3DRS_LINEPATTERN :
|
case D3DRS_LINEPATTERN :
|
||||||
case D3DRS_LASTPIXEL :
|
case D3DRS_LASTPIXEL :
|
||||||
|
@ -1735,7 +1764,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
|
||||||
case D3DRS_WRAP5 :
|
case D3DRS_WRAP5 :
|
||||||
case D3DRS_WRAP6 :
|
case D3DRS_WRAP6 :
|
||||||
case D3DRS_WRAP7 :
|
case D3DRS_WRAP7 :
|
||||||
case D3DRS_CLIPPING :
|
|
||||||
case D3DRS_FOGVERTEXMODE :
|
case D3DRS_FOGVERTEXMODE :
|
||||||
case D3DRS_COLORVERTEX :
|
case D3DRS_COLORVERTEX :
|
||||||
case D3DRS_LOCALVIEWER :
|
case D3DRS_LOCALVIEWER :
|
||||||
|
@ -2200,6 +2228,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD
|
||||||
if (textureType == D3DRTYPE_TEXTURE) {
|
if (textureType == D3DRTYPE_TEXTURE) {
|
||||||
IDirect3DTexture8Impl *pTexture2 = (IDirect3DTexture8Impl *) pTexture;
|
IDirect3DTexture8Impl *pTexture2 = (IDirect3DTexture8Impl *) pTexture;
|
||||||
int i;
|
int i;
|
||||||
|
float col[4];
|
||||||
|
|
||||||
/* Standard 2D texture */
|
/* Standard 2D texture */
|
||||||
TRACE("Standard 2d texture\n");
|
TRACE("Standard 2d texture\n");
|
||||||
|
@ -2245,12 +2274,23 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||||
/*glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);*/
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
checkGLcall("glEnable");
|
checkGLcall("glEnable");
|
||||||
|
|
||||||
pTexture2->Dirty = FALSE;
|
pTexture2->Dirty = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note the D3DRS value applies to all textures, but GL has one
|
||||||
|
per texture, so apply it now ready to be used! */
|
||||||
|
col[0] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR]>> 16) & 0xFF) / 255.0;
|
||||||
|
col[1] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 8 ) & 0xFF) / 255.0;
|
||||||
|
col[2] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 0 ) & 0xFF) / 255.0;
|
||||||
|
col[3] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 24 ) & 0xFF) / 255.0;
|
||||||
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
|
||||||
|
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FIXME("(%p) : stub\n", This);
|
FIXME("(%p) : stub\n", This);
|
||||||
|
@ -2326,8 +2366,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
||||||
int operand= GL_SRC_COLOR;
|
int operand= GL_SRC_COLOR;
|
||||||
int source = GL_TEXTURE;
|
int source = GL_TEXTURE;
|
||||||
|
|
||||||
TRACE("Type %d : %ld\n", Type, Value);
|
|
||||||
|
|
||||||
/* Catch alpha replicate */
|
/* Catch alpha replicate */
|
||||||
if (Value & D3DTA_ALPHAREPLICATE) {
|
if (Value & D3DTA_ALPHAREPLICATE) {
|
||||||
Value = Value & ~D3DTA_ALPHAREPLICATE;
|
Value = Value & ~D3DTA_ALPHAREPLICATE;
|
||||||
|
@ -2367,20 +2405,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
||||||
break;
|
break;
|
||||||
case D3DTA_TEXTURE: source = GL_TEXTURE;
|
case D3DTA_TEXTURE: source = GL_TEXTURE;
|
||||||
break;
|
break;
|
||||||
case D3DTA_TFACTOR: {
|
case D3DTA_TFACTOR: source = GL_CONSTANT_EXT;
|
||||||
float col[4];
|
|
||||||
|
|
||||||
source = GL_CONSTANT_EXT;
|
|
||||||
|
|
||||||
/* Note the D3DRS value applies to all textures, but GL has one
|
|
||||||
per texture, so apply it now ready to be used! */
|
|
||||||
col[0] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 16) & 0xFF) / 255.0;
|
|
||||||
col[1] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 8 ) & 0xFF) / 255.0;
|
|
||||||
col[2] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 0 ) & 0xFF) / 255.0;
|
|
||||||
col[3] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 24 ) & 0xFF) / 255.0;
|
|
||||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
|
|
||||||
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* According to the GL_ARB_texture_env_combine specs, SPECULAR is 'Secondary color' and
|
/* According to the GL_ARB_texture_env_combine specs, SPECULAR is 'Secondary color' and
|
||||||
|
@ -2392,11 +2417,13 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAlphaArg) {
|
if (isAlphaArg) {
|
||||||
|
TRACE("Source %x = %x, Operand %x = %x\n", SOURCEx_ALPHA_EXT(Type), source, OPERANDx_ALPHA_EXT(Type), operand);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, SOURCEx_ALPHA_EXT(Type), source);
|
glTexEnvi(GL_TEXTURE_ENV, SOURCEx_ALPHA_EXT(Type), source);
|
||||||
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, SOURCEx_ALPHA_EXT, source);");
|
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, SOURCEx_ALPHA_EXT, source);");
|
||||||
glTexEnvi(GL_TEXTURE_ENV, OPERANDx_ALPHA_EXT(Type), operand);
|
glTexEnvi(GL_TEXTURE_ENV, OPERANDx_ALPHA_EXT(Type), operand);
|
||||||
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, OPERANDx_ALPHA_EXT, operand);");
|
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, OPERANDx_ALPHA_EXT, operand);");
|
||||||
} else {
|
} else {
|
||||||
|
TRACE("Source %x = %x, Operand %x = %x\n", SOURCEx_RGB_EXT(Type), source, OPERANDx_RGB_EXT(Type), operand);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, SOURCEx_RGB_EXT(Type), source);
|
glTexEnvi(GL_TEXTURE_ENV, SOURCEx_RGB_EXT(Type), source);
|
||||||
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, SOURCEx_RGB_EXT, source);");
|
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, SOURCEx_RGB_EXT, source);");
|
||||||
glTexEnvi(GL_TEXTURE_ENV, OPERANDx_RGB_EXT(Type), operand);
|
glTexEnvi(GL_TEXTURE_ENV, OPERANDx_RGB_EXT(Type), operand);
|
||||||
|
@ -2413,6 +2440,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
||||||
int Parm = (Type == D3DTSS_ALPHAOP)? GL_COMBINE_ALPHA_EXT : GL_COMBINE_RGB_EXT;
|
int Parm = (Type == D3DTSS_ALPHAOP)? GL_COMBINE_ALPHA_EXT : GL_COMBINE_RGB_EXT;
|
||||||
|
|
||||||
switch (Value) {
|
switch (Value) {
|
||||||
|
case D3DTOP_DISABLE :
|
||||||
|
/* TODO: Disable by making this and all later levels disabled */
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
checkGLcall("Disable GL_TEXTURE_2D");
|
||||||
|
break;
|
||||||
|
|
||||||
case D3DTOP_SELECTARG1 :
|
case D3DTOP_SELECTARG1 :
|
||||||
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE);
|
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE);
|
||||||
break;
|
break;
|
||||||
|
@ -2441,7 +2474,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
||||||
|
|
||||||
case D3DTOP_SUBTRACT :
|
case D3DTOP_SUBTRACT :
|
||||||
/* glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT); Missing? */
|
/* glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT); Missing? */
|
||||||
case D3DTOP_DISABLE :
|
|
||||||
case D3DTOP_SELECTARG2 :
|
case D3DTOP_SELECTARG2 :
|
||||||
/* GL_REPLACE, swap args 0 and 1? */
|
/* GL_REPLACE, swap args 0 and 1? */
|
||||||
case D3DTOP_ADDSMOOTH :
|
case D3DTOP_ADDSMOOTH :
|
||||||
|
|
Loading…
Reference in New Issue