DXGL r188 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r187‎ | r188 | r189 >
Date:00:01, 30 June 2012
Author:admin
Status:new
Tags:
Comment:
Add IDirect3D3 interface.
Add IDirect3DVertexBuffer7 stub interface.
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3D.h (modified) (history)
  • /ddraw/glDirect3DVertexBuffer.cpp (added) (history)
  • /ddraw/glDirect3DVertexBuffer.h (added) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/ddraw.vcxproj
@@ -170,6 +170,7 @@
171171 <ClInclude Include="glDirect3D.h" />
172172 <ClInclude Include="glDirect3DDevice.h" />
173173 <ClInclude Include="glDirect3DLight.h" />
 174+ <ClInclude Include="glDirect3DVertexBuffer.h" />
174175 <ClInclude Include="glDirectDraw.h" />
175176 <ClInclude Include="glDirectDrawClipper.h" />
176177 <ClInclude Include="glDirectDrawPalette.h" />
@@ -216,6 +217,7 @@
217218 <ClCompile Include="glDirect3D.cpp" />
218219 <ClCompile Include="glDirect3DDevice.cpp" />
219220 <ClCompile Include="glDirect3DLight.cpp" />
 221+ <ClCompile Include="glDirect3DVertexBuffer.cpp" />
220222 <ClCompile Include="glDirectDraw.cpp" />
221223 <ClCompile Include="glDirectDrawClipper.cpp" />
222224 <ClCompile Include="glDirectDrawPalette.cpp" />
Index: ddraw/ddraw.vcxproj.filters
@@ -104,6 +104,9 @@
105105 <ClInclude Include="glRenderWindow.h">
106106 <Filter>Header Files</Filter>
107107 </ClInclude>
 108+ <ClInclude Include="glDirect3DVertexBuffer.h">
 109+ <Filter>Header Files</Filter>
 110+ </ClInclude>
108111 </ItemGroup>
109112 <ItemGroup>
110113 <ClCompile Include="ddraw.cpp">
@@ -166,6 +169,9 @@
167170 <ClCompile Include="glRenderWindow.cpp">
168171 <Filter>Source Files</Filter>
169172 </ClCompile>
 173+ <ClCompile Include="glDirect3DVertexBuffer.cpp">
 174+ <Filter>Source Files</Filter>
 175+ </ClCompile>
170176 </ItemGroup>
171177 <ItemGroup>
172178 <ResourceCompile Include="ddraw.rc">
Index: ddraw/glDirect3D.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011 William Feely
 3+// Copyright (C) 2011-2012 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -21,6 +21,7 @@
2222 #include "glDirect3DDevice.h"
2323 #include "glDirectDraw.h"
2424 #include "glDirectDrawSurface.h"
 25+#include "glDirect3DVertexBuffer.h"
