Stefan Dösinger : wined3d: Convert and load U8V8 surfaces as rgb.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 15 05:27:58 CST 2007
Module: wine
Branch: master
Commit: de036ff68e6adcb4b0f969dcfff3f2a4f2159251
URL: http://source.winehq.org/git/wine.git/?a=commit;h=de036ff68e6adcb4b0f969dcfff3f2a4f2159251
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Thu Feb 15 03:01:44 2007 +0100
wined3d: Convert and load U8V8 surfaces as rgb.
GL_INDEX is definitly not the way to load U8V8 surfaces
---
dlls/wined3d/surface.c | 35 ++++++++++++++++++++++++++++++++++-
dlls/wined3d/utils.c | 2 +-
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 149ec02..dabee6d 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -44,7 +44,8 @@ typedef enum {
CONVERT_CK_RGB24,
CONVERT_CK_8888,
CONVERT_CK_8888_ARGB,
- CONVERT_RGB32_888
+ CONVERT_RGB32_888,
+ CONVERT_V8U8
} CONVERT_TYPES;
HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf);
@@ -71,6 +72,11 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
int src_pitch = 0;
int dst_pitch = 0;
+ if(This->Flags & SFLAG_CONVERTED) {
+ FIXME("Read back converted textures unsupported\n");
+ return;
+ }
+
if (This->Flags & SFLAG_NONPOW2) {
src_pitch = This->bytesPerPixel * This->pow2Width;
dst_pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This);
@@ -1405,6 +1411,14 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
}
break;
+ case WINED3DFMT_V8U8:
+ *convert = CONVERT_V8U8;
+ *format = GL_BGR;
+ *internal = GL_RGB8;
+ *type = GL_BYTE;
+ *target_bpp = 3;
+ break;
+
default:
break;
}
@@ -1524,6 +1538,25 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
}
break;
+ case CONVERT_V8U8:
+ {
+ unsigned int x, y;
+ short *Source;
+ char *Dest;
+ for(y = 0; y < height; y++) {
+ Source = (short *) (src + y * pitch);
+ Dest = (char *) (dst + y * outpitch);
+ for (x = 0; x < width; x++ ) {
+ long color = (*Source++);
+ Dest[0] = color >> 8;
+ Dest[1] = color;
+ Dest[2] = 0xff;
+ Dest += 3;
+ }
+ }
+ break;
+ }
+
default:
ERR("Unsupported conversation type %d\n", convert);
}
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 8c0db1c..849f915 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -82,7 +82,7 @@ static const PixelFormatDesc formats[] = {
{WINED3DFMT_A8L8 ,0x0000ff00 ,0x0 ,0x0 ,0x0 ,2 ,FALSE ,GL_LUMINANCE8_ALPHA8 ,GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE },
{WINED3DFMT_A4L4 ,0x000000f0 ,0x0 ,0x0 ,0x0 ,1 ,FALSE ,GL_LUMINANCE4_ALPHA4 ,GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE },
/* Bump mapping stuff */
- {WINED3DFMT_V8U8 ,0x0 ,0x0 ,0x0 ,0x0 ,2 ,FALSE ,GL_COLOR_INDEX8_EXT ,GL_COLOR_INDEX ,GL_UNSIGNED_BYTE },
+ {WINED3DFMT_V8U8 ,0x0 ,0x0 ,0x0 ,0x0 ,2 ,FALSE ,GL_RGB8 ,GL_BGR ,GL_BYTE /* needs conversion! */},
{WINED3DFMT_L6V5U5 ,0x0 ,0x0 ,0x0 ,0x0 ,2 ,FALSE ,GL_COLOR_INDEX8_EXT ,GL_COLOR_INDEX ,GL_UNSIGNED_SHORT_5_5_5_1 },
{WINED3DFMT_X8L8V8U8 ,0x0 ,0x0 ,0x0 ,0x0 ,4 ,FALSE ,GL_RGBA8 ,GL_BGRA ,GL_UNSIGNED_BYTE },
{WINED3DFMT_Q8W8V8U8 ,0x0 ,0x0 ,0x0 ,0x0 ,4 ,FALSE ,GL_RGBA8 ,GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV/*?*/},
More information about the wine-cvs
mailing list