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,
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_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");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u1.dwRGBBitCount = 16;
......@@ -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_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");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u1.dwRGBBitCount = 16;
......@@ -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_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");
pformat->dwFlags = DDPF_RGB;
pformat->u1.dwRGBBitCount = 8;
......
......@@ -735,6 +735,11 @@ Main_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags,
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey);
if (TRACE_ON(ddraw)) {
TRACE(" - colorkey flags : ");
DDRAW_dump_colorkeyflag(dwFlags);
}
switch (dwFlags)
{
case DDCKEY_DESTBLT:
......@@ -1095,37 +1100,73 @@ Main_DirectDrawSurface_SetColorKey(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPDDCOLORKEY pCKey)
{
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey);
if (pCKey == NULL)
{
FIXME("supposedly removing color key %lu\n",
dwFlags & ~DDCKEY_COLORSPACE);
return DD_OK;
if (TRACE_ON(ddraw)) {
TRACE(" - colorkey flags : ");
DDRAW_dump_colorkeyflag(dwFlags);
}
switch (dwFlags & ~DDCKEY_COLORSPACE)
{
case DDCKEY_DESTBLT:
This->surface_desc.ddckCKDestBlt = *pCKey;
break;
if ((dwFlags & DDCKEY_COLORSPACE) != 0) {
FIXME(" colorkey value not supported (%08lx) !\n", dwFlags);
return DDERR_INVALIDPARAMS;
}
/* 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:
This->surface_desc.u3.ddckCKDestOverlay = *pCKey;
break;
case DDCKEY_DESTOVERLAY:
This->surface_desc.u3.ddckCKDestOverlay = *pCKey;
This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
break;
case DDCKEY_SRCOVERLAY:
This->surface_desc.ddckCKSrcOverlay = *pCKey;
break;
case DDCKEY_SRCOVERLAY:
This->surface_desc.ddckCKSrcOverlay = *pCKey;
This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
break;
case DDCKEY_SRCBLT:
This->surface_desc.ddckCKSrcBlt = *pCKey;
break;
case DDCKEY_SRCBLT:
This->surface_desc.ddckCKSrcBlt = *pCKey;
This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
break;
default:
return DDERR_INVALIDPARAMS;
default:
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;
}
......
......@@ -401,6 +401,7 @@ void set_render_state(IDirect3DDeviceGLImpl* This,
case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */
/* This needs to be fixed. */
if (dwRenderState)
glEnable(GL_BLEND);
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