2526
2627 D3DDEVICEDESC7 d3ddesc =
2728 {
@@ -96,6 +97,54 @@
9798 0,0,0,0 //dwReserved1 through dwReserved4
9899 };
99100
 101+D3DDEVICEDESC d3ddesc3 =
 102+{
 103+ sizeof(D3DDEVICEDESC), // dwSize
 104+ D3DDD_BCLIPPING|D3DDD_COLORMODEL|D3DDD_DEVCAPS|D3DDD_DEVICERENDERBITDEPTH|
 105+ D3DDD_DEVICEZBUFFERBITDEPTH|D3DDD_LIGHTINGCAPS|D3DDD_LINECAPS|D3DDD_MAXBUFFERSIZE|
 106+ D3DDD_MAXVERTEXCOUNT|D3DDD_TRANSFORMCAPS|D3DDD_TRICAPS, // dwFlags
 107+ D3DCOLOR_RGB, // dcmColorModel
 108+ d3ddesc.dwDevCaps,
 109+ { //dtcTransformCaps
 110+ sizeof(D3DTRANSFORMCAPS), //dwSize
 111+ 0 // dwCaps
 112+ },
 113+ FALSE, //bClipping
 114+ { // dlcLightingCaps
 115+ sizeof(D3DLIGHTINGCAPS), //dwSize
 116+ D3DLIGHTCAPS_DIRECTIONAL|D3DLIGHTCAPS_POINT|D3DLIGHTCAPS_SPOT, // dwCaps
 117+ D3DLIGHTINGMODEL_RGB, // dwLightingModel
 118+ 8 //dwNumLights
 119+ },
 120+ d3ddesc.dpcLineCaps,
 121+ d3ddesc.dpcTriCaps,
 122+ d3ddesc.dwDeviceRenderBitDepth,
 123+ d3ddesc.dwDeviceZBufferBitDepth,
 124+ 0, // dwMaxBufferSize
 125+ 65536, // dwMaxVertexCount
 126+ d3ddesc.dwMinTextureWidth,
 127+ d3ddesc.dwMinTextureHeight,
 128+ d3ddesc.dwMaxTextureWidth,
 129+ d3ddesc.dwMaxTextureHeight,
 130+ 0, // dwMinStippleWidth
 131+ 32, // dwMaxStippleWidth
 132+ 0, // dwMinStippleHeight
 133+ 32, // dwMaxStippleHeight
 134+ d3ddesc.dwMaxTextureRepeat,
 135+ d3ddesc.dwMaxTextureAspectRatio,
 136+ d3ddesc.dwMaxAnisotropy,
 137+ d3ddesc.dvGuardBandLeft,
 138+ d3ddesc.dvGuardBandTop,
 139+ d3ddesc.dvGuardBandRight,
 140+ d3ddesc.dvGuardBandBottom,
 141+ d3ddesc.dvExtentsAdjust,
 142+ d3ddesc.dwStencilCaps,
 143+ d3ddesc.dwFVFCaps,
 144+ d3ddesc.dwTextureOpCaps,
 145+ d3ddesc.wMaxTextureBlendStages,
 146+ d3ddesc.wMaxSimultaneousTextures
 147+};
 148+
100149 struct D3DDevice
101150 {
102151 char *name;
@@ -154,6 +203,12 @@
155204 *ppvObj = this;
156205 return D3D_OK;
157206 }
 207+ if(riid == IID_IDirect3D3)
 208+ {
 209+ this->AddRef();
 210+ *ppvObj = new glDirect3D3(this);
 211+ return D3D_OK;
 212+ }
158213 FIXME("glDirect3D7::QueryInterface: stub");
159214 return E_NOINTERFACE;
160215 }
@@ -166,10 +221,33 @@
167222 *lplpD3DDevice = (LPDIRECT3DDEVICE7) glD3DDev7;
168223 return D3D_OK;
169224 }
 225+HRESULT WINAPI glDirect3D7::CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter)
 226+{
 227+ if(!this) return DDERR_INVALIDPARAMS;
 228+ if(pUnkOuter) return DDERR_INVALIDPARAMS;
 229+ FIXME("glDirect3D7::CreateLight: stub");
 230+ return DDERR_GENERIC;
 231+}
 232+HRESULT WINAPI glDirect3D7::CreateMaterial(LPDIRECT3DMATERIAL3* lplpDirect3DMaterial, IUnknown* pUnkOuter)
 233+{
 234+ if(!this) return DDERR_INVALIDPARAMS;
 235+ if(pUnkOuter) return DDERR_INVALIDPARAMS;
 236+ FIXME("glDirect3D7::CreateMaterial: stub");
 237+ return DDERR_GENERIC;
 238+}
