DXGL r196 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r195‎ | r196 | r197 >
Date:14:41, 4 July 2012
Author:admin
Status:new
Tags:
Comment:
Support creating lights. Fix IDirec3D7::QueryInterface and IDirectDrawSurface7::QueryInterface for IDirect3DTexture2 objects.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3D.h (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -24,6 +24,7 @@
2525 #include "glDirect3DVertexBuffer.h"
2626 #include "glDirect3DViewport.h"
2727 #include "glDirect3DMaterial.h"
 28+#include "glDirect3DLight.h"
2829
2930 D3DDEVICEDESC7 d3ddesc =
3031 {
@@ -172,10 +173,12 @@
173174 refcount=1;
174175 this->glDD7 = glDD7;
175176 glDD7->AddRef();
 177+ glD3D3 = NULL;
176178 }
177179
178180 glDirect3D7::~glDirect3D7()
179181 {
 182+ if(glD3D3) glD3D3->Release();
180183 glDD7->Release();
181184 }
182185
@@ -197,7 +200,7 @@
198201
199202 HRESULT WINAPI glDirect3D7::QueryInterface(REFIID riid, void** ppvObj)
200203 {
201 - if(!this) return DDERR_INVALIDPARAMS;
 204+ if(!this) return DDERR_INVALIDOBJECT;
202205 if(!ppvObj) return DDERR_INVALIDPARAMS;
203206 if(riid == IID_IUnknown)
204207 {
@@ -207,9 +210,19 @@
208211 }
209212 if(riid == IID_IDirect3D3)
210213 {
211 - this->AddRef();
212 - *ppvObj = new glDirect3D3(this);
213 - return D3D_OK;
 214+ if(glD3D3)
 215+ {
 216+ *ppvObj = glD3D3;
 217+ glD3D3->AddRef();
 218+ return D3D_OK;
 219+ }
 220+ else
 221+ {
 222+ this->AddRef();
 223+ *ppvObj = new glDirect3D3(this);
 224+ glD3D3 = (glDirect3D3*)*ppvObj;
 225+ return D3D_OK;
 226+ }
214227 }
215228 return E_NOINTERFACE;
216229 }
@@ -225,9 +238,10 @@
226239 HRESULT WINAPI glDirect3D7::CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter)
227240 {
228241 if(!this) return DDERR_INVALIDPARAMS;
 242+ if(!lplpDirect3DLight) return DDERR_INVALIDPARAMS;
229243 if(pUnkOuter) return DDERR_INVALIDPARAMS;
230 - FIXME("glDirect3D7::CreateLight: stub");
231 - return DDERR_GENERIC;
 244+ *lplpDirect3DLight = new glDirect3DLight();
 245+ return D3D_OK;
232246 }
233247 HRESULT WINAPI glDirect3D7::CreateMaterial(LPDIRECT3DMATERIAL3* lplpDirect3DMaterial, IUnknown* pUnkOuter)
234248 {
Index: ddraw/glDirect3D.h
@@ -23,6 +23,7 @@
2424 extern D3DDEVICEDESC d3ddesc3;
2525 class glDirectDraw7;
2626
 27+class glDirect3D3;
2728 class glDirect3D7 : public IDirect3D7
2829 {
2930 public:
@@ -44,6 +45,7 @@
4546 glDirectDraw7 *glDD7;
4647 private:
4748 ULONG refcount;
 49+ glDirect3D3 *glD3D3;
4850 };
4951
5052 class glDirect3D3 : public IDirect3D3
Index: ddraw/glDirect3DDevice.cpp
@@ -672,6 +672,7 @@
673673 {
674674 if(!this) return DDERR_INVALIDOBJECT;
675675 *lplpD3D = glD3D7;
 676+ glD3D7->AddRef();
676677 return D3D_OK;
677678 }
678679 HRESULT WINAPI glDirect3DDevice7::GetInfo(DWORD dwDevInfoID, LPVOID pDevInfoStruct, DWORD dwSize)
@@ -1801,7 +1802,10 @@
18021803 HRESULT WINAPI glDirect3DDevice3::SetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 lpTexture)
18031804 {
18041805 if(!this) return DDERR_INVALIDOBJECT;
1805 - return glD3DDev7->SetTexture(dwStage,((glDirect3DTexture2*)lpTexture)->GetDDS7());
 1806+ glDirectDrawSurface7 *dds7;
 1807+ if(lpTexture) dds7 = ((glDirect3DTexture2*)lpTexture)->GetDDS7();
 1808+ else dds7 = NULL;
 1809+ return glD3DDev7->SetTexture(dwStage,dds7);
18061810 }
18071811
18081812 HRESULT WINAPI glDirect3DDevice3::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
Index: ddraw/glDirectDrawSurface.cpp
@@ -522,9 +522,19 @@
523523 }
524524 if(riid == IID_IDirect3DTexture2)
525525 {
526 - this->AddRef();
527 - *ppvObj = new glDirect3DTexture2(this);
528 - return DD_OK;
 526+ if(d3dt2)
 527+ {
 528+ *ppvObj = d3dt2;
 529+ d3dt2->AddRef();
 530+ return DD_OK;
 531+ }
 532+ else
 533+ {
 534+ this->AddRef();
 535+ *ppvObj = new glDirect3DTexture2(this);
 536+ d3dt2 = (glDirect3DTexture2*)*ppvObj;
 537+ return DD_OK;
 538+ }
529539 }
530540 ERR(E_NOINTERFACE);
531541 }
Index: ddraw/glDirectDrawSurface.h
@@ -32,6 +32,7 @@
3333 class glDirectDrawSurface2;
3434 class glDirectDrawSurface3;
3535 class glDirectDrawSurface4;
 36+class glDirect3DTexture2;
3637 class glDirectDrawSurface7 : public IDirectDrawSurface7
3738 {
3839 public:
@@ -108,6 +109,7 @@
109110 glDirectDrawSurface2 *dds2;
110111 glDirectDrawSurface3 *dds3;
111112 glDirectDrawSurface4 *dds4;
 113+ glDirect3DTexture2 *d3dt2;
112114 DWORD flipcount;
113115 GLenum texformat;
114116 GLenum texformat2;