Add {G,S}etRenderState and {G,S}etTextureStageState support, and
ensure the stateblock is fully populated at device startup.
This commit is contained in:
parent
20f8397321
commit
2003c7ab11
|
@ -374,15 +374,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface, DWOR
|
|||
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value) {
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
FIXME("(%p) : stub\n", This);
|
||||
return D3D_OK;
|
||||
return IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
TRACE("(%p) for State %d = %ld\n", This, State, This->UpdateStateBlock->renderstate[State]);
|
||||
*pValue = This->StateBlock->renderstate[State];
|
||||
return D3D_OK;
|
||||
return IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) {
|
||||
|
@ -411,15 +408,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD
|
|||
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
TRACE("(%p) : requesting Stage %ld, Type %d getting %ld\n", This, Stage, Type, This->UpdateStateBlock->texture_state[Stage][Type]);
|
||||
*pValue = This->UpdateStateBlock->texture_state[Stage][Type];
|
||||
return D3D_OK;
|
||||
return IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
FIXME("(%p) : stub\n", This);
|
||||
return D3D_OK;
|
||||
return IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1565,7 +1565,7 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
|
|||
vp.Height = *(pPresentationParameters->BackBufferHeight);
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
/* TODO: IWineD3DDevice_SetViewport((LPDIRECT3DDEVICE9) object, &vp); */
|
||||
IWineD3DDevice_SetViewport((IWineD3DDevice *)object, &vp);
|
||||
}
|
||||
|
||||
/* Initialize the current view state */
|
||||
|
|
|
@ -202,14 +202,10 @@ void init_materials(IWineD3DDevice *iface, BOOL isDiffuseSupplied) {
|
|||
checkGLcall("glMaterialfv");
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*) &This->stateBlock->material.Diffuse);
|
||||
checkGLcall("glMaterialfv");
|
||||
#if 0 /* TODO */
|
||||
if (This->stateBlock->renderstate[D3DRS_SPECULARENABLE]) {
|
||||
if (This->stateBlock->renderState[D3DRS_SPECULARENABLE]) {
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->stateBlock->material.Specular);
|
||||
checkGLcall("glMaterialfv");
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
|
||||
checkGLcall("glMaterialfv");
|
||||
|
@ -429,7 +425,7 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedD
|
|||
}
|
||||
|
||||
/* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */
|
||||
/** do we have to Check This->updateStateBlock->renderstate[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
|
||||
/** do we have to Check This->updateStateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
|
||||
numBlends = ((thisFVF & D3DFVF_POSITION_MASK) >> 1) - 2 +
|
||||
((FALSE == (thisFVF & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1); /* WARNING can be < 0 because -2 */
|
||||
if (numBlends > 0) {
|
||||
|
@ -1502,7 +1498,7 @@ void drawPrimitive(IWineD3DDevice *iface,
|
|||
|
||||
useHW = (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) &&
|
||||
This->devType != D3DDEVTYPE_REF &&
|
||||
!This->stateBlock->renderstate[D3DRS_SOFTWAREVERTEXPROCESSING] &&
|
||||
!This->stateBlock->renderState[D3DRS_SOFTWAREVERTEXPROCESSING] &&
|
||||
vertex_shader->usage != D3DUSAGE_SOFTWAREPROCESSING);
|
||||
|
||||
/** init Constants */
|
||||
|
|
|
@ -34,6 +34,16 @@ HRESULT WINAPI IWineD3DStateBlockImpl_GetParent(IWineD3DStateBlock *iface, IUnkn
|
|||
|
||||
HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock* iface) {
|
||||
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
|
||||
IWineD3DDeviceImpl *ThisDevice = (IWineD3DDeviceImpl *)(This->wineD3DDevice);
|
||||
union {
|
||||
D3DLINEPATTERN lp;
|
||||
DWORD d;
|
||||
} lp;
|
||||
union {
|
||||
float f;
|
||||
DWORD d;
|
||||
} tmpfloat;
|
||||
unsigned int i;
|
||||
|
||||
/* Note this may have a large overhead but it should only be executed
|
||||
once, in order to initialize the complete state of the device and
|
||||
|
@ -41,6 +51,205 @@ HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock*
|
|||
TRACE("-----------------------> Setting up device defaults...\n");
|
||||
This->blockType = D3DSBT_ALL;
|
||||
|
||||
/* FIXME: Set some of the defaults for lights, transforms etc */
|
||||
memcpy(&This->transforms[D3DTS_PROJECTION], &identity, sizeof(identity));
|
||||
memcpy(&This->transforms[D3DTS_VIEW], &identity, sizeof(identity));
|
||||
for (i = 0; i < 256; ++i) {
|
||||
memcpy(&This->transforms[D3DTS_WORLDMATRIX(i)], &identity, sizeof(identity));
|
||||
}
|
||||
|
||||
/* Render states: */
|
||||
if (ThisDevice->presentParms.EnableAutoDepthStencil) {
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
} else {
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
}
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FILLMODE, D3DFILL_SOLID);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
||||
|
||||
lp.lp.wRepeatFactor = 0; lp.lp.wLinePattern = 0;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_LINEPATTERN, lp.d);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ZWRITEENABLE, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ALPHATESTENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_LASTPIXEL, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_DESTBLEND, D3DBLEND_ZERO);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ALPHAREF, 0xff); /*??*/
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_DITHERENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_SPECULARENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ZVISIBLE, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGCOLOR, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
|
||||
tmpfloat.f = 0.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGSTART, tmpfloat.d);
|
||||
tmpfloat.f = 1.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGEND, tmpfloat.d);
|
||||
tmpfloat.f = 1.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGDENSITY, tmpfloat.d);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_EDGEANTIALIAS, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_ZBIAS, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_RANGEFOGENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
|
||||
|
||||
/* Setting stencil func also uses values for stencil ref/mask, so manually set defaults
|
||||
* so only a single call performed (and ensure defaults initialized before making that call)
|
||||
*
|
||||
* IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILREF, 0);
|
||||
* IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILMASK, 0xFFFFFFFF);
|
||||
*/
|
||||
This->renderState[D3DRS_STENCILREF] = 0;
|
||||
This->renderState[D3DRS_STENCILMASK] = 0xFFFFFFFF;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_TEXTUREFACTOR, 0xFFFFFFFF);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP0, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP1, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP2, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP3, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP4, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP5, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP6, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_WRAP7, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_CLIPPING, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_LIGHTING, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_AMBIENT, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_COLORVERTEX, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_LOCALVIEWER, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_NORMALIZENORMALS, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_SPECULARMATERIALSOURCE, D3DMCS_COLOR2);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR2);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_CLIPPLANEENABLE, 0);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
|
||||
tmpfloat.f = 1.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSIZE, tmpfloat.d);
|
||||
tmpfloat.f = 0.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSIZE_MIN, tmpfloat.d);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSPRITEENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSCALEENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSCALE_A, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSCALE_B, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSCALE_C, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_MULTISAMPLEANTIALIAS, TRUE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_PATCHEDGESTYLE, D3DPATCHEDGE_DISCRETE);
|
||||
tmpfloat.f = 1.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_PATCHSEGMENTS, tmpfloat.d);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_DEBUGMONITORTOKEN, D3DDMT_DISABLE);
|
||||
tmpfloat.f = 64.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POINTSIZE_MAX, tmpfloat.d);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_COLORWRITEENABLE, 0x0000000F);
|
||||
tmpfloat.f = 0.0f;
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_TWEENFACTOR, tmpfloat.d);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_POSITIONORDER, D3DORDER_CUBIC);
|
||||
IWineD3DDevice_SetRenderState(This->wineD3DDevice, D3DRS_NORMALORDER, D3DORDER_LINEAR);
|
||||
|
||||
/** clipping status */
|
||||
This->clip_status.ClipUnion = 0;
|
||||
This->clip_status.ClipIntersection = 0xFFFFFFFF;
|
||||
|
||||
/* Texture Stage States - Put directly into state block, we will call function below */
|
||||
for (i = 0; i < GL_LIMITS(textures); i++) {
|
||||
TRACE("Setting up default texture states for texture Stage %d\n", i);
|
||||
memcpy(&This->transforms[D3DTS_TEXTURE0 + i], &identity, sizeof(identity));
|
||||
This->textureState[i][D3DTSS_COLOROP ] = (i==0)? D3DTOP_MODULATE : D3DTOP_DISABLE;
|
||||
This->textureState[i][D3DTSS_COLORARG1 ] = D3DTA_TEXTURE;
|
||||
This->textureState[i][D3DTSS_COLORARG2 ] = D3DTA_CURRENT;
|
||||
This->textureState[i][D3DTSS_ALPHAOP ] = (i==0)? D3DTOP_SELECTARG1 : D3DTOP_DISABLE;
|
||||
This->textureState[i][D3DTSS_ALPHAARG1 ] = D3DTA_TEXTURE;
|
||||
This->textureState[i][D3DTSS_ALPHAARG2 ] = D3DTA_CURRENT;
|
||||
This->textureState[i][D3DTSS_BUMPENVMAT00 ] = (DWORD) 0.0;
|
||||
This->textureState[i][D3DTSS_BUMPENVMAT01 ] = (DWORD) 0.0;
|
||||
This->textureState[i][D3DTSS_BUMPENVMAT10 ] = (DWORD) 0.0;
|
||||
This->textureState[i][D3DTSS_BUMPENVMAT11 ] = (DWORD) 0.0;
|
||||
This->textureState[i][D3DTSS_TEXCOORDINDEX ] = i;
|
||||
This->textureState[i][D3DTSS_ADDRESSU ] = D3DTADDRESS_WRAP;
|
||||
This->textureState[i][D3DTSS_ADDRESSV ] = D3DTADDRESS_WRAP;
|
||||
This->textureState[i][D3DTSS_BORDERCOLOR ] = 0x00;
|
||||
This->textureState[i][D3DTSS_MAGFILTER ] = D3DTEXF_POINT;
|
||||
This->textureState[i][D3DTSS_MINFILTER ] = D3DTEXF_POINT;
|
||||
This->textureState[i][D3DTSS_MIPFILTER ] = D3DTEXF_NONE;
|
||||
This->textureState[i][D3DTSS_MIPMAPLODBIAS ] = 0;
|
||||
This->textureState[i][D3DTSS_MAXMIPLEVEL ] = 0;
|
||||
This->textureState[i][D3DTSS_MAXANISOTROPY ] = 1;
|
||||
This->textureState[i][D3DTSS_BUMPENVLSCALE ] = (DWORD) 0.0;
|
||||
This->textureState[i][D3DTSS_BUMPENVLOFFSET ] = (DWORD) 0.0;
|
||||
This->textureState[i][D3DTSS_TEXTURETRANSFORMFLAGS ] = D3DTTFF_DISABLE;
|
||||
This->textureState[i][D3DTSS_ADDRESSW ] = D3DTADDRESS_WRAP;
|
||||
This->textureState[i][D3DTSS_COLORARG0 ] = D3DTA_CURRENT;
|
||||
This->textureState[i][D3DTSS_ALPHAARG0 ] = D3DTA_CURRENT;
|
||||
This->textureState[i][D3DTSS_RESULTARG ] = D3DTA_CURRENT;
|
||||
}
|
||||
|
||||
/* Under DirectX you can have texture stage operations even if no texture is
|
||||
bound, whereas opengl will only do texture operations when a valid texture is
|
||||
bound. We emulate this by creating dummy textures and binding them to each
|
||||
texture stage, but disable all stages by default. Hence if a stage is enabled
|
||||
then the default texture will kick in until replaced by a SetTexture call */
|
||||
|
||||
ENTER_GL();
|
||||
|
||||
for (i = 0; i < GL_LIMITS(textures); i++) {
|
||||
GLubyte white = 255;
|
||||
|
||||
/* Note this avoids calling settexture, so pretend it has been called */
|
||||
This->set.textures[i] = TRUE;
|
||||
This->changed.textures[i] = TRUE;
|
||||
This->textures[i] = NULL;
|
||||
|
||||
/* Make appropriate texture active */
|
||||
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
||||
GL_ACTIVETEXTURE(i);
|
||||
} else if (i > 0) {
|
||||
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
||||
}
|
||||
|
||||
/* Generate an opengl texture name */
|
||||
glGenTextures(1, &ThisDevice->dummyTextureName[i]);
|
||||
checkGLcall("glGenTextures");
|
||||
TRACE("Dummy Texture %d given name %d\n", i, ThisDevice->dummyTextureName[i]);
|
||||
|
||||
/* Generate a dummy 1d texture */
|
||||
This->textureDimensions[i] = GL_TEXTURE_1D;
|
||||
glBindTexture(GL_TEXTURE_1D, ThisDevice->dummyTextureName[i]);
|
||||
checkGLcall("glBindTexture");
|
||||
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &white);
|
||||
checkGLcall("glTexImage1D");
|
||||
|
||||
/* Reapply all the texture state information to this texture */
|
||||
IWineD3DDevice_SetupTextureStates(This->wineD3DDevice, i, REAPPLY_ALL);
|
||||
}
|
||||
|
||||
LEAVE_GL();
|
||||
|
||||
#if 0 /* TODO: Palette support */
|
||||
/* defaulting palettes */
|
||||
for (i = 0; i < MAX_PALETTES; ++i) {
|
||||
int j;
|
||||
for (j = 0; j < 256; ++j) {
|
||||
This->palettes[i][j].peRed = 0xFF;
|
||||
This->palettes[i][j].peGreen = 0xFF;
|
||||
This->palettes[i][j].peBlue = 0xFF;
|
||||
This->palettes[i][j].peFlags = 0xFF;
|
||||
}
|
||||
}
|
||||
This->currentPalette = 0;
|
||||
#endif /* TODO: Palette support */
|
||||
|
||||
TRACE("-----------------------> Device defaults now set up...\n");
|
||||
return D3D_OK;
|
||||
}
|
||||
|
|
1379
dlls/wined3d/utils.c
1379
dlls/wined3d/utils.c
File diff suppressed because it is too large
Load Diff
|
@ -69,18 +69,51 @@ extern int num_lock;
|
|||
/*****************************************************************************
|
||||
* Defines
|
||||
*/
|
||||
|
||||
/* GL related defines */
|
||||
/* ------------------ */
|
||||
#define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
|
||||
#define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
|
||||
#define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
|
||||
|
||||
#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
|
||||
#define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
|
||||
#define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
|
||||
#define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
|
||||
|
||||
#define D3DCOLORTOGLFLOAT4(dw, vec) \
|
||||
(vec)[0] = D3DCOLOR_R(dw); \
|
||||
(vec)[1] = D3DCOLOR_G(dw); \
|
||||
(vec)[2] = D3DCOLOR_B(dw); \
|
||||
(vec)[3] = D3DCOLOR_A(dw);
|
||||
|
||||
/* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
|
||||
#if defined(GL_VERSION_1_3)
|
||||
#define GL_ACTIVETEXTURE(textureNo) \
|
||||
glActiveTexture(GL_TEXTURE0 + textureNo); \
|
||||
checkGLcall("glActiveTexture");
|
||||
#else
|
||||
#define GL_ACTIVETEXTURE(textureNo) \
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \
|
||||
checkGLcall("glActiveTextureARB");
|
||||
#endif
|
||||
|
||||
/* DirectX Device Limits */
|
||||
/* --------------------- */
|
||||
#define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
|
||||
See MaxStreams in MSDN under GetDeviceCaps */
|
||||
#define HIGHEST_TRANSFORMSTATE 512
|
||||
/* Highest value in D3DTRANSFORMSTATETYPE */
|
||||
#define HIGHEST_RENDER_STATE 209
|
||||
/* Highest D3DRS_ value */
|
||||
#define HIGHEST_TEXTURE_STATE 32
|
||||
/* Highest D3DTSS_ value */
|
||||
#define WINED3D_VSHADER_MAX_CONSTANTS 96
|
||||
/* Maximum number of constants provided to the shaders */
|
||||
#define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
|
||||
|
||||
/* Checking of API calls */
|
||||
/* --------------------- */
|
||||
#define checkGLcall(A) \
|
||||
{ \
|
||||
GLint err = glGetError(); \
|
||||
|
@ -91,6 +124,10 @@ extern int num_lock;
|
|||
} \
|
||||
}
|
||||
|
||||
/* Trace routines / diagnostics */
|
||||
/* ---------------------------- */
|
||||
|
||||
/* Dump out a matrix and copy it */
|
||||
#define conv_mat(mat,gl_mat) \
|
||||
do { \
|
||||
TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
|
||||
|
@ -100,17 +137,6 @@ do {
|
|||
memcpy(gl_mat, (mat), 16 * sizeof(float)); \
|
||||
} while (0)
|
||||
|
||||
/* The following is purely to keep the source code as clear from #ifdefs as possible */
|
||||
#if defined(GL_VERSION_1_3)
|
||||
#define GL_ACTIVETEXTURE(textureNo) \
|
||||
glActiveTexture(GL_TEXTURE0 + textureNo); \
|
||||
checkGLcall("glActiveTexture");
|
||||
#else
|
||||
#define GL_ACTIVETEXTURE(textureNo) \
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \
|
||||
checkGLcall("glActiveTextureARB");
|
||||
#endif
|
||||
|
||||
/* Macro to dump out the current state of the light chain */
|
||||
#define DUMP_LIGHT_CHAIN() \
|
||||
{ \
|
||||
|
@ -121,11 +147,20 @@ do {
|
|||
} \
|
||||
}
|
||||
|
||||
/* Trace vector and strided data information */
|
||||
#define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
|
||||
#define TRACE_STRIDED(sd,name) TRACE( #name "=(data:%p, stride:%ld, type:%ld)\n", sd->u.s.name.lpData, sd->u.s.name.dwStride, sd->u.s.name.dwType);
|
||||
|
||||
/* Defines used for optimizations */
|
||||
|
||||
/* Only reapply what is necessary */
|
||||
#define REAPPLY_ALPHAOP 0x0001
|
||||
#define REAPPLY_ALL 0xFFFF
|
||||
|
||||
/* Advance declaration of structures to satisfy compiler */
|
||||
typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
|
||||
|
||||
/* Global variables */
|
||||
extern const float identity[16];
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -268,6 +303,11 @@ typedef struct IWineD3DDeviceImpl
|
|||
#define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
|
||||
#define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
|
||||
#define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
|
||||
UINT srcBlend;
|
||||
UINT dstBlend;
|
||||
UINT alphafunc;
|
||||
UINT stencilfunc;
|
||||
BOOL texture_shader_active; /* TODO: Confirm use is correct */
|
||||
|
||||
/* State block related */
|
||||
BOOL isRecordingState;
|
||||
|
@ -283,6 +323,9 @@ typedef struct IWineD3DDeviceImpl
|
|||
/* For rendering to a texture using glCopyTexImage */
|
||||
BOOL renderUpsideDown;
|
||||
|
||||
/* Textures for when no other textures are mapped */
|
||||
UINT dummyTextureName[8];
|
||||
|
||||
} IWineD3DDeviceImpl;
|
||||
|
||||
extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
|
||||
|
@ -380,6 +423,8 @@ typedef struct SAVEDSTATES {
|
|||
BOOL textures[8];
|
||||
BOOL transform[HIGHEST_TRANSFORMSTATE];
|
||||
BOOL viewport;
|
||||
BOOL renderState[HIGHEST_RENDER_STATE];
|
||||
BOOL textureState[8][HIGHEST_TEXTURE_STATE];
|
||||
BOOL clipplane[MAX_CLIPPLANES];
|
||||
} SAVEDSTATES;
|
||||
|
||||
|
@ -428,9 +473,20 @@ struct IWineD3DStateBlockImpl
|
|||
/* Material */
|
||||
WINED3DMATERIAL material;
|
||||
|
||||
/* Indexed Vertex Blending */
|
||||
D3DVERTEXBLENDFLAGS vertex_blend;
|
||||
FLOAT tween_factor;
|
||||
|
||||
/* RenderState */
|
||||
DWORD renderState[HIGHEST_RENDER_STATE];
|
||||
|
||||
/* Texture */
|
||||
IWineD3DBaseTexture *textures[8];
|
||||
int textureDimensions[8];
|
||||
|
||||
/* Texture State Stage */
|
||||
DWORD textureState[8][HIGHEST_TEXTURE_STATE];
|
||||
|
||||
};
|
||||
|
||||
extern IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
|
||||
|
@ -438,11 +494,21 @@ extern IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
|
|||
/*****************************************************************************
|
||||
* Utility function prototypes
|
||||
*/
|
||||
|
||||
/* Trace routines */
|
||||
const char* debug_d3dformat(D3DFORMAT fmt);
|
||||
const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
|
||||
const char* debug_d3dresourcetype(D3DRESOURCETYPE res);
|
||||
const char* debug_d3dusage(DWORD usage);
|
||||
const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
|
||||
const char* debug_d3drenderstate(DWORD state);
|
||||
const char* debug_d3dtexturestate(DWORD state);
|
||||
|
||||
/* Routines for GL <-> D3D values */
|
||||
GLenum StencilOp(DWORD op);
|
||||
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 GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
|
||||
|
||||
#if 0 /* Needs fixing during rework */
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -182,11 +182,19 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
|
|||
STDMETHOD(GetIndices)(THIS_ IWineD3DIndexBuffer ** ppIndexData,UINT * pBaseVertexIndex) PURE;
|
||||
STDMETHOD(SetViewport)(THIS_ CONST WINED3DVIEWPORT * pViewport) PURE;
|
||||
STDMETHOD(GetViewport)(THIS_ WINED3DVIEWPORT * pViewport) PURE;
|
||||
STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE;
|
||||
STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD * pValue) PURE;
|
||||
STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE;
|
||||
STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD * pValue) PURE;
|
||||
STDMETHOD(BeginScene)(THIS) PURE;
|
||||
STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE;
|
||||
STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,INT baseVIdx, UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE;
|
||||
STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
|
||||
STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void * pIndexData,D3DFORMAT IndexDataFormat,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
|
||||
/*** Internal use IWineD3D methods ***/
|
||||
STDMETHOD_(void, SetupTextureStates)(THIS_ DWORD Stage, DWORD Flags);
|
||||
|
||||
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
|
@ -221,11 +229,16 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
|
|||
#define IWineD3DDevice_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b)
|
||||
#define IWineD3DDevice_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a)
|
||||
#define IWineD3DDevice_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a)
|
||||
#define IWineD3DDevice_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b)
|
||||
#define IWineD3DDevice_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b)
|
||||
#define IWineD3DDevice_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c)
|
||||
#define IWineD3DDevice_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c)
|
||||
#define IWineD3DDevice_BeginScene(p) (p)->lpVtbl->BeginScene(p)
|
||||
#define IWineD3DDevice_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c)
|
||||
#define IWineD3DDevice_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f)
|
||||
#define IWineD3DDevice_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d)
|
||||
#define IWineD3DDevice_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h)
|
||||
#define IWineD3DDevice_SetupTextureStates(p,a,b) (p)->lpVtbl->SetupTextureStates(p,a,b)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
Loading…
Reference in New Issue