DXGL r115 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r114‎ | r115 | r116 >
Date:00:37, 7 March 2012
Author:admin
Status:new
Tags:
Comment:
Add IDirect3D7::EnumDevices
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -22,6 +22,90 @@
2323 #include "glDirectDraw.h"
2424 #include "glDirectDrawSurface.h"
2525
 26+D3DDEVICEDESC7 d3ddesc =
 27+{
 28+ D3DDEVCAPS_CANBLTSYSTONONLOCAL | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_DRAWPRIMTLVERTEX |
 29+ D3DDEVCAPS_FLOATTLVERTEX, // dwDevCaps
 30+ { //dpcLineCaps
 31+ sizeof(D3DPRIMCAPS),
 32+ 0, // dwMiscCaps
 33+ D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_ZTEST, //dwRasterCaps
 34+ D3DPCMPCAPS_LESSEQUAL, //dwZCmpCaps
 35+ DDBD_16|DDBD_24|DDBD_32, //dwSrcBlendCaps
 36+ DDBD_16|DDBD_24|DDBD_32, //dwDestBlendCaps
 37+ 0, //dwAlphaCmpCaps
 38+ 0, //dwShadeCaps
 39+ 0, //dwTextureCaps
 40+ 0, //dwTextureFilterCaps
 41+ 0, //dwTextureBlendCaps
 42+ 0, //dwTextureAddressCaps
 43+ 0, //dwStippleWidth
 44+ 0 //dwStippleHeight
 45+ },
 46+ { //dpcTriCaps
 47+ sizeof(D3DPRIMCAPS),
 48+ 0, // dwMiscCaps
 49+ D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_ZTEST, //dwRasterCaps
 50+ D3DPCMPCAPS_LESSEQUAL, //dwZCmpCaps
 51+ 0, //dwSrcBlendCaps
 52+ 0, //dwDestBlendCaps
 53+ 0, //dwAlphaCmpCaps
 54+ 0, //dwShadeCaps
 55+ 0, //dwTextureCaps
 56+ 0, //dwTextureFilterCaps
 57+ 0, //dwTextureBlendCaps
 58+ 0, //dwTextureAddressCaps
 59+ 0, //dwStippleWidth
 60+ 0 //dwStippleHeight
 61+ },
 62+ DDBD_16|DDBD_24|DDBD_32, //dwDeviceRenderBitDepth
 63+ DDBD_16|DDBD_24|DDBD_32, //dwDeviceZBufferBitDepth
 64+ 0, //dwMinTextureWidth
 65+ 0, //dwMinTextureHeight
 66+ 0, //dwMaxTextureWidth
 67+ 0, //dwMaxTextureHeight
 68+ 0, //dwMaxTextureRepeat
 69+ 0, //dwMaxTextureAspectRatio
 70+ 0, //dwMaxAnisotropy
 71+ 0.0f, //dvGuardBandLeft
 72+ 0.0f, //dvGuardBandTop
 73+ 0.0f, //dvGuardBandRight
 74+ 0.0f, //dvGuardBandBottom
 75+ 0.0f, //dvExtentsAdjust
 76+ 0, //dwStencilCaps
 77+ 8, //dwFVFCaps
 78+ 0, //dwTextureOpCaps
 79+ 0, //wMaxTextureBlendStages
 80+ 0, //wMaxSimultaneousTextures
 81+ 8, //dwMaxActiveLights
 82+ 0.0f, //dvMaxVertexW
 83+ IID_IDirect3DHALDevice, //deviceGUID
 84+ 0, //wMaxUserClipPlanes
 85+ 0, //wMaxVertexBlendMatrices
 86+ D3DVTXPCAPS_DIRECTIONALLIGHTS, //dwVertexProcessingCaps
 87+ 0,0,0,0 //dwReserved1 through dwReserved4
 88+};
 89+
 90+struct D3DDevice
 91+{
 92+ char *name;
 93+ char *devname;
 94+};
 95+D3DDevice devices[3] =
 96+{
 97+ {
 98+ "Simulated RGB Rasterizer",
 99+ "DXGL RGB Rasterizer",
 100+ },
 101+ {
 102+ "DXGL Hardware Accelerator",
 103+ "DXGL D3D HAL",
 104+ },
 105+ {
 106+ "DXGL Hardware Accelerator with Transform and Lighting",
 107+ "DXGL D3D T&L HAL",
 108+ }
 109+};
26110 glDirect3D7::glDirect3D7(glDirectDraw7 *glDD7)
27111 {
28112 refcount=1;
@@ -75,8 +159,29 @@
76160 HRESULT WINAPI glDirect3D7::EnumDevices(LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg)
77161 {
78162 if(!this) return DDERR_INVALIDPARAMS;
79 - FIXME("glDirect3D7::EnumDevices: stub");
80 - return DDERR_GENERIC;
 163+ if(!lpEnumDevicesCallback) return DDERR_INVALIDPARAMS;
 164+ HRESULT result;
 165+ D3DDEVICEDESC7 desc = d3ddesc;
 166+ for(int i = 0; i < 3; i++)
 167+ {
 168+ switch(i)
 169+ {
 170+ case 0:
 171+ desc.deviceGUID = IID_IDirect3DRGBDevice;
 172+ break;
 173+ case 1:
 174+ desc.deviceGUID = IID_IDirect3DHALDevice;
 175+ desc.dwDevCaps |= D3DDEVCAPS_HWRASTERIZATION;
 176+ break;
 177+ case 2:
 178+ desc.deviceGUID = IID_IDirect3DTnLHalDevice;
 179+ desc.dwDevCaps |= D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_HWTRANSFORMANDLIGHT;
 180+ break;
 181+ }
 182+ result = lpEnumDevicesCallback(devices[i].name,devices[i].devname,&desc,lpUserArg);
 183+ if(result != D3DENUMRET_OK) break;
 184+ }
 185+ return D3D_OK;
81186 }
82187 HRESULT WINAPI glDirect3D7::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
83188 {
Index: ddraw/glDirect3DDevice.cpp
@@ -434,6 +434,7 @@
435435 HRESULT WINAPI glDirect3DDevice7::DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
436436 DWORD dwVertexCount, DWORD dwFlags)
437437 {
 438+ if(!this) return DDERR_INVALIDPARAMS;
438439 return DrawIndexedPrimitive(dptPrimitiveType,dwVertexTypeDesc,lpVertices,dwVertexCount,NULL,0,dwFlags);
439440 }
440441 HRESULT WINAPI glDirect3DDevice7::DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,