170239 HRESULT WINAPI glDirect3D7::CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIRECT3DVERTEXBUFFER7* lplpD3DVertexBuffer, DWORD dwFlags)
171240 {
172241 if(!this) return DDERR_INVALIDPARAMS;
173 - FIXME("glDirect3D7::CreateVertexBuffer: stub");
 242+ if(!lplpD3DVertexBuffer) return DDERR_INVALIDPARAMS;
 243+ if(!lpVBDesc) return DDERR_INVALIDPARAMS;
 244+ *lplpD3DVertexBuffer = (LPDIRECT3DVERTEXBUFFER7)new glDirect3DVertexBuffer7(this,*lpVBDesc,dwFlags);
 245+ return D3D_OK;
 246+}
 247+HRESULT WINAPI glDirect3D7::CreateViewport(LPDIRECT3DVIEWPORT3* lplpD3DViewport, IUnknown* pUnkOuter)
 248+{
 249+ if(!this) return DDERR_INVALIDPARAMS;
 250+ if(pUnkOuter) return DDERR_INVALIDPARAMS;
 251+ FIXME("glDirect3D7::CreateViewport: stub");
174252 return DDERR_GENERIC;
175253 }
176254 HRESULT WINAPI glDirect3D7::EnumDevices(LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg)
@@ -199,6 +277,20 @@
200278 }
201279 return D3D_OK;
202280 }
 281+
 282+HRESULT WINAPI glDirect3D7::EnumDevices3(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg)
 283+{
 284+ if(!this) return DDERR_INVALIDPARAMS;
 285+ if(!lpEnumDevicesCallback) return DDERR_INVALIDPARAMS;
 286+ HRESULT result;
 287+ D3DDEVICEDESC desc = d3ddesc3;
 288+ GUID guid = IID_IDirect3DRGBDevice;
 289+ result = lpEnumDevicesCallback(&guid,devices[0].name,devices[0].devname,&desc,&desc,lpUserArg);
 290+ if(result != D3DENUMRET_OK) return D3D_OK;
 291+ guid = IID_IDirect3DHALDevice;
 292+ result = lpEnumDevicesCallback(&guid,devices[1].name,devices[1].devname,&desc,&desc,lpUserArg);
 293+ return D3D_OK;
 294+}
