[WINED3D] Flip red/blue for R8G8B8 format.
Ivan Gyurdiev
ivg2 at cornell.edu
Sat May 6 22:27:54 CDT 2006
[ applies on top of Mike's tree, but hopefully on the main tree too ]
R8G8B8 means red is the most significant bit.
On a little-endian system, the texture is stored starting with blue.
It is read byte-by-byte (GL_UNSIGNED_BYTE), therefore it needs to be
flipped to GL_BGR.
This makes Demo #2 (texture mapping:
http://www.zanir.szm.sk/dx00-09.html) show the correct colors.
Also, in HL2, it makes Barney's face human color (previously it was blue).
I think Stefan Dosinger saw improvement on some other demos.
-------------- next part --------------
---
dlls/wined3d/surface.c | 2 +-
dlls/wined3d/utils.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
861909a76beb105faeb6c545fadbe8b539a686af
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index ed62f73..c2d2f21 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -837,7 +837,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_Unloc
case WINED3DFMT_R8G8B8:
{
glDrawPixels(This->lockedRect.right - This->lockedRect.left, (This->lockedRect.bottom - This->lockedRect.top)-1,
- GL_RGB, GL_UNSIGNED_BYTE, This->resource.allocatedMemory);
+ GL_BGR, GL_UNSIGNED_BYTE, This->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index ca76a93..ca45bcb 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1715,7 +1715,7 @@ GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl*
/* color buffer */
case WINED3DFMT_R3G3B2: retVal = GL_RGB; break;
case WINED3DFMT_R5G6B5: retVal = GL_RGB; break;
- case WINED3DFMT_R8G8B8: retVal = GL_RGB; break;
+ case WINED3DFMT_R8G8B8: retVal = GL_BGR; break;
case WINED3DFMT_A1R5G5B5: retVal = GL_BGRA; break;
case WINED3DFMT_X1R5G5B5: retVal = GL_BGRA; break;
case WINED3DFMT_A4R4G4B4: retVal = GL_BGRA; break;
--
1.3.0
More information about the wine-patches
mailing list