DXGL r314 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r313‎ | r314 | r315 >
Date:00:45, 29 January 2013
Author:admin
Status:new
Tags:
Comment:
Add IDirect3DTexture wrapper.
Modified paths:
  • /ddraw/glDirect3DTexture.cpp (modified) (history)
  • /ddraw/glDirect3DTexture.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DTexture.cpp
@@ -72,8 +72,6 @@
7373 HRESULT ret = glDDS7->GetHandle(glD3DDev7,lpHandle);
7474 glD3DDev7->Release();
7575 return ret;
76 - FIXME("glDirect3DTexture2::GetHandle: stub");
77 - return DDERR_GENERIC;
7876 }
7977 HRESULT WINAPI glDirect3DTexture2::Load(LPDIRECT3DTEXTURE2 lpD3DTexture2)
8078 {
@@ -87,3 +85,72 @@
8886 FIXME("glDirect3DTexture2::PaletteChanged: stub");
8987 return DDERR_GENERIC;
9088 }
 89+
 90+glDirect3DTexture1::glDirect3DTexture1(glDirectDrawSurface7 *glDDS7)
 91+{
 92+ glDDS7->Release();
 93+}
 94+glDirect3DTexture1::~glDirect3DTexture1()
 95+{
 96+ glDDS7->Release();
 97+}
 98+HRESULT WINAPI glDirect3DTexture1::QueryInterface(REFIID riid, void** ppvObj)
 99+{
 100+ if(!this) return DDERR_INVALIDPARAMS;
 101+ if(riid == IID_IUnknown)
 102+ {
 103+ this->AddRef();
 104+ *ppvObj = this;
 105+ return DD_OK;
 106+ }
 107+ return glDDS7->QueryInterface(riid,ppvObj);
 108+}
 109+ULONG WINAPI glDirect3DTexture1::AddRef()
 110+{
 111+ if(!this) return 0;
 112+ refcount++;
 113+ return refcount;
 114+}
 115+ULONG WINAPI glDirect3DTexture1::Release()
 116+{
 117+ if(!this) return 0;
 118+ ULONG ret;
 119+ refcount--;
 120+ ret = refcount;
 121+ if(refcount == 0) delete this;
 122+ return ret;
 123+}
 124+
 125+HRESULT WINAPI glDirect3DTexture1::GetHandle(LPDIRECT3DDEVICE lpDirect3DDevice, LPD3DTEXTUREHANDLE lpHandle)
 126+{
 127+ if(!this) return DDERR_INVALIDOBJECT;
 128+ if(!lpDirect3DDevice) return DDERR_INVALIDPARAMS;
 129+ glDirect3DDevice7 *glD3DDev7;
 130+ lpDirect3DDevice->QueryInterface(IID_IDirect3DDevice7,(void**)&glD3DDev7);
 131+ HRESULT ret = glDDS7->GetHandle(glD3DDev7,lpHandle);
 132+ glD3DDev7->Release();
 133+ return ret;
 134+}
 135+HRESULT WINAPI glDirect3DTexture1::Initialize(LPDIRECT3DDEVICE lpD3DDevice, LPDIRECTDRAWSURFACE lpDDSurface)
 136+{
 137+ if(!this) return DDERR_INVALIDOBJECT;
 138+ return DDERR_ALREADYINITIALIZED;
 139+}
 140+HRESULT WINAPI glDirect3DTexture1::Load(LPDIRECT3DTEXTURE lpD3DTexture)
 141+{
 142+ if(!this) return DDERR_INVALIDOBJECT;
 143+ FIXME("glDirect3DTexture1::Load: stub");
 144+ return DDERR_GENERIC;
 145+}
 146+HRESULT WINAPI glDirect3DTexture1::PaletteChanged(DWORD dwStart, DWORD dwCount)
 147+{
 148+ if(!this) return DDERR_INVALIDOBJECT;
 149+ FIXME("glDirect3DTexture1::PaletteChanged: stub");
 150+ return DDERR_GENERIC;
 151+}
 152+HRESULT WINAPI glDirect3DTexture1::Unload()
 153+{
 154+ if(!this) return DDERR_INVALIDOBJECT;
 155+ FIXME("glDirect3DTexture1::Unload: stub");
 156+ return DDERR_GENERIC;
 157+}
Index: ddraw/glDirect3DTexture.h
@@ -36,4 +36,23 @@
3737 ULONG refcount;
3838 };
3939
 40+class glDirect3DTexture1 : public IDirect3DTexture
 41+{
 42+public:
 43+ glDirect3DTexture1(glDirectDrawSurface7 *glDDS7);
 44+ virtual ~glDirect3DTexture1();
 45+ HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
 46+ ULONG WINAPI AddRef();
 47+ ULONG WINAPI Release();
 48+ HRESULT WINAPI GetHandle(LPDIRECT3DDEVICE lpDirect3DDevice, LPD3DTEXTUREHANDLE lpHandle);
 49+ HRESULT WINAPI Initialize(LPDIRECT3DDEVICE lpD3DDevice, LPDIRECTDRAWSURFACE lpDDSurface);
 50+ HRESULT WINAPI Load(LPDIRECT3DTEXTURE lpD3DTexture);
 51+ HRESULT WINAPI PaletteChanged(DWORD dwStart, DWORD dwCount);
 52+ HRESULT WINAPI Unload();
 53+ glDirectDrawSurface7 *GetDDS7(){return glDDS7;}
 54+private:
 55+ glDirectDrawSurface7 *glDDS7;
 56+ ULONG refcount;
 57+};
 58+
4059 #endif //__GLDIRECT3DTEXTURE_H
\ No newline at end of file
Index: ddraw/glDirectDrawSurface.cpp
@@ -429,7 +429,23 @@
430430 return DD_OK;
431431 }
432432 }
433 - ERR(E_NOINTERFACE);
 433+ if(riid == IID_IDirect3DTexture)
 434+ {
 435+ if(d3dt1)
 436+ {
 437+ *ppvObj = d3dt1;
 438+ d3dt1->AddRef();
 439+ return DD_OK;
 440+ }
 441+ else
 442+ {
 443+ this->AddRef();
 444+ *ppvObj = new glDirect3DTexture1(this);
 445+ d3dt1 = (glDirect3DTexture1*)*ppvObj;
 446+ return DD_OK;
 447+ }
 448+ }
 449+ return E_NOINTERFACE;
434450 }
435451 ULONG WINAPI glDirectDrawSurface7::AddRef()
436452 {
Index: ddraw/glDirectDrawSurface.h
@@ -33,6 +33,7 @@
3434 class glDirectDrawSurface3;
3535 class glDirectDrawSurface4;
3636 class glDirect3DTexture2;
 37+class glDirect3DTexture1;
3738 class glDirect3DDevice7;
3839 class glDirectDrawSurface7 : public IDirectDrawSurface7
3940 {
@@ -112,6 +113,7 @@
113114 glDirectDrawSurface3 *dds3;
114115 glDirectDrawSurface4 *dds4;
115116 glDirect3DTexture2 *d3dt2;
 117+ glDirect3DTexture1 *d3dt1;
116118 DWORD flipcount;
117119 DWORD fakex,fakey;
118120 DWORD dirty;