From 9914a8ec5dd82e77991b3f91fedda17e1447fa8c Mon Sep 17 00:00:00 2001 From: Lionel Ulmer Date: Thu, 8 May 2003 21:03:57 +0000 Subject: [PATCH] - only enumerate 32 bpp ARGB texture format and remove RGBA one - add support for 32 bpp ARGB texture format --- dlls/ddraw/d3ddevice/mesa.c | 13 +++++++++++++ dlls/ddraw/d3dtexture.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index aa23795733b..743215c4057 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -385,6 +385,8 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, pformat->dwSize = sizeof(DDPIXELFORMAT); pformat->dwFourCC = 0; +#if 0 + /* See argument about the RGBA format for 'packed' texture formats */ TRACE("Enumerating GL_RGBA unpacked (32)\n"); pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; pformat->u1.dwRGBBitCount = 32; @@ -394,6 +396,17 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, pformat->u5.dwRGBAlphaBitMask = 0x000000FF; 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_RGBA unpacked (32)\n"); + pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; + pformat->u1.dwRGBBitCount = 32; + pformat->u2.dwRBitMask = 0x00FF0000; + pformat->u3.dwGBitMask = 0x0000FF00; + pformat->u4.dwBBitMask = 0x000000FF; + pformat->u5.dwRGBAlphaBitMask = 0xFF000000; + 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_RGB unpacked (24)\n"); pformat->dwFlags = DDPF_RGB; diff --git a/dlls/ddraw/d3dtexture.c b/dlls/ddraw/d3dtexture.c index 04b0859daeb..644423e7e27 100644 --- a/dlls/ddraw/d3dtexture.c +++ b/dlls/ddraw/d3dtexture.c @@ -383,6 +383,35 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This) { } format = GL_RGBA; pixel_format = GL_UNSIGNED_INT_8_8_8_8; + } else if ((src_d->ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) && + (src_d->ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) && + (src_d->ddpfPixelFormat.u4.dwBBitMask == 0x000000FF) && + (src_d->ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0xFF000000)) { + /* Convert from ARGB (Windows' format) to RGBA. + Note: need to check for GL extensions handling ARGB instead of always converting */ + DWORD i; + DWORD *src = (DWORD *) src_d->lpSurface, *dst; + + surface = (DWORD *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, src_d->dwWidth * src_d->dwHeight * sizeof(DWORD)); + dst = (DWORD *) surface; + if (src_d->dwFlags & DDSD_CKSRCBLT) { + for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) { + DWORD color = *src++; + *dst = (color & 0x00FFFFFF) << 8; + if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) || + (color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue)) + *dst |= (color & 0xFF000000) >> 24; + dst++; + } + } else { + for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) { + DWORD color = *src++; + *dst = (color & 0x00FFFFFF) << 8; + *dst |= (color & 0xFF000000) >> 24; + } + } + format = GL_RGBA; + pixel_format = GL_UNSIGNED_INT_8_8_8_8; } else if ((src_d->ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) && (src_d->ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) && (src_d->ddpfPixelFormat.u4.dwBBitMask == 0x000000FF) &&