203295 HRESULT WINAPI glDirect3D7::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
204296 {
205297 if(!this) return DDERR_INVALIDPARAMS;
@@ -231,7 +323,203 @@
232324 }
233325 HRESULT WINAPI glDirect3D7::EvictManagedTextures()
234326 {
 327+ return D3D_OK;
 328+}
 329+
 330+HRESULT WINAPI glDirect3D7::FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR)
 331+{
235332 if(!this) return DDERR_INVALIDPARAMS;
236 - FIXME("glDirect3D7::EvictManagedTextures: stub");
237 - return DDERR_GENERIC;
 333+ if(!lpD3DFDS) return DDERR_INVALIDPARAMS;
 334+ if(!lpD3DFDR) return DDERR_INVALIDPARAMS;
 335+ if(lpD3DFDR->dwSize < sizeof(D3DFINDDEVICERESULT)) return DDERR_INVALIDPARAMS;
 336+ if(lpD3DFDS->dwSize < sizeof(D3DFINDDEVICESEARCH)) return DDERR_INVALIDPARAMS;
 337+ bool found = true;
 338+ GUID guid = IID_IDirect3DHALDevice;
 339+ if((lpD3DFDS->dwFlags & D3DFDS_LINES) || (lpD3DFDS->dwFlags & D3DFDS_TRIANGLES))
 340+ {
 341+ if(lpD3DFDS->dwFlags & D3DFDS_ALPHACMPCAPS)
 342+ {
 343+ if((d3ddesc.dpcTriCaps.dwAlphaCmpCaps & lpD3DFDS->dpcPrimCaps.dwAlphaCmpCaps)
 344+ != lpD3DFDS->dpcPrimCaps.dwAlphaCmpCaps) found = false;
 345+ }
 346+ if(lpD3DFDS->dwFlags & D3DFDS_DSTBLENDCAPS)
 347+ {
 348+ if((d3ddesc.dpcTriCaps.dwDestBlendCaps & lpD3DFDS->dpcPrimCaps.dwDestBlendCaps)
 349+ != lpD3DFDS->dpcPrimCaps.dwDestBlendCaps) found = false;
 350+ }
 351+ if(lpD3DFDS->dwFlags & D3DFDS_MISCCAPS)
 352+ {
 353+ if((d3ddesc.dpcTriCaps.dwMiscCaps & lpD3DFDS->dpcPrimCaps.dwMiscCaps)
 354+ != lpD3DFDS->dpcPrimCaps.dwMiscCaps) found = false;
 355+ }
 356+ if(lpD3DFDS->dwFlags & D3DFDS_RASTERCAPS)
 357+ {
 358+ if((d3ddesc.dpcTriCaps.dwRasterCaps & lpD3DFDS->dpcPrimCaps.dwRasterCaps)
 359+ != lpD3DFDS->dpcPrimCaps.dwRasterCaps) found = false;
 360+ }
 361+ if(lpD3DFDS->dwFlags & D3DFDS_SHADECAPS)
 362+ {
 363+ if((d3ddesc.dpcTriCaps.dwShadeCaps & lpD3DFDS->dpcPrimCaps.dwShadeCaps)
 364+ != lpD3DFDS->dpcPrimCaps.dwShadeCaps) found = false;
 365+ }
 366+ if(lpD3DFDS->dwFlags & D3DFDS_SRCBLENDCAPS)
 367+ {
 368+ if((d3ddesc.dpcTriCaps.dwSrcBlendCaps & lpD3DFDS->dpcPrimCaps.dwSrcBlendCaps)
 369+ != lpD3DFDS->dpcPrimCaps.dwSrcBlendCaps) found = false;
 370+ }
 371+ if(lpD3DFDS->dwFlags & D3DFDS_TEXTUREBLENDCAPS)
 372+ {
 373+ if((d3ddesc.dpcTriCaps.dwTextureBlendCaps & lpD3DFDS->dpcPrimCaps.dwTextureBlendCaps)
 374+ != lpD3DFDS->dpcPrimCaps.dwTextureBlendCaps) found = false;
 375+ }
 376+ if(lpD3DFDS->dwFlags & D3DFDS_TEXTURECAPS)
 377+ {
 378+ if((d3ddesc.dpcTriCaps.dwTextureCaps & lpD3DFDS->dpcPrimCaps.dwTextureCaps)
 379+ != lpD3DFDS->dpcPrimCaps.dwTextureCaps) found = false;
 380+ }
 381+ if(lpD3DFDS->dwFlags & D3DFDS_TEXTUREFILTERCAPS)
 382+ {
 383+ if((d3ddesc.dpcTriCaps.dwTextureFilterCaps & lpD3DFDS->dpcPrimCaps.dwTextureFilterCaps)
 384+ != lpD3DFDS->dpcPrimCaps.dwTextureFilterCaps) found = false;
 385+ }
 386+ if(lpD3DFDS->dwCaps & D3DFDS_ZCMPCAPS)
 387+ {
 388+ if((d3ddesc.dpcTriCaps.dwZCmpCaps & lpD3DFDS->dpcPrimCaps.dwZCmpCaps)
 389+ != lpD3DFDS->dpcPrimCaps.dwZCmpCaps) found = false;
 390+ }
 391+ }
 392+ if(lpD3DFDS->dwFlags & D3DFDS_COLORMODEL)
 393+ {
 394+ if((d3ddesc3.dcmColorModel & lpD3DFDS->dcmColorModel) != lpD3DFDS->dcmColorModel) found = false;
 395+ }
 396+ if(lpD3DFDS->dwFlags & D3DFDS_GUID)
 397+ {
 398+ if((lpD3DFDS->guid != IID_IDirect3DRGBDevice) && (lpD3DFDS->guid != IID_IDirect3DHALDevice))
 399+ found = false;
 400+ else guid = lpD3DFDS->guid;
 401+ }
 402+ if(lpD3DFDS->dwFlags & D3DFDS_HARDWARE)
 403+ {
 404+ if(lpD3DFDS->dwFlags & D3DFDS_GUID)
 405+ {
 406+ if(lpD3DFDS->bHardware && (lpD3DFDS->guid != IID_IDirect3DHALDevice)) found = false;
 407+ if(!lpD3DFDS->bHardware && (lpD3DFDS->guid != IID_IDirect3DRGBDevice)) found = false;
 408+ }
 409+ else if(!lpD3DFDS->bHardware) guid = IID_IDirect3DRGBDevice;
 410+ }
 411+ if(!found) return DDERR_NOTFOUND;
 412+ if(guid == IID_IDirect3DRGBDevice) lpD3DFDR->ddSwDesc = d3ddesc3;
 413+ else lpD3DFDR->ddHwDesc = d3ddesc3;
 414+ lpD3DFDR->guid = guid;
 415+ return D3D_OK;
238416 }
 417+
 418+
 419+// IDirect3D3 wrapper
 420+glDirect3D3::glDirect3D3(glDirect3D7 *glD3D7)
 421+{
 422+ this->glD3D7 = glD3D7;
 423+ glD3D7->AddRef();
 424+ refcount = 1;
 425+}
 426+
 427+glDirect3D3::~glDirect3D3()
 428+{
 429+ glD3D7->Release();
 430+}
 431+
 432+HRESULT WINAPI glDirect3D3::QueryInterface(REFIID riid, void** ppvObj)
 433+{
 434+ if(!this) return DDERR_INVALIDPARAMS;
 435+ if(riid == IID_IUnknown)
 436+ {
 437+ this->AddRef();
 438+ *ppvObj = this;
 439+ return DD_OK;
 440+ }
 441+ return glD3D7->QueryInterface(riid,ppvObj);
 442+}
 443+
 444+ULONG WINAPI glDirect3D3::AddRef()
 445+{
 446+ if(!this) return 0;
 447+ refcount++;
 448+ return refcount;
 449+}
 450+
 451+ULONG WINAPI glDirect3D3::Release()
 452+{
 453+ if(!this) return 0;
 454+ ULONG ret;
 455+ refcount--;
 456+ ret = refcount;
 457+ if(refcount == 0) delete this;
 458+ return ret;
 459+}
 460+
 461+HRESULT WINAPI glDirect3D3::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 * lplpD3DDevice, LPUNKNOWN pUnkOuter)
 462+{
 463+ if(!this) return DDERR_INVALIDPARAMS;
 464+ if(pUnkOuter) return DDERR_INVALIDPARAMS;
 465+ LPDIRECT3DDEVICE7 lpD3DDev7;
 466+ HRESULT err = glD3D7->CreateDevice(rclsid,((glDirectDrawSurface4*)lpDDS)->GetDDS7(),&lpD3DDev7);
 467+ if(err == D3D_OK)
 468+ {
 469+ lpD3DDev7->QueryInterface(IID_IDirect3DDevice3,(LPVOID*) lplpD3DDevice);
 470+ lpD3DDev7->Release();
 471+ return D3D_OK;
 472+ }
 473+ return err;
 474+}
 475+
 476+HRESULT WINAPI glDirect3D3::CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter)
 477+{
 478+ if(!this) return DDERR_INVALIDPARAMS;
 479+ return glD3D7->CreateLight(lplpDirect3DLight,pUnkOuter);
 480+}
 481+HRESULT WINAPI glDirect3D3::CreateMaterial(LPDIRECT3DMATERIAL3* lplpDirect3DMaterial, IUnknown* pUnkOuter)
 482+{
 483+ if(!this) return DDERR_INVALIDPARAMS;
 484+ return glD3D7->CreateMaterial(lplpDirect3DMaterial,pUnkOuter);
 485+}
 486+HRESULT WINAPI glDirect3D3::CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIRECT3DVERTEXBUFFER* lplpD3DVertexBuffer, DWORD dwFlags, LPUNKNOWN pUnkOuter)
 487+{
 488+ if(!this) return DDERR_INVALIDPARAMS;
 489+ if(pUnkOuter) return DDERR_INVALIDPARAMS;
 490+ LPDIRECT3DVERTEXBUFFER7 lpD3DVB7;
 491+ HRESULT err = glD3D7->CreateVertexBuffer(lpVBDesc,&lpD3DVB7,dwFlags);
 492+ if(err == D3D_OK)
 493+ {
 494+ lpD3DVB7->QueryInterface(IID_IDirect3DVertexBuffer,(LPVOID*)lplpD3DVertexBuffer);
 495+ lpD3DVB7->Release();
 496+ return D3D_OK;
 497+ }
 498+ return err;
 499+}
 500+HRESULT WINAPI glDirect3D3::CreateViewport(LPDIRECT3DVIEWPORT3* lplpD3DViewport, IUnknown* pUnkOuter)
 501+{
 502+ if(!this) return DDERR_INVALIDPARAMS;
 503+ return glD3D7->CreateViewport(lplpD3DViewport,pUnkOuter);
 504+}
 505+
 506+HRESULT WINAPI glDirect3D3::EnumDevices(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg)
 507+{
 508+ if(!this) return DDERR_INVALIDPARAMS;
 509+ return glD3D7->EnumDevices3(lpEnumDevicesCallback,lpUserArg);
 510+}
 511+
 512+HRESULT WINAPI glDirect3D3::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
 513+{
 514+ if(!this) return DDERR_INVALIDPARAMS;
 515+ return glD3D7->EnumZBufferFormats(riidDevice,lpEnumCallback,lpContext);
 516+}
 517+HRESULT WINAPI glDirect3D3::EvictManagedTextures()
 518+{
 519+ if(!this) return DDERR_INVALIDPARAMS;
 520+ return glD3D7->EvictManagedTextures();
 521+}
 522+HRESULT WINAPI glDirect3D3::FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR)
 523+{
 524+ if(!this) return DDERR_INVALIDPARAMS;
 525+ return glD3D7->FindDevice(lpD3DFDS,lpD3DFDR);
 526+}
