src/video/win32/SDL_d3drender.c
changeset 1904 1a713f9d1f71
parent 1903 f132024010be
child 1905 36d52b1f0504
     1.1 --- a/src/video/win32/SDL_d3drender.c	Fri Jul 14 06:40:53 2006 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Fri Jul 14 07:41:16 2006 +0000
     1.3 @@ -113,7 +113,8 @@
     1.4  typedef struct
     1.5  {
     1.6      float x, y, z;
     1.7 -    float tu, tv;
     1.8 +    float rhw;
     1.9 +    float u, v;
    1.10  } Vertex;
    1.11  
    1.12  static void
    1.13 @@ -330,9 +331,17 @@
    1.14      data->beginScene = SDL_TRUE;
    1.15  
    1.16      /* Set up parameters for rendering */
    1.17 +    IDirect3DDevice9_SetVertexShader(data->device, NULL);
    1.18 +    IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZRHW | D3DFVF_TEX1);
    1.19      IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
    1.20                                      D3DCULL_NONE);
    1.21 -    IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZ | D3DFVF_TEX1);
    1.22 +    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
    1.23 +    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
    1.24 +                                    TRUE);
    1.25 +    IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
    1.26 +                                    D3DBLEND_SRCALPHA);
    1.27 +    IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
    1.28 +                                    D3DBLEND_INVSRCALPHA);
    1.29  
    1.30      return renderer;
    1.31  }
    1.32 @@ -560,7 +569,7 @@
    1.33      SDL_D3D_TextureData *texturedata =
    1.34          (SDL_D3D_TextureData *) texture->driverdata;
    1.35      float minx, miny, maxx, maxy;
    1.36 -    float mintu, maxtu, mintv, maxtv;
    1.37 +    float minu, maxu, minv, maxv;
    1.38      Vertex vertices[4];
    1.39      HRESULT result;
    1.40  
    1.41 @@ -569,36 +578,43 @@
    1.42          data->beginScene = SDL_FALSE;
    1.43      }
    1.44  
    1.45 -    minx = (float) dstrect->x;
    1.46 -    miny = (float) dstrect->y;
    1.47 -    maxx = (float) dstrect->x + dstrect->w;
    1.48 -    maxy = (float) dstrect->y + dstrect->h;
    1.49 +    minx = (float) dstrect->x - 0.5f;
    1.50 +    miny = (float) dstrect->y - 0.5f;
    1.51 +    maxx = (float) dstrect->x + dstrect->w - 0.5f;
    1.52 +    maxy = (float) dstrect->y + dstrect->h - 0.5f;
    1.53  
    1.54 -    mintu = (float) srcrect->x / texture->w;
    1.55 -    maxtu = (float) (srcrect->x + srcrect->w) / texture->w;
    1.56 -    mintv = (float) srcrect->y / texture->h;
    1.57 -    maxtv = (float) (srcrect->y + srcrect->h) / texture->h;
    1.58 +    minu = (float) srcrect->x / texture->w;
    1.59 +    maxu = (float) (srcrect->x + srcrect->w) / texture->w;
    1.60 +    minv = (float) srcrect->y / texture->h;
    1.61 +    maxv = (float) (srcrect->y + srcrect->h) / texture->h;
    1.62  
    1.63      vertices[0].x = minx;
    1.64      vertices[0].y = miny;
    1.65      vertices[0].z = 0.0f;
    1.66 -    vertices[0].tu = mintu;
    1.67 -    vertices[0].tv = mintv;
    1.68 +    vertices[0].rhw = 1.0f;
    1.69 +    vertices[0].u = minu;
    1.70 +    vertices[0].v = minv;
    1.71 +
    1.72      vertices[1].x = maxx;
    1.73      vertices[1].y = miny;
    1.74      vertices[1].z = 0.0f;
    1.75 -    vertices[1].tu = maxtu;
    1.76 -    vertices[1].tv = mintv;
    1.77 +    vertices[1].rhw = 1.0f;
    1.78 +    vertices[1].u = maxu;
    1.79 +    vertices[1].v = minv;
    1.80 +
    1.81      vertices[2].x = maxx;
    1.82      vertices[2].y = maxy;
    1.83      vertices[2].z = 0.0f;
    1.84 -    vertices[2].tu = maxtu;
    1.85 -    vertices[2].tv = maxtv;
    1.86 +    vertices[2].rhw = 1.0f;
    1.87 +    vertices[2].u = maxu;
    1.88 +    vertices[2].v = maxv;
    1.89 +
    1.90      vertices[3].x = minx;
    1.91      vertices[3].y = maxy;
    1.92      vertices[3].z = 0.0f;
    1.93 -    vertices[3].tu = mintu;
    1.94 -    vertices[3].tv = maxtv;
    1.95 +    vertices[3].rhw = 1.0f;
    1.96 +    vertices[3].u = minu;
    1.97 +    vertices[3].v = maxv;
    1.98  
    1.99      result =
   1.100          IDirect3DDevice9_SetTexture(data->device, 0,