DXGL r121 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r120‎ | r121 | r122 >
Date:21:23, 11 March 2012
Author:admin
Status:new
Tags:
Comment:
Add GetTexture and SetTexture
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -26,7 +26,7 @@
2727 #include "glutil.h"
2828 #include "matrix.h"
2929
30 -const DWORD renderstate_default[153] = {0, // 0
 30+const DWORD renderstate_default[153] = {0, // 0
3131 NULL, //texturehandle
3232 D3DANTIALIAS_NONE, //antialias
3333 D3DTADDRESS_WRAP, //textureaddress
@@ -141,7 +141,8 @@
142142 1,
143143 0,
144144 0,
145 - D3DTTFF_DISABLE
 145+ D3DTTFF_DISABLE,
 146+ NULL
146147 };
147148 const TEXTURESTAGE texstagedefault1 =
148149 {
@@ -164,7 +165,8 @@
165166 1,
166167 0,
167168 0,
168 - D3DTTFF_DISABLE
 169+ D3DTTFF_DISABLE,
 170+ NULL
169171 };
170172
171173 int setdrawmode(D3DPRIMITIVETYPE d3dptPrimitiveType)
@@ -225,6 +227,8 @@
226228 for(int i = 0; i < lightsmax; i++)
227229 if(lights[i]) delete lights[i];
228230 delete lights;
 231+ for(int i = 0; i < 8; i++)
 232+ if(texstages[i].texture) texstages[i].texture->Release();
229233 glD3D7->Release();
230234 glDDS7->Release();
231235 }
@@ -621,9 +625,13 @@
622626 }
623627 HRESULT WINAPI glDirect3DDevice7::GetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 *lplpTexture)
624628 {
 629+ if(!lplpTexture) return DDERR_INVALIDPARAMS;
625630 if(!this) return DDERR_INVALIDPARAMS;
626 - FIXME("glDirect3DDevice7::GetTexture: stub");
627 - ERR(DDERR_GENERIC);
 631+ if(dwStage > 7) return DDERR_INVALIDPARAMS;
 632+ if(!texstages[dwStage].texture) return DDERR_INVALIDOBJECT;
 633+ *lplpTexture = texstages[dwStage].texture;
 634+ texstages[dwStage].texture->AddRef();
 635+ return D3D_OK;
628636 }
629637 HRESULT WINAPI glDirect3DDevice7::GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, LPDWORD lpdwValue)
630638 {
@@ -852,8 +860,11 @@
853861 HRESULT WINAPI glDirect3DDevice7::SetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 lpTexture)
854862 {
855863 if(!this) return DDERR_INVALIDPARAMS;
856 - FIXME("glDirect3DDevice7::SetTexture: stub");
857 - ERR(DDERR_GENERIC);
 864+ if(dwStage > 7) return DDERR_INVALIDPARAMS;
 865+ if(texstages[dwStage].texture) texstages[dwStage].texture->Release();
 866+ texstages[dwStage].texture = (glDirectDrawSurface7*)lpTexture;
 867+ if(lpTexture) lpTexture->AddRef();
 868+ return D3D_OK;
858869 }
859870 HRESULT WINAPI glDirect3DDevice7::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
860871 {
Index: ddraw/glDirect3DDevice.h
@@ -44,6 +44,7 @@
4545 D3DVALUE bumpenvlscale;
4646 D3DVALUE bumpenvloffset;
4747 D3DTEXTURETRANSFORMFLAGS textransform;
 48+ glDirectDrawSurface7 *texture;
4849 };
4950
5051 class glDirect3DLight;