Index: ddraw/glDirect3D.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011 William Feely
 3+// Copyright (C) 2011-2012 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -31,15 +31,41 @@
3232 ULONG WINAPI AddRef();
3333 ULONG WINAPI Release();
3434 HRESULT WINAPI CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7 *lplpD3DDevice);
 35+ HRESULT WINAPI CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter);
 36+ HRESULT WINAPI CreateMaterial(LPDIRECT3DMATERIAL3* lplpDirect3DMaterial, IUnknown* pUnkOuter);
3537 HRESULT WINAPI CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIRECT3DVERTEXBUFFER7* lplpD3DVertexBuffer, DWORD dwFlags);
 38+ HRESULT WINAPI CreateViewport(LPDIRECT3DVIEWPORT3* lplpD3DViewport, IUnknown* pUnkOuter);
3639 HRESULT WINAPI EnumDevices(LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg);
 40+ HRESULT WINAPI EnumDevices3(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg);
3741 HRESULT WINAPI EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext);
3842 HRESULT WINAPI EvictManagedTextures();
 43+ HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
3944 glDirectDraw7 *glDD7;
4045 private:
4146 ULONG refcount;
4247 };
4348
 49+class glDirect3D3 : public IDirect3D3
 50+{
 51+public:
 52+ glDirect3D3(glDirect3D7 *glDD7);
 53+ virtual ~glDirect3D3();
 54+ HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
 55+ ULONG WINAPI AddRef();
 56+ ULONG WINAPI Release();
 57+ HRESULT WINAPI CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 * lplpD3DDevice, LPUNKNOWN pUnkOuter);
 58+ HRESULT WINAPI CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter);
 59+ HRESULT WINAPI CreateMaterial(LPDIRECT3DMATERIAL3* lplpDirect3DMaterial, IUnknown* pUnkOuter);
 60+ HRESULT WINAPI CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIRECT3DVERTEXBUFFER* lplpD3DVertexBuffer, DWORD dwFlags, LPUNKNOWN pUnkOuter);
 61+ HRESULT WINAPI CreateViewport(LPDIRECT3DVIEWPORT3* lplpD3DViewport, IUnknown* pUnkOuter);
 62+ HRESULT WINAPI EnumDevices(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg);
 63+ HRESULT WINAPI EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext);
 64+ HRESULT WINAPI EvictManagedTextures();
 65+ HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
 66+private:
 67+ ULONG refcount;
 68+ glDirect3D7 *glD3D7;
 69+};
