Beginning of state block.

Initialize the device with the right D3D default values.
Implements GetRenderState, GetTextureStageState and GetLightState.
This commit is contained in:
Christian Costa 2003-01-03 21:08:50 +00:00 committed by Alexandre Julliard
parent c064dcf50c
commit 4fc7a8495a
7 changed files with 272 additions and 35 deletions

View File

@ -26,6 +26,10 @@
#include "d3d.h" #include "d3d.h"
#define HIGHEST_RENDER_STATE 152
#define HIGHEST_TEXTURE_STAGE_STATE 24
#define HIGHEST_LIGHT_STATE 8
/***************************************************************************** /*****************************************************************************
* Predeclare the interface implementation structures * Predeclare the interface implementation structures
*/ */
@ -39,6 +43,19 @@ typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
#include "ddraw_private.h" #include "ddraw_private.h"
typedef struct STATEBLOCKFLAGS {
BOOL render_state[HIGHEST_RENDER_STATE];
BOOL texture_stage_state[8][HIGHEST_TEXTURE_STAGE_STATE];
BOOL light_state[HIGHEST_LIGHT_STATE];
} STATEBLOCKFLAGS;
typedef struct STATEBLOCK {
STATEBLOCKFLAGS set_flags;
DWORD render_state[HIGHEST_RENDER_STATE];
DWORD texture_stage_state[8][HIGHEST_TEXTURE_STAGE_STATE];
DWORD light_state[HIGHEST_LIGHT_STATE];
} STATEBLOCK;
/***************************************************************************** /*****************************************************************************
* IDirect3D implementation structure. * IDirect3D implementation structure.
* This is common for interfaces 1, 2, 3 and 7. * This is common for interfaces 1, 2, 3 and 7.
@ -212,6 +229,8 @@ struct IDirect3DDeviceImpl
void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices); void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices, void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat); D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
STATEBLOCK state_block;
}; };
/***************************************************************************** /*****************************************************************************

View File

@ -34,6 +34,170 @@
WINE_DEFAULT_DEBUG_CHANNEL(ddraw); WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
DWORD InitRenderStateTab[] = {
/*D3DRENDERSTATE_TEXTUREHANDLE, (DWORD)NULL,*/
D3DRENDERSTATE_ANTIALIAS, D3DANTIALIAS_NONE,
/* FIXME: D3DRENDERSTATE_TEXTUREADDRESS */
D3DRENDERSTATE_TEXTUREPERSPECTIVE, TRUE,
/* FIXME: D3DRENDERSTATE_WRAPU */
/* FIXME: D3DRENDERSTATE_WRAPV */
D3DRENDERSTATE_ZENABLE, FALSE,
D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID,
D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD,
D3DRENDERSTATE_LINEPATTERN, 0,
D3DRENDERSTATE_MONOENABLE, FALSE,
D3DRENDERSTATE_ROP2, R2_COPYPEN,
D3DRENDERSTATE_PLANEMASK, 0xFFFFFFFF,
D3DRENDERSTATE_ZWRITEENABLE, TRUE,
D3DRENDERSTATE_ALPHATESTENABLE, FALSE,
D3DRENDERSTATE_LASTPIXEL, TRUE,
D3DRENDERSTATE_TEXTUREMAG, D3DFILTER_NEAREST,
D3DRENDERSTATE_TEXTUREMIN, D3DFILTER_NEAREST,
D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE,
D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO,
D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE,
D3DRENDERSTATE_CULLMODE, D3DCULL_CCW,
D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL,
D3DRENDERSTATE_ALPHAREF, 0,
D3DRENDERSTATE_ALPHAFUNC, D3DCMP_ALWAYS,
D3DRENDERSTATE_DITHERENABLE, FALSE,
D3DRENDERSTATE_ALPHABLENDENABLE, FALSE,
D3DRENDERSTATE_FOGENABLE, FALSE,
D3DRENDERSTATE_SPECULARENABLE, FALSE,
D3DRENDERSTATE_ZVISIBLE, FALSE,
D3DRENDERSTATE_SUBPIXEL, FALSE,
D3DRENDERSTATE_SUBPIXELX, FALSE,
D3DRENDERSTATE_STIPPLEDALPHA, FALSE,
D3DRENDERSTATE_FOGCOLOR, D3DRGBA(0,0,0,0),
D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE,
/* FIXME: D3DRENDERSTATE_FOGTABLESTART (same as D3DRENDERSTATE_FOGSTART) */
/* FIXME: D3DRENDERSTATE_FOGTABLEEND (same as D3DRENDERSTATE_FOGEND) */
D3DRENDERSTATE_FOGTABLEDENSITY, 0x3F80000, /* 1.0f (same as D3DRENDERSTATE_FOGDENSITY) */
/* FXIME: D3DRENDERSTATE_STIPPLEENABLE */
D3DRENDERSTATE_EDGEANTIALIAS, FALSE,
D3DRENDERSTATE_COLORKEYENABLE, FALSE,
/* FIXME: D3DRENDERSTATE_BORDERCOLOR */
D3DRENDERSTATE_TEXTUREADDRESSU, D3DTADDRESS_WRAP,
D3DRENDERSTATE_TEXTUREADDRESSV, D3DTADDRESS_WRAP,
D3DRENDERSTATE_MIPMAPLODBIAS, 0x00000000, /* 0.0f */
D3DRENDERSTATE_ZBIAS, 0,
D3DRENDERSTATE_RANGEFOGENABLE, FALSE,
/* FIXME: D3DRENDERSTATE_ANISOTROPY */
/* FIXME: D3DRENDERSTATE_FLUSHBATCH */
/* FIXME: D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT */
D3DRENDERSTATE_STENCILENABLE, FALSE,
D3DRENDERSTATE_STENCILFAIL, D3DSTENCILOP_KEEP,
D3DRENDERSTATE_STENCILZFAIL, D3DSTENCILOP_KEEP,
D3DRENDERSTATE_STENCILPASS, D3DSTENCILOP_KEEP,
D3DRENDERSTATE_STENCILFUNC, D3DCMP_ALWAYS,
D3DRENDERSTATE_STENCILREF, 0,
D3DRENDERSTATE_STENCILMASK, 0xFFFFFFFF,
D3DRENDERSTATE_STENCILWRITEMASK, 0xFFFFFFFF,
/* FIXME: D3DRENDERSTATE_TEXTUREFACTOR */
/* FIXME: D3DRENDERSTATE_STIPPLEPATTERN00..31 */
D3DRENDERSTATE_WRAP0, 0,
D3DRENDERSTATE_WRAP1, 0,
D3DRENDERSTATE_WRAP2, 0,
D3DRENDERSTATE_WRAP3, 0,
D3DRENDERSTATE_WRAP4, 0,
D3DRENDERSTATE_WRAP5, 0,
D3DRENDERSTATE_WRAP6, 0,
D3DRENDERSTATE_WRAP7, 0,
D3DRENDERSTATE_CLIPPING, FALSE,
D3DRENDERSTATE_LIGHTING, TRUE,
D3DRENDERSTATE_EXTENTS, FALSE,
D3DRENDERSTATE_AMBIENT, D3DRGBA(0,0,0,0),
D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE,
D3DRENDERSTATE_COLORVERTEX, TRUE,
D3DRENDERSTATE_LOCALVIEWER, TRUE,
D3DRENDERSTATE_NORMALIZENORMALS, FALSE,
/* FIXME: D3DRENDER_STATE_COLORKEYBLENDENABLE */
D3DRENDERSTATE_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1,
D3DRENDERSTATE_SPECULARMATERIALSOURCE, D3DMCS_COLOR2,
D3DRENDERSTATE_AMBIENTMATERIALSOURCE, D3DMCS_COLOR2,
D3DRENDERSTATE_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL,
D3DRENDERSTATE_VERTEXBLEND, D3DVBLEND_DISABLE,
D3DRENDERSTATE_CLIPPLANEENABLE, 0
};
DWORD InitLightStateTab[] = {
D3DLIGHTSTATE_MATERIAL, (DWORD)NULL,
D3DLIGHTSTATE_AMBIENT, D3DRGBA(0,0,0,0),
D3DLIGHTSTATE_COLORMODEL, D3DCOLOR_RGB,
D3DLIGHTSTATE_FOGMODE, D3DFOG_NONE,
D3DLIGHTSTATE_FOGSTART, 0x3F80000, /* 1.0f */
D3DLIGHTSTATE_FOGEND, 0x42C8000, /* 100.0f */
D3DLIGHTSTATE_FOGDENSITY, 0x3F80000 /* 1.0f */
/* FIXME: D3DLIGHTSTATE_COLORVERTEX */
};
DWORD InitTextureStageStateTab[] = {
D3DTSS_COLOROP, D3DTOP_DISABLE,
D3DTSS_COLORARG1, D3DTA_TEXTURE,
D3DTSS_COLORARG2, D3DTA_CURRENT,
D3DTSS_ALPHAOP, D3DTOP_DISABLE,
D3DTSS_ALPHAARG1, D3DTA_TEXTURE,
D3DTSS_ALPHAARG2, D3DTA_CURRENT,
/* FIXME: D3DTSS_BUMPENVMAT00,01,10,11 */
/* D3DTSS_TEXCOORDINDEX is set manually */
D3DTSS_ADDRESS, D3DTADDRESS_WRAP,
D3DTSS_ADDRESSU, D3DTADDRESS_WRAP,
D3DTSS_ADDRESSV, D3DTADDRESS_WRAP,
/* FIXME: D3DTSS_BORDERCOLOR */
D3DTSS_MAGFILTER, D3DTFG_POINT,
D3DTSS_MINFILTER, D3DTFN_POINT,
D3DTSS_MIPFILTER, D3DTFP_NONE,
D3DTSS_MIPMAPLODBIAS, 0x00000000, /* 0.0f */
D3DTSS_MAXMIPLEVEL, 0
/* FIXME: D3DTSS_MAXANISOTROPY */
/* FIXME: D3DTSS_BUMPENVLSCALE */
/* FIXME: D3DTSS_NUMPENVLOFFSET */
/* FIXME: D3DTSS_TEXTURETRANSFORMFLAGS */
};
void InitDefaultStateBlock(STATEBLOCK* lpStateBlock, int version)
{
int i,j;
TRACE("(%p,%d)\n", lpStateBlock, version);
memset(lpStateBlock,0,sizeof(STATEBLOCK));
/* Initialize render states */
for(i=0;i<sizeof(InitRenderStateTab)/4;i+=2)
{
lpStateBlock->render_state[InitRenderStateTab[i]-1] = InitRenderStateTab[i+1];
lpStateBlock->set_flags.render_state[InitRenderStateTab[i]-1] = TRUE;
}
/* Initialize render states */
for(i=0;i<sizeof(InitLightStateTab)/4;i+=2)
{
lpStateBlock->light_state[InitLightStateTab[i]-1] = InitLightStateTab[i+1];
lpStateBlock->set_flags.light_state[InitLightStateTab[i]-1] = TRUE;
}
/* Initialize texture stages states */
for(i=0;i<8;i++)
{
for(j=0;j<sizeof(InitTextureStageStateTab)/4;j+=2)
{
lpStateBlock->texture_stage_state[i][InitTextureStageStateTab[j]-1] = InitTextureStageStateTab[j+1];
lpStateBlock->set_flags.texture_stage_state[i][InitTextureStageStateTab[j]-1] = TRUE;
}
/* Map texture coords 0 to stage 0, 1 to stage 1, etc... */
lpStateBlock->texture_stage_state[i][D3DTSS_TEXCOORDINDEX-1] = i;
lpStateBlock->set_flags.texture_stage_state[i][D3DTSS_TEXCOORDINDEX-1] = TRUE;
}
/* The first texture is particular, update it consequently */
lpStateBlock->texture_stage_state[0][D3DTSS_COLOROP-1] = D3DTOP_MODULATE;
lpStateBlock->texture_stage_state[0][D3DTSS_ALPHAOP-1] = D3DTOP_SELECTARG1;
/* Updates for particular versions */
if ((version == 1)||(version==2))
lpStateBlock->render_state[D3DRENDERSTATE_SPECULARENABLE-1] = TRUE;
}
HRESULT WINAPI HRESULT WINAPI
Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface, Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface,
REFIID riid, REFIID riid,
@ -593,9 +757,13 @@ Main_IDirect3DDeviceImpl_7_3T_GetTextureStageState(LPDIRECT3DDEVICE7 iface,
LPDWORD lpdwState) LPDWORD lpdwState)
{ {
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
FIXME("(%p/%p)->(%08lx,%08x,%p): stub!\n", This, iface, dwStage, d3dTexStageStateType, lpdwState); TRACE("(%p/%p)->(%08lx,%08x,%p)\n", This, iface, dwStage, d3dTexStageStateType, lpdwState);
if (lpdwState && (dwStage < 8) && d3dTexStageStateType && (d3dTexStageStateType < HIGHEST_TEXTURE_STAGE_STATE) ) {
*lpdwState = This->state_block.texture_stage_state[dwStage][d3dTexStageStateType-1];
return DD_OK; return DD_OK;
} }
return DDERR_INVALIDPARAMS;
}
HRESULT WINAPI HRESULT WINAPI
Main_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface, Main_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface,
@ -938,9 +1106,13 @@ Main_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface,
LPDWORD lpdwLightState) LPDWORD lpdwLightState)
{ {
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
FIXME("(%p/%p)->(%08x,%p): stub!\n", This, iface, dwLightStateType, lpdwLightState); TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dwLightStateType, lpdwLightState);
if (lpdwLightState && dwLightStateType && (dwLightStateType <= HIGHEST_LIGHT_STATE) ) {
*lpdwLightState = This->state_block.light_state[dwLightStateType-1];
return DD_OK; return DD_OK;
} }
return DDERR_INVALIDPARAMS;
}
HRESULT WINAPI HRESULT WINAPI
Main_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, Main_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface,

