- fix in the GetHandle method
- factorize some code between D3D1/2/3 and D3D7 - fix reference counting for palettes
This commit is contained in:
parent
274e72672b
commit
07f1269302
|
@ -312,9 +312,11 @@ GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface)
|
||||||
|
|
||||||
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, This->ref);
|
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, This->ref);
|
||||||
if (!--(This->ref)) {
|
if (!--(This->ref)) {
|
||||||
|
int i;
|
||||||
/* Release texture associated with the device */
|
/* Release texture associated with the device */
|
||||||
if (This->current_texture[0] != NULL)
|
for (i = 0; i < MAX_TEXTURES; i++)
|
||||||
IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[0], IDirect3DTexture2));
|
if (This->current_texture[i] != NULL)
|
||||||
|
IDirectDrawSurface7_Release(ICOM_INTERFACE(This->current_texture[i], IDirectDrawSurface7));
|
||||||
|
|
||||||
/* And warn the D3D object that this device is no longer active... */
|
/* And warn the D3D object that this device is no longer active... */
|
||||||
This->d3d->removed_device(This->d3d, This);
|
This->d3d->removed_device(This->d3d, This);
|
||||||
|
@ -1402,12 +1404,13 @@ GL_IDirect3DDeviceImpl_7_3T_SetTexture(LPDIRECT3DDEVICE7 iface,
|
||||||
TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwStage, lpTexture2);
|
TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwStage, lpTexture2);
|
||||||
|
|
||||||
if (This->current_texture[dwStage] != NULL) {
|
if (This->current_texture[dwStage] != NULL) {
|
||||||
/* Seems that this is not right... Need to test in real Windows
|
IDirectDrawSurface7_Release(ICOM_INTERFACE(This->current_texture[dwStage], IDirectDrawSurface7));
|
||||||
IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[dwStage], IDirect3DTexture2)); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
if (lpTexture2 == NULL) {
|
if (lpTexture2 == NULL) {
|
||||||
|
This->current_texture[dwStage] = NULL;
|
||||||
|
|
||||||
TRACE(" disabling 2D texturing.\n");
|
TRACE(" disabling 2D texturing.\n");
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
@ -2102,9 +2105,6 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
|
||||||
surf->d3ddevice = object;
|
surf->d3ddevice = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Should handle other versions than just 7 */
|
|
||||||
InitDefaultStateBlock(&object->state_block,7);
|
|
||||||
|
|
||||||
/* FIXME: These 4 statements are kept for compatibility but should be removed as soon
|
/* FIXME: These 4 statements are kept for compatibility but should be removed as soon
|
||||||
as they are correctly handled */
|
as they are correctly handled */
|
||||||
gl_object->render_state.fog_on = FALSE;
|
gl_object->render_state.fog_on = FALSE;
|
||||||
|
@ -2137,10 +2137,6 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
TRACE(" current context set\n");
|
TRACE(" current context set\n");
|
||||||
|
|
||||||
/* Apply default render state values */
|
|
||||||
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);
|
||||||
|
@ -2161,6 +2157,12 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
|
||||||
|
|
||||||
/* And finally warn D3D that this device is now present */
|
/* And finally warn D3D that this device is now present */
|
||||||
object->d3d->added_device(object->d3d, object);
|
object->d3d->added_device(object->d3d, object);
|
||||||
|
|
||||||
|
/* FIXME: Should handle other versions than just 7 */
|
||||||
|
InitDefaultStateBlock(&object->state_block,7);
|
||||||
|
/* Apply default render state values */
|
||||||
|
apply_render_state(gl_object, &object->state_block);
|
||||||
|
/* FIXME: do something similar for ligh_state and texture_stage_state */
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,8 +496,19 @@ Main_IDirect3DTextureImpl_2_1T_GetHandle(LPDIRECT3DTEXTURE2 iface,
|
||||||
LPD3DTEXTUREHANDLE lpHandle)
|
LPD3DTEXTUREHANDLE lpHandle)
|
||||||
{
|
{
|
||||||
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirect3DTexture2, iface);
|
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirect3DTexture2, iface);
|
||||||
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpDirect3DDevice2, lpHandle);
|
IDirect3DDeviceImpl *lpDeviceImpl = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice2, lpDirect3DDevice2);
|
||||||
return DD_OK;
|
|
||||||
|
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpDirect3DDevice2, lpHandle);
|
||||||
|
|
||||||
|
/* The handle is simply the pointer to the implementation structure */
|
||||||
|
*lpHandle = (D3DTEXTUREHANDLE) This;
|
||||||
|
|
||||||
|
TRACE(" returning handle %08lx.\n", *lpHandle);
|
||||||
|
|
||||||
|
/* Now set the device for this texture */
|
||||||
|
This->d3ddevice = lpDeviceImpl;
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
|
@ -525,9 +536,10 @@ gltex_final_release(IDirectDrawSurfaceImpl *This)
|
||||||
{
|
{
|
||||||
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
||||||
DWORD mem_used;
|
DWORD mem_used;
|
||||||
|
int i;
|
||||||
|
|
||||||
TRACE(" deleting texture with GL id %d.\n", glThis->tex_name);
|
TRACE(" deleting texture with GL id %d.\n", glThis->tex_name);
|
||||||
|
|
||||||
/* And delete texture handle */
|
/* And delete texture handle */
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
if (glThis->tex_name != 0)
|
if (glThis->tex_name != 0)
|
||||||
|
@ -536,8 +548,9 @@ gltex_final_release(IDirectDrawSurfaceImpl *This)
|
||||||
|
|
||||||
/* And if this texture was the current one, remove it at the device level */
|
/* And if this texture was the current one, remove it at the device level */
|
||||||
if (This->d3ddevice != NULL)
|
if (This->d3ddevice != NULL)
|
||||||
if (This->d3ddevice->current_texture[0] == This)
|
for (i = 0; i < MAX_TEXTURES; i++)
|
||||||
This->d3ddevice->current_texture[0] = NULL;
|
if (This->d3ddevice->current_texture[i] == This)
|
||||||
|
This->d3ddevice->current_texture[i] = NULL;
|
||||||
|
|
||||||
/* All this should be part of main surface management not just a hack for texture.. */
|
/* All this should be part of main surface management not just a hack for texture.. */
|
||||||
if (glThis->loaded) {
|
if (glThis->loaded) {
|
||||||
|
@ -569,37 +582,6 @@ gltex_unlock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
|
||||||
glThis->dirty_flag = TRUE;
|
glThis->dirty_flag = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI
|
|
||||||
GL_IDirect3DTextureImpl_2_1T_GetHandle(LPDIRECT3DTEXTURE2 iface,
|
|
||||||
LPDIRECT3DDEVICE2 lpDirect3DDevice2,
|
|
||||||
LPD3DTEXTUREHANDLE lpHandle)
|
|
||||||
{
|
|
||||||
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirect3DTexture2, iface);
|
|
||||||
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
|
||||||
IDirect3DDeviceImpl *lpDeviceImpl = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice2, lpDirect3DDevice2);
|
|
||||||
|
|
||||||
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpDirect3DDevice2, lpHandle);
|
|
||||||
|
|
||||||
/* The handle is simply the pointer to the implementation structure */
|
|
||||||
*lpHandle = (D3DTEXTUREHANDLE) This;
|
|
||||||
|
|
||||||
TRACE(" returning handle %08lx.\n", *lpHandle);
|
|
||||||
|
|
||||||
/* Now, bind a new texture */
|
|
||||||
This->d3ddevice = lpDeviceImpl;
|
|
||||||
|
|
||||||
/* Associate the texture with the device and perform the appropriate AddRef/Release */
|
|
||||||
/* FIXME: Is there only one or several textures associated with the device ? */
|
|
||||||
if (lpDeviceImpl->current_texture[0] != NULL)
|
|
||||||
IDirectDrawSurface7_Release(ICOM_INTERFACE(lpDeviceImpl->current_texture[0], IDirectDrawSurface7));
|
|
||||||
IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This, IDirectDrawSurface7));
|
|
||||||
lpDeviceImpl->current_texture[0] = This;
|
|
||||||
|
|
||||||
TRACE("OpenGL texture handle is : %d\n", glThis->tex_name);
|
|
||||||
|
|
||||||
return D3D_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
||||||
LPDIRECT3DTEXTURE2 lpD3DTexture2)
|
LPDIRECT3DTEXTURE2 lpD3DTexture2)
|
||||||
|
@ -641,12 +623,11 @@ GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
||||||
if (This->palette == NULL) {
|
if (This->palette == NULL) {
|
||||||
This->palette = lpD3DTextureImpl->palette;
|
This->palette = lpD3DTextureImpl->palette;
|
||||||
if (lpD3DTextureImpl->palette != NULL) IDirectDrawPalette_AddRef(ICOM_INTERFACE(lpD3DTextureImpl->palette,
|
if (lpD3DTextureImpl->palette != NULL) IDirectDrawPalette_AddRef(ICOM_INTERFACE(lpD3DTextureImpl->palette,
|
||||||
IDirectDrawPalette));
|
IDirectDrawPalette));
|
||||||
} else {
|
} else {
|
||||||
if (lpD3DTextureImpl->palette != NULL) {
|
if (lpD3DTextureImpl->palette != NULL) {
|
||||||
PALETTEENTRY palent[256];
|
PALETTEENTRY palent[256];
|
||||||
IDirectDrawPalette *pal_int = ICOM_INTERFACE(lpD3DTextureImpl->palette, IDirectDrawPalette);
|
IDirectDrawPalette *pal_int = ICOM_INTERFACE(lpD3DTextureImpl->palette, IDirectDrawPalette);
|
||||||
IDirectDrawPalette_AddRef(pal_int);
|
|
||||||
IDirectDrawPalette_GetEntries(pal_int, 0, 0, 256, palent);
|
IDirectDrawPalette_GetEntries(pal_int, 0, 0, 256, palent);
|
||||||
IDirectDrawPalette_SetEntries(ICOM_INTERFACE(This->palette, IDirectDrawPalette),
|
IDirectDrawPalette_SetEntries(ICOM_INTERFACE(This->palette, IDirectDrawPalette),
|
||||||
0, 0, 256, palent);
|
0, 0, 256, palent);
|
||||||
|
@ -667,6 +648,7 @@ GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
||||||
|
|
||||||
/* Copy also the ColorKeying stuff */
|
/* Copy also the ColorKeying stuff */
|
||||||
if (src_d->dwFlags & DDSD_CKSRCBLT) {
|
if (src_d->dwFlags & DDSD_CKSRCBLT) {
|
||||||
|
dst_d->dwFlags |= DDSD_CKSRCBLT;
|
||||||
dst_d->ddckCKSrcBlt.dwColorSpaceLowValue = src_d->ddckCKSrcBlt.dwColorSpaceLowValue;
|
dst_d->ddckCKSrcBlt.dwColorSpaceLowValue = src_d->ddckCKSrcBlt.dwColorSpaceLowValue;
|
||||||
dst_d->ddckCKSrcBlt.dwColorSpaceHighValue = src_d->ddckCKSrcBlt.dwColorSpaceHighValue;
|
dst_d->ddckCKSrcBlt.dwColorSpaceHighValue = src_d->ddckCKSrcBlt.dwColorSpaceHighValue;
|
||||||
}
|
}
|
||||||
|
@ -780,7 +762,7 @@ ICOM_VTABLE(IDirect3DTexture2) VTABLE_IDirect3DTexture2 =
|
||||||
XCAST(QueryInterface) Thunk_IDirect3DTextureImpl_2_QueryInterface,
|
XCAST(QueryInterface) Thunk_IDirect3DTextureImpl_2_QueryInterface,
|
||||||
XCAST(AddRef) Thunk_IDirect3DTextureImpl_2_AddRef,
|
XCAST(AddRef) Thunk_IDirect3DTextureImpl_2_AddRef,
|
||||||
XCAST(Release) Thunk_IDirect3DTextureImpl_2_Release,
|
XCAST(Release) Thunk_IDirect3DTextureImpl_2_Release,
|
||||||
XCAST(GetHandle) GL_IDirect3DTextureImpl_2_1T_GetHandle,
|
XCAST(GetHandle) Main_IDirect3DTextureImpl_2_1T_GetHandle,
|
||||||
XCAST(PaletteChanged) Main_IDirect3DTextureImpl_2_1T_PaletteChanged,
|
XCAST(PaletteChanged) Main_IDirect3DTextureImpl_2_1T_PaletteChanged,
|
||||||
XCAST(Load) GL_IDirect3DTextureImpl_2_1T_Load,
|
XCAST(Load) GL_IDirect3DTextureImpl_2_1T_Load,
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,23 +81,12 @@ void set_render_state(IDirect3DDeviceGLImpl* This,
|
||||||
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
|
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
|
||||||
IDirectDrawSurfaceImpl *tex = (IDirectDrawSurfaceImpl*) dwRenderState;
|
IDirectDrawSurfaceImpl *tex = (IDirectDrawSurfaceImpl*) dwRenderState;
|
||||||
|
|
||||||
if (tex == NULL) {
|
LEAVE_GL();
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
IDirect3DDevice7_SetTexture(ICOM_INTERFACE(&(This->parent), IDirect3DDevice7),
|
||||||
glDisable(GL_TEXTURE_2D);
|
0,
|
||||||
TRACE("disabling texturing\n");
|
ICOM_INTERFACE(tex, IDirectDrawSurface7));
|
||||||
} else {
|
ENTER_GL();
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
/* Default parameters */
|
|
||||||
gltex_upload_texture(tex);
|
|
||||||
|
|
||||||
/* To prevent state change, we could test here what are the parameters
|
|
||||||
stored in the texture */
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, rs->mag);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, rs->min);
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
||||||
case D3DRENDERSTATE_TEXTUREADDRESSU: /* 44 */
|
case D3DRENDERSTATE_TEXTUREADDRESSU: /* 44 */
|
||||||
case D3DRENDERSTATE_TEXTUREADDRESSV: /* 45 */
|
case D3DRENDERSTATE_TEXTUREADDRESSV: /* 45 */
|
||||||
|
|
Loading…
Reference in New Issue