4470
4571
4672 #endif //__GLDIRECT3D_H
\ No newline at end of file
Index: ddraw/glDirect3DVertexBuffer.cpp
@@ -0,0 +1,109 @@
 2+// DXGL
 3+// Copyright (C) 2011-2012 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include "common.h"
 20+#include "include/d3d.h"
 21+#include "include/d3dtypes.h"
 22+#include "glRenderer.h"
 23+#include "glDirect3D.h"
 24+#include "glDirect3DDevice.h"
 25+#include "glDirect3DVertexBuffer.h"
 26+
 27+glDirect3DVertexBuffer7::glDirect3DVertexBuffer7(glDirect3D7 *glD3D7, D3DVERTEXBUFFERDESC desc, DWORD flags)
 28+{
 29+ this->glD3D7 = glD3D7;
 30+ glD3D7->AddRef();
 31+ refcount = 1;
 32+ vbdesc = desc;
 33+ this->flags = flags;
 34+}
 35+
 36+glDirect3DVertexBuffer7::~glDirect3DVertexBuffer7()
 37+{
 38+ glD3D7->Release();
 39+}
 40+
 41+ULONG WINAPI glDirect3DVertexBuffer7::AddRef()
 42+{
 43+ if(!this) return 0;
 44+ refcount++;
 45+ return refcount;
 46+}
 47+ULONG WINAPI glDirect3DVertexBuffer7::Release()
 48+{
 49+ if(!this) return 0;
 50+ ULONG ret;
 51+ refcount--;
 52+ ret = refcount;
 53+ if(refcount == 0) delete this;
 54+ return ret;
 55+}
 56+
 57+HRESULT WINAPI glDirect3DVertexBuffer7::QueryInterface(REFIID riid, void** ppvObj)
 58+{
 59+ if(!this) return DDERR_INVALIDPARAMS;
 60+ if(!ppvObj) return DDERR_INVALIDPARAMS;
 61+ if(riid == IID_IUnknown)
 62+ {
 63+ this->AddRef();
 64+ *ppvObj = this;
 65+ return D3D_OK;
 66+ }
 67+ return E_NOINTERFACE;
 68+}
 69+
 70+HRESULT WINAPI glDirect3DVertexBuffer7::GetVertexBufferDesc(LPD3DVERTEXBUFFERDESC lpVBDesc)
 71+{
 72+ if(!this) return DDERR_INVALIDPARAMS;
 73+ if(!lpVBDesc) return DDERR_INVALIDPARAMS;
 74+ *lpVBDesc = vbdesc;
 75+ return D3D_OK;
 76+}
 77+
 78+HRESULT WINAPI glDirect3DVertexBuffer7::Lock(DWORD dwFlags, LPVOID* lplpData, LPDWORD lpdwSize)
 79+{
 80+ if(!this) return DDERR_INVALIDPARAMS;
 81+ FIXME("glDirect3DVertexBuffer7::Lock: stub");
 82+ return DDERR_GENERIC;
 83+}
 84+
 85+HRESULT WINAPI glDirect3DVertexBuffer7::Optimize(LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags)
 86+{
 87+ if(!this) return DDERR_INVALIDPARAMS;
 88+ FIXME("glDirect3DVertexBuffer7::Optimize: stub");
 89+ return DDERR_GENERIC;
 90+}
 91+HRESULT WINAPI glDirect3DVertexBuffer7::ProcessVertices(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount,
 92+ LPDIRECT3DVERTEXBUFFER7 lpSrcBuffer, DWORD dwSrcIndex, LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags)
 93+{
 94+ if(!this) return DDERR_INVALIDPARAMS;
 95+ FIXME("glDirect3DVertexBuffer7::ProcessVertices: stub");
 96+ return DDERR_GENERIC;
 97+}
 98+HRESULT WINAPI glDirect3DVertexBuffer7::ProcessVerticesStrided(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount,
 99+ LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwSrcIndex, LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags)
 100+{
 101+ if(!this) return DDERR_INVALIDPARAMS;
 102+ FIXME("glDirect3DVertexBuffer7::ProcessVerticesStrided: stub");
 103+ return DDERR_GENERIC;
 104+}
 105+HRESULT WINAPI glDirect3DVertexBuffer7::Unlock()
 106+{
 107+ if(!this) return DDERR_INVALIDPARAMS;
 108+ FIXME("glDirect3DVertexBuffer7::Unlock: stub");
 109+ return DDERR_GENERIC;
 110+}
\ No newline at end of file
Index: ddraw/glDirect3DVertexBuffer.h
@@ -0,0 +1,45 @@
 2+// DXGL
 3+// Copyright (C) 2011-2012 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#pragma once
 20+#ifndef __GLDIRECT3DVERTEXBUFFER_H
 21+#define __GLDIRECT3DVERTEXBUFFER_H
 22+
 23+class glDirect3DVertexBuffer7 : public IDirect3DVertexBuffer7
 24+{
 25+public:
 26+ glDirect3DVertexBuffer7(glDirect3D7 *glD3DD7, D3DVERTEXBUFFERDESC desc, DWORD flags);
 27+ ~glDirect3DVertexBuffer7();
 28+ HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
 29+ ULONG WINAPI AddRef();
 30+ ULONG WINAPI Release();
 31+ HRESULT WINAPI GetVertexBufferDesc(LPD3DVERTEXBUFFERDESC lpVBDesc);
 32+ HRESULT WINAPI Lock(DWORD dwFlags, LPVOID* lplpData, LPDWORD lpdwSize);
 33+ HRESULT WINAPI Optimize(LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags);
 34+ HRESULT WINAPI ProcessVertices(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount,
 35+ LPDIRECT3DVERTEXBUFFER7 lpSrcBuffer, DWORD dwSrcIndex, LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags);
 36+ HRESULT WINAPI ProcessVerticesStrided(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount,
 37+ LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwSrcIndex, LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags);
 38+ HRESULT WINAPI Unlock();
 39+private:
 40+ glDirect3D7 *glD3D7;
 41+ ULONG refcount;
 42+ D3DVERTEXBUFFERDESC vbdesc;
 43+ DWORD flags;
 44+};
 45+
 46+#endif //__GLDIRECT3DVERTEXBUFFER_H
\ No newline at end of file
Index: ddraw/glDirectDraw.cpp
@@ -650,8 +650,10 @@
651651 }
652652 if(riid == IID_IDirect3D3)
653653 {
654 - FIXME("Add IDirect3D Interfaces\n");
655 - ERR(DDERR_GENERIC);
 654+ glDirect3D7 *tmp = new glDirect3D7(this);
 655+ tmp->QueryInterface(IID_IDirect3D3,ppvObj);
 656+ tmp->Release();
 657+ return DD_OK;
656658 }
657659 if(riid == IID_IDirect3D7)
658660 {