- factorize Clear method between Viewport and Device
- some more rendering states handled
This commit is contained in:
parent
5f78568b53
commit
608da067ac
|
@ -175,6 +175,13 @@ struct IDirect3DDeviceImpl
|
|||
IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
|
||||
|
||||
void (*set_context)(IDirect3DDeviceImpl*);
|
||||
HRESULT (*clear)(IDirect3DDeviceImpl *This,
|
||||
DWORD dwCount,
|
||||
LPD3DRECT lpRects,
|
||||
DWORD dwFlags,
|
||||
DWORD dwColor,
|
||||
D3DVALUE dvZ,
|
||||
DWORD dwStencil);
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -191,8 +191,8 @@ Main_IDirect3DDeviceImpl_7_Clear(LPDIRECT3DDEVICE7 iface,
|
|||
DWORD dwStencil)
|
||||
{
|
||||
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
|
||||
FIXME("(%p/%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx): stub!\n", This, iface, dwCount, lpRects, dwFlags, (DWORD) dwColor, dvZ, dwStencil);
|
||||
return DD_OK;
|
||||
TRACE("(%p/%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, iface, dwCount, lpRects, dwFlags, (DWORD) dwColor, dvZ, dwStencil);
|
||||
return This->clear(This, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
|
|
@ -1575,6 +1575,83 @@ ICOM_VTABLE(IDirect3DDevice) VTABLE_IDirect3DDevice =
|
|||
#undef XCAST
|
||||
#endif
|
||||
|
||||
static HRESULT d3ddevice_clear(IDirect3DDeviceImpl *This,
|
||||
DWORD dwCount,
|
||||
LPD3DRECT lpRects,
|
||||
DWORD dwFlags,
|
||||
DWORD dwColor,
|
||||
D3DVALUE dvZ,
|
||||
DWORD dwStencil)
|
||||
{
|
||||
GLboolean ztest;
|
||||
GLfloat old_z_clear_value;
|
||||
GLbitfield bitfield = 0;
|
||||
GLint old_stencil_clear_value;
|
||||
GLfloat old_color_clear_value[4];
|
||||
|
||||
TRACE("(%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
|
||||
if (TRACE_ON(ddraw)) {
|
||||
int i;
|
||||
TRACE(" rectangles : \n");
|
||||
for (i = 0; i < dwCount; i++) {
|
||||
TRACE(" - %ld x %ld %ld x %ld\n", lpRects[i].u1.x1, lpRects[i].u2.y1, lpRects[i].u3.x2, lpRects[i].u4.y2);
|
||||
}
|
||||
}
|
||||
|
||||
if (dwCount != 1) {
|
||||
WARN(" Warning, this function only for now clears the whole screen...\n");
|
||||
}
|
||||
|
||||
/* Clears the screen */
|
||||
ENTER_GL();
|
||||
if (dwFlags & D3DCLEAR_ZBUFFER) {
|
||||
bitfield |= GL_DEPTH_BUFFER_BIT;
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &ztest);
|
||||
glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value);
|
||||
glClearDepth(dvZ);
|
||||
TRACE(" depth value : %f\n", dvZ);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_STENCIL) {
|
||||
bitfield |= GL_STENCIL_BUFFER_BIT;
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value);
|
||||
glClearStencil(dwStencil);
|
||||
TRACE(" stencil value : %ld\n", dwStencil);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_TARGET) {
|
||||
bitfield |= GL_COLOR_BUFFER_BIT;
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
|
||||
glClearColor(((dwColor >> 16) & 0xFF) / 255.0,
|
||||
((dwColor >> 8) & 0xFF) / 255.0,
|
||||
((dwColor >> 0) & 0xFF) / 255.0,
|
||||
((dwColor >> 24) & 0xFF) / 255.0);
|
||||
TRACE(" color value (ARGB) : %08lx\n", dwColor);
|
||||
}
|
||||
|
||||
glClear(bitfield);
|
||||
|
||||
if (dwFlags & D3DCLEAR_ZBUFFER) {
|
||||
glDepthMask(ztest);
|
||||
glClearDepth(old_z_clear_value);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_STENCIL) {
|
||||
bitfield |= GL_STENCIL_BUFFER_BIT;
|
||||
glClearStencil(old_stencil_clear_value);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_TARGET) {
|
||||
bitfield |= GL_COLOR_BUFFER_BIT;
|
||||
glClearColor(old_color_clear_value[0],
|
||||
old_color_clear_value[1],
|
||||
old_color_clear_value[2],
|
||||
old_color_clear_value[3]);
|
||||
}
|
||||
|
||||
LEAVE_GL();
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
||||
/* TODO for both these functions :
|
||||
- change / restore OpenGL parameters for pictures transfers in case they are ever modified
|
||||
by other OpenGL code in D3D
|
||||
|
@ -1689,6 +1766,7 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
|
|||
object->d3d = d3d;
|
||||
object->surface = surface;
|
||||
object->set_context = set_context;
|
||||
object->clear = d3ddevice_clear;
|
||||
|
||||
TRACE(" creating OpenGL device for surface = %p, d3d = %p\n", surface, d3d);
|
||||
|
||||
|
|
|
@ -233,8 +233,12 @@ Main_IDirect3DViewportImpl_3_2_1_Clear(LPDIRECT3DVIEWPORT3 iface,
|
|||
DWORD dwFlags)
|
||||
{
|
||||
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
|
||||
FIXME("(%p/%p)->(%08lx,%p,%08lx): stub!\n", This, iface, dwCount, lpRects, dwFlags);
|
||||
return DD_OK;
|
||||
TRACE("(%p/%p)->(%08lx,%p,%08lx)\n", This, iface, dwCount, lpRects, dwFlags);
|
||||
if (This->active_device == NULL) {
|
||||
ERR(" Trying to clear a viewport not attached to a device !\n");
|
||||
return D3DERR_VIEWPORTHASNODEVICE;
|
||||
}
|
||||
return This->active_device->clear(This->active_device, dwCount, lpRects, dwFlags, 0x00000000, 0.0, 0x00000000);
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
@ -362,106 +366,12 @@ Main_IDirect3DViewportImpl_3_Clear2(LPDIRECT3DVIEWPORT3 iface,
|
|||
DWORD dwStencil)
|
||||
{
|
||||
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
|
||||
FIXME("(%p/%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx): stub!\n", This, iface, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
GL_IDirect3DViewportImpl_3_2_1_Clear(LPDIRECT3DVIEWPORT3 iface,
|
||||
DWORD dwCount,
|
||||
LPD3DRECT lpRects,
|
||||
DWORD dwFlags)
|
||||
{
|
||||
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
|
||||
GLboolean ztest;
|
||||
|
||||
TRACE("(%p/%p)->(%08lx,%p,%08lx)\n", This, iface, dwCount, lpRects, dwFlags);
|
||||
|
||||
if (dwCount != 1) {
|
||||
WARN(" Warning, this function only for now clears the whole screen...\n");
|
||||
}
|
||||
|
||||
/* Clears the screen */
|
||||
ENTER_GL();
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &ztest);
|
||||
glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
|
||||
glClear(((dwFlags & D3DCLEAR_TARGET) ? GL_COLOR_BUFFER_BIT : 0) |
|
||||
((dwFlags & D3DCLEAR_ZBUFFER) ? GL_DEPTH_BUFFER_BIT : 0));
|
||||
glDepthMask(ztest);
|
||||
LEAVE_GL();
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
GL_IDirect3DViewportImpl_3_Clear2(LPDIRECT3DVIEWPORT3 iface,
|
||||
DWORD dwCount,
|
||||
LPD3DRECT lpRects,
|
||||
DWORD dwFlags,
|
||||
DWORD dwColor,
|
||||
D3DVALUE dvZ,
|
||||
DWORD dwStencil)
|
||||
{
|
||||
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
|
||||
GLboolean ztest;
|
||||
GLfloat old_z_clear_value;
|
||||
GLbitfield bitfield = 0;
|
||||
GLint old_stencil_clear_value;
|
||||
GLfloat old_color_clear_value[4];
|
||||
|
||||
TRACE("(%p/%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, iface, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
|
||||
|
||||
if (dwCount != 1) {
|
||||
WARN(" Warning, this function only for now clears the whole screen...\n");
|
||||
if (This->active_device == NULL) {
|
||||
ERR(" Trying to clear a viewport not attached to a device !\n");
|
||||
return D3DERR_VIEWPORTHASNODEVICE;
|
||||
}
|
||||
|
||||
/* Clears the screen */
|
||||
ENTER_GL();
|
||||
if (dwFlags & D3DCLEAR_ZBUFFER) {
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &ztest);
|
||||
glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value);
|
||||
glClearDepth(dvZ);
|
||||
TRACE(" Depth value : %f\n", dvZ);
|
||||
bitfield |= GL_DEPTH_BUFFER_BIT;
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_STENCIL) {
|
||||
bitfield |= GL_STENCIL_BUFFER_BIT;
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value);
|
||||
glClearStencil(dwStencil);
|
||||
TRACE(" Stencil value : %ld\n", dwStencil);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_TARGET) {
|
||||
bitfield |= GL_COLOR_BUFFER_BIT;
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
|
||||
glClearColor(((dwColor >> 16) & 0xFF) / 255.0,
|
||||
((dwColor >> 8) & 0xFF) / 255.0,
|
||||
((dwColor >> 0) & 0xFF) / 255.0,
|
||||
((dwColor >> 24) & 0xFF) / 255.0);
|
||||
TRACE("Color value (ARGB) : %08lx\n", dwColor);
|
||||
}
|
||||
|
||||
glClear(bitfield);
|
||||
|
||||
if (dwFlags & D3DCLEAR_ZBUFFER) {
|
||||
glDepthMask(ztest);
|
||||
glClearDepth(old_z_clear_value);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_STENCIL) {
|
||||
bitfield |= GL_STENCIL_BUFFER_BIT;
|
||||
glClearStencil(old_stencil_clear_value);
|
||||
}
|
||||
if (dwFlags & D3DCLEAR_TARGET) {
|
||||
bitfield |= GL_COLOR_BUFFER_BIT;
|
||||
glClearColor(old_color_clear_value[0],
|
||||
old_color_clear_value[1],
|
||||
old_color_clear_value[2],
|
||||
old_color_clear_value[3]);
|
||||
}
|
||||
|
||||
LEAVE_GL();
|
||||
|
||||
return DD_OK;
|
||||
return This->active_device->clear(This->active_device, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
|
||||
}
|
||||
|
||||
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
||||
|
@ -485,7 +395,7 @@ ICOM_VTABLE(IDirect3DViewport3) VTABLE_IDirect3DViewport3 =
|
|||
XCAST(GetBackground) Main_IDirect3DViewportImpl_3_2_1_GetBackground,
|
||||
XCAST(SetBackgroundDepth) Main_IDirect3DViewportImpl_3_2_1_SetBackgroundDepth,
|
||||
XCAST(GetBackgroundDepth) Main_IDirect3DViewportImpl_3_2_1_GetBackgroundDepth,
|
||||
XCAST(Clear) GL_IDirect3DViewportImpl_3_2_1_Clear,
|
||||
XCAST(Clear) Main_IDirect3DViewportImpl_3_2_1_Clear,
|
||||
XCAST(AddLight) Main_IDirect3DViewportImpl_3_2_1_AddLight,
|
||||
XCAST(DeleteLight) Main_IDirect3DViewportImpl_3_2_1_DeleteLight,
|
||||
XCAST(NextLight) Main_IDirect3DViewportImpl_3_2_1_NextLight,
|
||||
|
@ -493,7 +403,7 @@ ICOM_VTABLE(IDirect3DViewport3) VTABLE_IDirect3DViewport3 =
|
|||
XCAST(SetViewport2) Main_IDirect3DViewportImpl_3_2_SetViewport2,
|
||||
XCAST(SetBackgroundDepth2) Main_IDirect3DViewportImpl_3_SetBackgroundDepth2,
|
||||
XCAST(GetBackgroundDepth2) Main_IDirect3DViewportImpl_3_GetBackgroundDepth2,
|
||||
XCAST(Clear2) GL_IDirect3DViewportImpl_3_Clear2,
|
||||
XCAST(Clear2) Main_IDirect3DViewportImpl_3_Clear2,
|
||||
};
|
||||
|
||||
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
||||
|
|
|
@ -297,6 +297,11 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
|
|||
/* We do not support this anyway, so why protest :-) */
|
||||
break;
|
||||
|
||||
case D3DRENDERSTATE_STIPPLEDALPHA: /* 33 */
|
||||
if (dwRenderState)
|
||||
ERR(" Stippled Alpha not supported yet.\n");
|
||||
break;
|
||||
|
||||
case D3DRENDERSTATE_FOGCOLOR: { /* 34 */
|
||||
GLint color[4];
|
||||
color[0] = (dwRenderState >> 16) & 0xFF;
|
||||
|
@ -331,6 +336,15 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
|
|||
case D3DRENDERSTATE_FLUSHBATCH: /* 50 */
|
||||
break;
|
||||
|
||||
case D3DRENDERSTATE_LIGHTING: /* 137 */
|
||||
/* There will be more to do here once we really support D3D7 Lighting.
|
||||
Should be enough for now to prevent warnings :-) */
|
||||
if (dwRenderState)
|
||||
glEnable(GL_LIGHTING);
|
||||
else
|
||||
glDisable(GL_LIGHTING);
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("Unhandled dwRenderStateType %s (%08x) !\n", _get_renderstate(dwRenderStateType), dwRenderStateType);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue