wined3d: Fix the cube map coordinates in surface_blt_to_drawable().

Henri Verbeet hverbeet at codeweavers.com
Wed Nov 19 04:49:13 CST 2008


I don't see how this can ever have worked properly.
---
 dlls/wined3d/surface.c |   71 +++++++++++++++++++++++++++++++----------------
 1 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 1fb27cc..1849b83 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -4265,6 +4265,22 @@ struct coords {
     GLfloat x, y, z;
 };
 
+struct float_rect
+{
+    float l;
+    float t;
+    float r;
+    float b;
+};
+
+static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct float_rect *f)
+{
+    f->l = ((r->left * 2.0f) / w) - 1.0f;
+    f->t = ((r->top * 2.0f) / h) - 1.0f;
+    f->r = ((r->right * 2.0f) / w) - 1.0f;
+    f->b = ((r->bottom * 2.0f) / h) - 1.0f;
+}
+
 static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in) {
     struct coords coords[4];
     RECT rect;
@@ -4272,6 +4288,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
     IWineD3DBaseTexture *texture;
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     GLenum bind_target;
+    struct float_rect f;
 
     if(rect_in) {
         rect = *rect_in;
@@ -4314,50 +4331,56 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
 
         case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
             bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            coords[0].x =  1;   coords[0].y = -1;   coords[0].z =  1;
-            coords[1].x =  1;   coords[1].y =  1;   coords[1].z =  1;
-            coords[2].x =  1;   coords[2].y =  1;   coords[2].z = -1;
-            coords[3].x =  1;   coords[3].y = -1;   coords[3].z = -1;
+            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
+            coords[0].x =    1; coords[0].y = -f.t; coords[0].z = -f.l;
+            coords[1].x =    1; coords[1].y = -f.b; coords[1].z = -f.l;
+            coords[2].x =    1; coords[2].y = -f.b; coords[2].z = -f.r;
+            coords[3].x =    1; coords[3].y = -f.t; coords[3].z = -f.r;
             break;
 
         case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
             bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            coords[0].x = -1;   coords[0].y = -1;   coords[0].z =  1;
-            coords[1].x = -1;   coords[1].y =  1;   coords[1].z =  1;
-            coords[2].x = -1;   coords[2].y =  1;   coords[2].z = -1;
-            coords[3].x = -1;   coords[3].y = -1;   coords[3].z = -1;
+            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
+            coords[0].x =   -1; coords[0].y = -f.t; coords[0].z =  f.l;
+            coords[1].x =   -1; coords[1].y = -f.b; coords[1].z =  f.l;
+            coords[2].x =   -1; coords[2].y = -f.b; coords[2].z =  f.r;
+            coords[3].x =   -1; coords[3].y = -f.t; coords[3].z =  f.r;
             break;
 
         case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
             bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            coords[0].x = -1;   coords[0].y =  1;   coords[0].z =  1;
-            coords[1].x =  1;   coords[1].y =  1;   coords[1].z =  1;
-            coords[2].x =  1;   coords[2].y =  1;   coords[2].z = -1;
-            coords[3].x = -1;   coords[3].y =  1;   coords[3].z = -1;
+            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
+            coords[0].x =  f.l; coords[0].y =    1; coords[0].z =  f.t;
+            coords[1].x =  f.l; coords[1].y =    1; coords[1].z =  f.b;
+            coords[2].x =  f.r; coords[2].y =    1; coords[2].z =  f.b;
+            coords[3].x =  f.r; coords[3].y =    1; coords[3].z =  f.t;
             break;
 
         case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
             bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            coords[0].x = -1;   coords[0].y = -1;   coords[0].z =  1;
-            coords[1].x =  1;   coords[1].y = -1;   coords[1].z =  1;
-            coords[2].x =  1;   coords[2].y = -1;   coords[2].z = -1;
-            coords[3].x = -1;   coords[3].y = -1;   coords[3].z = -1;
+            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
+            coords[0].x =  f.l; coords[0].y =   -1; coords[0].z = -f.t;
+            coords[1].x =  f.l; coords[1].y =   -1; coords[1].z = -f.b;
+            coords[2].x =  f.r; coords[2].y =   -1; coords[2].z = -f.b;
+            coords[3].x =  f.r; coords[3].y =   -1; coords[3].z = -f.t;
             break;
 
         case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
             bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            coords[0].x = -1;   coords[0].y = -1;   coords[0].z =  1;
-            coords[1].x =  1;   coords[1].y = -1;   coords[1].z =  1;
-            coords[2].x =  1;   coords[2].y = -1;   coords[2].z =  1;
-            coords[3].x = -1;   coords[3].y = -1;   coords[3].z =  1;
+            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
+            coords[0].x =  f.l; coords[0].y = -f.t; coords[0].z =    1;
+            coords[1].x =  f.l; coords[1].y = -f.b; coords[1].z =    1;
+            coords[2].x =  f.r; coords[2].y = -f.b; coords[2].z =    1;
+            coords[3].x =  f.r; coords[3].y = -f.t; coords[3].z =    1;
             break;
 
         case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
             bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            coords[0].x = -1;   coords[0].y = -1;   coords[0].z = -1;
-            coords[1].x =  1;   coords[1].y = -1;   coords[1].z = -1;
-            coords[2].x =  1;   coords[2].y = -1;   coords[2].z = -1;
-            coords[3].x = -1;   coords[3].y = -1;   coords[3].z = -1;
+            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
+            coords[0].x = -f.l; coords[0].y = -f.t; coords[0].z =   -1;
+            coords[1].x = -f.l; coords[1].y = -f.b; coords[1].z =   -1;
+            coords[2].x = -f.r; coords[2].y = -f.b; coords[2].z =   -1;
+            coords[3].x = -f.r; coords[3].y = -f.t; coords[3].z =   -1;
             break;
 
         default:
-- 
1.5.6.4



--------------030708060200090100020509--



More information about the wine-patches mailing list