View File

@ -20,6 +20,8 @@
/* This is defined here so as to be able to put them in 'drivers' */ /* This is defined here so as to be able to put them in 'drivers' */
void InitDefaultStateBlock(STATEBLOCK* lpStateBlock, int version);
HRESULT WINAPI HRESULT WINAPI
Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface, Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface,
REFIID riid, REFIID riid,

View File

@ -531,7 +531,23 @@ GL_IDirect3DDeviceImpl_7_3T_2T_SetRenderState(LPDIRECT3DDEVICE7 iface,
TRACE("(%p/%p)->(%08x,%08lx)\n", This, iface, dwRenderStateType, dwRenderState); TRACE("(%p/%p)->(%08x,%08lx)\n", This, iface, dwRenderStateType, dwRenderState);
/* Call the render state functions */ /* Call the render state functions */
set_render_state(dwRenderStateType, dwRenderState, &(glThis->render_state)); set_render_state(glThis, dwRenderStateType, dwRenderState);
store_render_state(dwRenderStateType, dwRenderState, &glThis->parent.state_block);
return DD_OK;
}
HRESULT WINAPI
GL_IDirect3DDeviceImpl_7_3T_2T_GetRenderState(LPDIRECT3DDEVICE7 iface,
D3DRENDERSTATETYPE dwRenderStateType,
LPDWORD lpdwRenderState)
{
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dwRenderStateType, lpdwRenderState);
/* Call the render state functions */
get_render_state(dwRenderStateType, lpdwRenderState, &glThis->parent.state_block);
return DD_OK; return DD_OK;
} }
@ -561,7 +577,7 @@ GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface,
case D3DLIGHTSTATE_AMBIENT: /* 2 */ case D3DLIGHTSTATE_AMBIENT: /* 2 */
/* Call the render_state function... */ /* Call the render_state function... */
set_render_state(D3DRENDERSTATE_AMBIENT, dwLightState, &(glThis->render_state)); set_render_state(glThis, D3DRENDERSTATE_AMBIENT, dwLightState);
break; break;
#define UNSUP(x) case D3DLIGHTSTATE_##x: FIXME("unsupported D3DLIGHTSTATE_" #x "!\n");break; #define UNSUP(x) case D3DLIGHTSTATE_##x: FIXME("unsupported D3DLIGHTSTATE_" #x "!\n");break;
@ -578,6 +594,8 @@ GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface,
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
This->state_block.light_state[dwLightStateType] = dwLightState;
return DD_OK; return DD_OK;
} }
@ -1359,6 +1377,8 @@ GL_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface,
if (TRACE_ON(ddraw)) DPRINTF(" unhandled.\n"); if (TRACE_ON(ddraw)) DPRINTF(" unhandled.\n");
} }
This->state_block.texture_stage_state[dwStage][d3dTexStageStateType-1] = dwState;
return DD_OK; return DD_OK;
} }
@ -1590,7 +1610,7 @@ ICOM_VTABLE(IDirect3DDevice7) VTABLE_IDirect3DDevice7 =
XCAST(SetLight) GL_IDirect3DDeviceImpl_7_SetLight, XCAST(SetLight) GL_IDirect3DDeviceImpl_7_SetLight,
XCAST(GetLight) Main_IDirect3DDeviceImpl_7_GetLight, XCAST(GetLight) Main_IDirect3DDeviceImpl_7_GetLight,
XCAST(SetRenderState) GL_IDirect3DDeviceImpl_7_3T_2T_SetRenderState, XCAST(SetRenderState) GL_IDirect3DDeviceImpl_7_3T_2T_SetRenderState,
XCAST(GetRenderState) Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderState, XCAST(GetRenderState) GL_IDirect3DDeviceImpl_7_3T_2T_GetRenderState,
XCAST(BeginStateBlock) Main_IDirect3DDeviceImpl_7_BeginStateBlock, XCAST(BeginStateBlock) Main_IDirect3DDeviceImpl_7_BeginStateBlock,
XCAST(EndStateBlock) Main_IDirect3DDeviceImpl_7_EndStateBlock, XCAST(EndStateBlock) Main_IDirect3DDeviceImpl_7_EndStateBlock,
XCAST(PreLoad) Main_IDirect3DDeviceImpl_7_PreLoad, XCAST(PreLoad) Main_IDirect3DDeviceImpl_7_PreLoad,
@ -1998,7 +2018,7 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
XVisualInfo *vis; XVisualInfo *vis;
int num; int num;
XVisualInfo template; XVisualInfo template;
GLenum buffer; GLenum buffer = GL_FRONT;
int light; int light;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDeviceGLImpl)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDeviceGLImpl));
@ -2075,27 +2095,15 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
surf->d3ddevice = object; surf->d3ddevice = object;
} }
gl_object->render_state.src = GL_ONE; /* FIXME: Should handle other versions than just 7 */
gl_object->render_state.dst = GL_ZERO; InitDefaultStateBlock(&object->state_block,7);
gl_object->render_state.mag = GL_NEAREST;
gl_object->render_state.min = GL_NEAREST; /* FIXME: These 4 statements are kept for compatibility but should be removed as soon
gl_object->render_state.alpha_ref = 0.0; /* No actual idea about the real default value... */ as they are correctly handled */
gl_object->render_state.alpha_func = GL_ALWAYS; /* Here either but it seems logical */
gl_object->render_state.alpha_blend_enable = FALSE;
gl_object->render_state.fog_on = FALSE; gl_object->render_state.fog_on = FALSE;
gl_object->render_state.stencil_func = GL_ALWAYS;
gl_object->render_state.stencil_mask = 0xFFFFFFFF;
gl_object->render_state.stencil_ref = 0;
gl_object->render_state.stencil_enable = FALSE; gl_object->render_state.stencil_enable = FALSE;
gl_object->render_state.stencil_fail = GL_KEEP;
gl_object->render_state.stencil_zfail = GL_KEEP;
gl_object->render_state.stencil_pass = GL_KEEP;
gl_object->render_state.lighting_enable = FALSE; gl_object->render_state.lighting_enable = FALSE;
gl_object->render_state.specular_enable = FALSE; gl_object->render_state.specular_enable = FALSE;
gl_object->render_state.color_diffuse = D3DMCS_COLOR1;
gl_object->render_state.color_specular = D3DMCS_COLOR2;
gl_object->render_state.color_ambient = D3DMCS_COLOR2;
gl_object->render_state.color_emissive = D3DMCS_MATERIAL;
/* Set the various light parameters */ /* Set the various light parameters */
for (light = 0; light < MAX_LIGHTS; light++) { for (light = 0; light < MAX_LIGHTS; light++) {
@ -2121,7 +2129,13 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
object->set_context(object); object->set_context(object);
ENTER_GL(); ENTER_GL();
TRACE(" current context set\n"); TRACE(" current context set\n");
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
/* Apply default render state values */
/* FIXME: disable because our current D3D code does not like it */
/* apply_render_state(gl_object, &object->state_block); */
/* FIXME: do something similar for ligh_state and texture_stage_state */
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDrawBuffer(buffer); glDrawBuffer(buffer);

View File

@ -460,7 +460,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
LPD3DSTATE ci = (LPD3DSTATE) instr; LPD3DSTATE ci = (LPD3DSTATE) instr;
/* Handle the state transform */ /* Handle the state transform */
set_render_state(ci->u1.drstRenderStateType, ci->u2.dwArg[0], &(lpDeviceGL->render_state)); set_render_state(lpDeviceGL, ci->u1.drstRenderStateType, ci->u2.dwArg[0]);
instr += size; instr += size;
} }

