Commit cec93d0a authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- re-activate the color-keying code

- fix yet again texture enumeration to please all games :-/
parent b110a962
...@@ -415,16 +415,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, ...@@ -415,16 +415,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1,
if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_5_5_5_1 (16)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u1.dwRGBBitCount = 16;
pformat->u2.dwRBitMask = 0x0000F800;
pformat->u3.dwGBitMask = 0x000007C0;
pformat->u4.dwBBitMask = 0x0000003E;
pformat->u5.dwRGBAlphaBitMask = 0x00000001;
if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (ARGB) (16)\n"); TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (ARGB) (16)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u1.dwRGBBitCount = 16; pformat->u1.dwRGBBitCount = 16;
...@@ -435,6 +425,12 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, ...@@ -435,6 +425,12 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1,
if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
#if 0
/* This is a compromise : some games choose the first 16 bit texture format with alpha they
find enumerated, others the last one. And both want to have the ARGB one.
So basically, forget our OpenGL roots and do not even enumerate our RGBA ones.
*/
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n"); TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u1.dwRGBBitCount = 16; pformat->u1.dwRGBBitCount = 16;
...@@ -445,6 +441,17 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, ...@@ -445,6 +441,17 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1,
if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_5_5_5_1 (16)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u1.dwRGBBitCount = 16;
pformat->u2.dwRBitMask = 0x0000F800;
pformat->u3.dwGBitMask = 0x000007C0;
pformat->u4.dwBBitMask = 0x0000003E;
pformat->u5.dwRGBAlphaBitMask = 0x00000001;
if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
#endif
TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n"); TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n");
pformat->dwFlags = DDPF_RGB; pformat->dwFlags = DDPF_RGB;
pformat->u1.dwRGBBitCount = 8; pformat->u1.dwRGBBitCount = 8;
......
...@@ -735,6 +735,11 @@ Main_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags, ...@@ -735,6 +735,11 @@ Main_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags,
ICOM_THIS(IDirectDrawSurfaceImpl, iface); ICOM_THIS(IDirectDrawSurfaceImpl, iface);
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey); TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey);
if (TRACE_ON(ddraw)) {
TRACE(" - colorkey flags : ");
DDRAW_dump_colorkeyflag(dwFlags);
}
switch (dwFlags) switch (dwFlags)
{ {
case DDCKEY_DESTBLT: case DDCKEY_DESTBLT:
...@@ -1095,37 +1100,73 @@ Main_DirectDrawSurface_SetColorKey(LPDIRECTDRAWSURFACE7 iface, ...@@ -1095,37 +1100,73 @@ Main_DirectDrawSurface_SetColorKey(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPDDCOLORKEY pCKey) DWORD dwFlags, LPDDCOLORKEY pCKey)
{ {
ICOM_THIS(IDirectDrawSurfaceImpl, iface); ICOM_THIS(IDirectDrawSurfaceImpl, iface);
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey); TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey);
if (pCKey == NULL)
{ if (TRACE_ON(ddraw)) {
FIXME("supposedly removing color key %lu\n", TRACE(" - colorkey flags : ");
dwFlags & ~DDCKEY_COLORSPACE); DDRAW_dump_colorkeyflag(dwFlags);
return DD_OK;
} }
switch (dwFlags & ~DDCKEY_COLORSPACE) if ((dwFlags & DDCKEY_COLORSPACE) != 0) {
{ FIXME(" colorkey value not supported (%08lx) !\n", dwFlags);
case DDCKEY_DESTBLT: return DDERR_INVALIDPARAMS;
This->surface_desc.ddckCKDestBlt = *pCKey; }
break;
/* TODO: investigate if this function can take multiple bits set at the same
time (ie setting multiple colorkey values at the same time with only
one API call).
*/
if (pCKey) {
switch (dwFlags & ~DDCKEY_COLORSPACE) {
case DDCKEY_DESTBLT:
This->surface_desc.ddckCKDestBlt = *pCKey;
This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
break;
case DDCKEY_DESTOVERLAY: case DDCKEY_DESTOVERLAY:
This->surface_desc.u3.ddckCKDestOverlay = *pCKey; This->surface_desc.u3.ddckCKDestOverlay = *pCKey;
break; This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
break;
case DDCKEY_SRCOVERLAY: case DDCKEY_SRCOVERLAY:
This->surface_desc.ddckCKSrcOverlay = *pCKey; This->surface_desc.ddckCKSrcOverlay = *pCKey;
break; This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
break;
case DDCKEY_SRCBLT: case DDCKEY_SRCBLT:
This->surface_desc.ddckCKSrcBlt = *pCKey; This->surface_desc.ddckCKSrcBlt = *pCKey;
break; This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
break;
default: default:
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
}
} else {
switch (dwFlags & ~DDCKEY_COLORSPACE) {
case DDCKEY_DESTBLT:
This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
break;
case DDCKEY_DESTOVERLAY:
This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
break;
case DDCKEY_SRCOVERLAY:
This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
break;
case DDCKEY_SRCBLT:
This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
break;
default:
return DDERR_INVALIDPARAMS;
}
} }
if (This->aux_setcolorkey_cb) This->aux_setcolorkey_cb(This, dwFlags, pCKey);
return DD_OK; return DD_OK;
} }
......
...@@ -401,6 +401,7 @@ void set_render_state(IDirect3DDeviceGLImpl* This, ...@@ -401,6 +401,7 @@ void set_render_state(IDirect3DDeviceGLImpl* This,
case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */ case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */
/* This needs to be fixed. */
if (dwRenderState) if (dwRenderState)
glEnable(GL_BLEND); glEnable(GL_BLEND);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment