[PATCH] drawprim.c function drawStridedSlow to add in correctly the textures

Chris Ahrendt celticht32 at aol.com
Wed Sep 17 16:28:41 CDT 2008


---
 dlls/wined3d/drawprim.c |  120 ++++++++++++++++++++++++++--------------------
 1 files changed, 68 insertions(+), 52 deletions(-)

diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 37cbe19..46b43d7 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -276,6 +276,7 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum
     return;
 }
 
+
 /*
  * Actually draw using the supplied information.
  * Slower GL version which extracts info about each vertex in turn
@@ -298,6 +299,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
 
     BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
     BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
+    float r = 0.0, s = 0.0, t = 0.0, u = 0.0,x = 0.0, y = 0.0, z = 0.0, w = 0.0;
+    short rs = 0, ss = 0, ts = 0, us = 0;
 
     TRACE("Using slow vertex array code\n");
 
@@ -417,13 +420,13 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
             }
 
             /* Query tex coords */
-            if (This->stateBlock->textures[textureNo] != NULL || pixelShader) {
-
+            if (This->stateBlock->textures[textureNo] || pixelShader) {
                 int    coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
                 int texture_idx = This->texUnitMap[textureNo];
                 float *ptrToCoords = NULL;
-                float  s = 0.0, t = 0.0, r = 0.0, q = 0.0;
-
+                short *ptrToShortCoords = NULL;
+                
+                if (texture_idx == -1) continue;
                 if (coordIdx > 7) {
                     VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
                     continue;
@@ -433,64 +436,77 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
                 }
 
                 ptrToCoords = (float *)(texCoords[coordIdx] + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
-                if (texCoords[coordIdx] == NULL) {
+                ptrToShortCoords = (short *)(texCoords[coordIdx] + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
+                
+                if (!texCoords[coordIdx]) {
                     TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
                     if (GL_SUPPORT(ARB_MULTITEXTURE)) {
                         GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
                     } else {
                         glTexCoord4f(0, 0, 0, 1);
-                    }
+                    }                        
                     continue;
-                } else {
-                    int coordsToUse = sd->u.s.texCoords[coordIdx].dwType + 1; /* 0 == WINED3DDECLTYPE_FLOAT1 etc */
-
-                    if (texture_idx == -1) continue;
-
-                    /* The coords to supply depend completely on the fvf / vertex shader */
-                    switch (coordsToUse) {
-                    case 4: q = ptrToCoords[3]; /* drop through */
-                    case 3: r = ptrToCoords[2]; /* drop through */
-                    case 2: t = ptrToCoords[1]; /* drop through */
-                    case 1: s = ptrToCoords[0];
-                    }
-
-                    switch (coordsToUse) {   /* Supply the provided texture coords */
-                    case WINED3DTTFF_COUNT1:
-                        VTRACE(("tex:%d, s=%f\n", textureNo, s));
-                        if (GL_SUPPORT(ARB_MULTITEXTURE)) {
-                            GL_EXTCALL(glMultiTexCoord1fARB(GL_TEXTURE0_ARB + texture_idx, s));
-                        } else {
-                            glTexCoord1f(s);
-                        }
+                }
+                r =  ptrToCoords[0];
+                s =  ptrToCoords[1];
+                t =  ptrToCoords[2];
+                u =  ptrToCoords[3];  
+                rs = ptrToShortCoords[0];
+                ss = ptrToShortCoords[1];
+                ts = ptrToShortCoords[2];
+                us = ptrToShortCoords[3];
+                x = float_16_to_32(((unsigned short *) ptrToCoords) + 0);
+                y = float_16_to_32(((unsigned short *) ptrToCoords) + 1);
+                z = float_16_to_32(((unsigned short *) ptrToCoords) + 2);
+                w = float_16_to_32(((unsigned short *) ptrToCoords) + 3);
+
+                TRACE("Texture %d Texture Number %d\n",sd->u.s.texCoords[coordIdx].dwType,textureNo);
+                switch(sd->u.s.texCoords[coordIdx].dwType) {
+                    case WINED3DDECLTYPE_FLOAT1:
+                        glTexCoord1f(r);
                         break;
-                    case WINED3DTTFF_COUNT2:
-                        VTRACE(("tex:%d, s=%f, t=%f\n", textureNo, s, t));
-                        if (GL_SUPPORT(ARB_MULTITEXTURE)) {
-                            GL_EXTCALL(glMultiTexCoord2fARB(GL_TEXTURE0_ARB + texture_idx, s, t));
-                        } else {
-                            glTexCoord2f(s, t);
-                        }
+                    case WINED3DDECLTYPE_FLOAT2:
+                        glTexCoord2f(r,s);
                         break;
-                    case WINED3DTTFF_COUNT3:
-                        VTRACE(("tex:%d, s=%f, t=%f, r=%f\n", textureNo, s, t, r));
-                        if (GL_SUPPORT(ARB_MULTITEXTURE)) {
-                            GL_EXTCALL(glMultiTexCoord3fARB(GL_TEXTURE0_ARB + texture_idx, s, t, r));
-                        } else {
-                            glTexCoord3f(s, t, r);
-                        }
+                    case WINED3DDECLTYPE_FLOAT3:
+                        glTexCoord3f(r,s,t);
                         break;
-                    case WINED3DTTFF_COUNT4:
-                        VTRACE(("tex:%d, s=%f, t=%f, r=%f, q=%f\n", textureNo, s, t, r, q));
-                        if (GL_SUPPORT(ARB_MULTITEXTURE)) {
-                            GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, s, t, r, q));
-                        } else {
-                            glTexCoord4f(s, t, r, q);
-                        }
+                    case WINED3DDECLTYPE_FLOAT4:
+                        glTexCoord4f(r,s,t,u);
                         break;
+                    case WINED3DDECLTYPE_UBYTE4:
+                    case WINED3DDECLTYPE_UBYTE4N:
+                    case WINED3DDECLTYPE_D3DCOLOR:
+                        FIXME("unsure how to handle byte types\n");
+                        break;
+                    case WINED3DDECLTYPE_USHORT2N:
+                    case WINED3DDECLTYPE_SHORT2N:
+                    case WINED3DDECLTYPE_SHORT2:
+                         ts = 0;
+                         us = 1;
+                    case WINED3DDECLTYPE_SHORT4N:
+                    case WINED3DDECLTYPE_USHORT4N:
+                    case WINED3DDECLTYPE_SHORT4:
+                        glTexCoord4s(rs,ss,ts,us);
+                        break;
+                    case WINED3DDECLTYPE_UDEC3:
+                        FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
+                        break;
+                    case WINED3DDECLTYPE_DEC3N:
+                        FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
+                        break;
+                    case WINED3DDECLTYPE_FLOAT16_2:
+                        glTexCoord2f(x, y);
+                        break;
+                    case WINED3DDECLTYPE_FLOAT16_4:
+                        glTexCoord4f(x, y, z, w);
+                        break;
+                    case WINED3DDECLTYPE_UNUSED:
                     default:
-                        FIXME("Should not get here as coordsToUse is two bits only (%x)!\n", coordsToUse);
-                    }
+                        ERR("Unexpected attribute declaration: %d\n", sd->u.s.texCoords[coordIdx].dwType);
+                        break;
                 }
+
             }
         } /* End of textures */
 
@@ -540,7 +556,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
         }
 
         /* Normal -------------------------------- */
-        if (normal != NULL) {
+        if (normal) {
             float *ptrToCoords = (float *)(normal + (SkipnStrides * sd->u.s.normal.dwStride));
             normal_funcs[sd->u.s.normal.dwType](ptrToCoords);
         }
@@ -552,7 +568,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
         }
 
         /* For non indexed mode, step onto next parts */
-        if (idxData == NULL) {
+        if (!idxData) {
             ++SkipnStrides;
         }
     }
-- 
1.5.5.1


--------------070609020402000608010104--



More information about the wine-devel mailing list