View File

@ -62,9 +62,10 @@ GLenum convert_D3D_stencilop_to_GL(D3DSTENCILOP dwRenderState)
return GL_KEEP; return GL_KEEP;
} }
void set_render_state(D3DRENDERSTATETYPE dwRenderStateType, void set_render_state(IDirect3DDeviceGLImpl* This,
DWORD dwRenderState, RenderState *rs) D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState)
{ {
RenderState* rs = &This->render_state;
if (TRACE_ON(ddraw)) if (TRACE_ON(ddraw))
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState); TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
@ -525,3 +526,27 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
LEAVE_GL(); LEAVE_GL();
} }
} }
void store_render_state(D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState,
STATEBLOCK* lpStateBlock)
{
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
lpStateBlock->render_state[dwRenderStateType-1] = dwRenderState;
}
void get_render_state(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState,
STATEBLOCK* lpStateBlock)
{
*lpdwRenderState = lpStateBlock->render_state[dwRenderStateType-1];
if (TRACE_ON(ddraw))
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), *lpdwRenderState);
}
void apply_render_state(IDirect3DDeviceGLImpl* This, STATEBLOCK* lpStateBlock)
{
DWORD i;
TRACE("(%p,%p)\n", This, lpStateBlock);
for(i=0;i<HIGHEST_RENDER_STATE;i++)
if (lpStateBlock->set_flags.render_state[i])
set_render_state(This, i+1, lpStateBlock->render_state[i]);
}

View File

@ -84,10 +84,6 @@ typedef struct render_state {
BOOLEAN fog_on; BOOLEAN fog_on;
} RenderState; } RenderState;
/* Common functions defined in d3dcommon.c */
void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
DWORD dwRenderState, RenderState *rs) ;
typedef struct IDirect3DGLImpl typedef struct IDirect3DGLImpl
{ {
struct IDirect3DImpl parent; struct IDirect3DImpl parent;
@ -161,6 +157,15 @@ extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context)
extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ; extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice); extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
/* Common functions defined in d3dcommon.c */
void set_render_state(IDirect3DDeviceGLImpl* This,
D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState);
void store_render_state(D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState,
STATEBLOCK* lpStateBlock);
void get_render_state(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState,
STATEBLOCK* lpStateBlock);
void apply_render_state(IDirect3DDeviceGLImpl* This, STATEBLOCK* lpStateBlock);
/* This structure contains all the function pointers to OpenGL extensions /* This structure contains all the function pointers to OpenGL extensions
that are used by Wine */ that are used by Wine */
typedef struct { typedef struct {