DXGL r190 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r189‎ | r190 | r191 >
Date:00:46, 3 July 2012
Author:admin
Status:new
Tags:
Comment:
(DOES NOT BUILD) Added some IDirect3DDevice3 functions.
Added header entries for IDirect3DVertexBuffer interface.
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirect3DVertexBuffer.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -22,6 +22,8 @@
2323 #include "glDirectDraw.h"
2424 #include "glDirectDrawSurface.h"
2525 #include "glDirect3DMaterial.h"
 26+#include "glDirect3DViewport.h"
 27+#include "glDirect3DVertexBuffer.h"
2628 #include "glDirect3DDevice.h"
2729 #include "glDirect3DLight.h"
2830 #include <string>
@@ -212,6 +214,10 @@
213215 materials = (glDirect3DMaterial3**)malloc(32*sizeof(glDirect3DMaterial3*));
214216 materialcount = 1;
215217 materials[0] = NULL;
 218+ maxviewports = 32;
 219+ viewportcount = 0;
 220+ viewports = (glDirect3DViewport3**)malloc(32*sizeof(glDirect3DViewport3*));
 221+ ZeroMemory(viewports,32*sizeof(glDirect3DViewport3*));
216222 vertices = normals = NULL;
217223 diffuse = specular = NULL;
218224 ZeroMemory(texcoords,8*sizeof(GLfloat*));
@@ -1312,6 +1318,25 @@
13131319 return materialcount-1;
13141320 }
13151321
 1322+HRESULT glDirect3DDevice7::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
 1323+{
 1324+ if(!this) return DDERR_INVALIDOBJECT;
 1325+ if(!lpDirect3DViewport) return DDERR_INVALIDPARAMS;
 1326+ for(int i = 0; i < maxviewports; i++)
 1327+ {
 1328+ if(viewports[i] == lpDirect3DViewport) return DDERR_INVALIDPARAMS;
 1329+ }
 1330+ viewports[viewportcount] = (glDirect3DViewport3*)lpDirect3DViewport;
 1331+ viewports[viewportcount]->AddRef();
 1332+ viewportcount++;
 1333+ if(viewportcount >= maxviewports)
 1334+ {
 1335+ maxviewports += 32;
 1336+ viewports = (glDirect3DViewport3**)realloc(viewports,maxviewports*sizeof(glDirect3DViewport3*));
 1337+ }
 1338+ return D3D_OK;
 1339+}
 1340+
13161341 // IDirect3DDevice3 wrapper
13171342 glDirect3DDevice3::glDirect3DDevice3(glDirect3DDevice7 *glD3DDev7)
13181343 {
@@ -1355,26 +1380,90 @@
13561381
13571382 HRESULT WINAPI glDirect3DDevice3::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
13581383 {
 1384+ if(!this) return DDERR_INVALIDOBJECT;
 1385+ return glD3DDev7->AddViewport(lpDirect3DViewport);
13591386 }
13601387
1361 - HRESULT WINAPI Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags);
1362 - HRESULT WINAPI BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
1363 - HRESULT WINAPI BeginScene();
1364 - HRESULT WINAPI ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
1365 - HRESULT WINAPI DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
1366 - HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
1367 - LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
1368 - HRESULT WINAPI DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
1369 - LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVerticexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
1370 - HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
1371 - LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
1372 - HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
1373 - DWORD dwVertexCount, DWORD dwFlags);
1374 - HRESULT WINAPI DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,
1375 - LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, DWORD dwFlags);
1376 - HRESULT WINAPI DrawPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
1377 - DWORD dwStartVertex, DWORD dwNumVertices, DWORD dwFlags);
1378 - HRESULT WINAPI End(DWORD dwFlags);
 1388+HRESULT WINAPI glDirect3DDevice3::Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags)
 1389+{
 1390+ if(!this) return DDERR_INVALIDOBJECT;
 1391+ return glD3DDev7->Begin(d3dpt,dwVertexTypeDesc,dwFlags);
 1392+}
 1393+
 1394+HRESULT WINAPI glDirect3DDevice3::BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags)
 1395+{
 1396+ if(!this) return DDERR_INVALIDOBJECT;
 1397+ return glD3DDev7->BeginIndexed(dptPrimitiveType,dwVertexTypeDesc,lpvVertices,dwNumVertices,dwFlags);
 1398+}
 1399+
 1400+HRESULT WINAPI glDirect3DDevice3::BeginScene()
 1401+{
 1402+ if(!this) return DDERR_INVALIDOBJECT;
 1403+ return glD3DDev7->BeginScene();
 1404+}
 1405+
 1406+HRESULT WINAPI glDirect3DDevice3::ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues)
 1407+{
 1408+ if(!this) return DDERR_INVALIDOBJECT;
 1409+ return glD3DDev7->ComputeSphereVisibility3(lpCenters,lpRadii,dwNumSpheres,dwFlags,lpdwReturnValues);
 1410+}
 1411+
 1412+HRESULT WINAPI glDirect3DDevice3::DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
 1413+{
 1414+ if(!this) return DDERR_INVALIDOBJECT;
 1415+ return glD3DDev7->DeleteViewport(lpDirect3DViewport);
 1416+}
 1417+
 1418+HRESULT WINAPI glDirect3DDevice3::DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
 1419+ LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
 1420+{
 1421+ if(!this) return DDERR_INVALIDOBJECT;
 1422+ return glD3DDev7->DrawIndexedPrimitive(d3dptPrimitiveType,dwVertexTypeDesc,lpvVertices,dwVertexCount,lpwIndices,dwIndexCount,dwFlags);
 1423+}
 1424+
 1425+HRESULT WINAPI glDirect3DDevice3::DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
 1426+ LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
 1427+{
 1428+ if(!this) return DDERR_INVALIDOBJECT;
 1429+ return glD3DDev7->DrawIndexedPrimitiveStrided(d3dptPrimitiveType,dwVertexTypeDesc,lpVertexArray,dwVertexCount,lpwIndices,dwIndexCount,dwFlags);
 1430+}
 1431+
 1432+HRESULT WINAPI glDirect3DDevice3::DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
 1433+ LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
 1434+{
 1435+ if(!this) return DDERR_INVALIDOBJECT;
 1436+ if(!lpd3dVertexBuffer) return DDERR_INVALIDPARAMS;
 1437+ return glD3DDev7->DrawIndexedPrimitiveVB(d3dptPrimitiveType,
 1438+ ((glDirect3DVertexBuffer1*)lpd3dVertexBuffer)->GetGLD3DVB7(),0,-1,lpwIndices,dwIndexCount,dwFlags);
 1439+}
 1440+
 1441+HRESULT WINAPI glDirect3DDevice3::DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
 1442+ DWORD dwVertexCount, DWORD dwFlags)
 1443+{
 1444+ if(!this) return DDERR_INVALIDOBJECT;
 1445+ return glD3DDev7->DrawPrimitive(dptPrimitiveType,dwVertexTypeDesc,lpVertices,dwVertexCount,dwFlags);
 1446+}
 1447+
 1448+HRESULT WINAPI glDirect3DDevice3::DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,
 1449+ LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, DWORD dwFlags)
 1450+{
 1451+ if(!this) return DDERR_INVALIDOBJECT;
 1452+ return glD3DDev7->DrawPrimitiveStrided(dptPrimitiveType,dwVertexTypeDesc,lpVertexArray,dwVertexCount,dwFlags);
 1453+}
 1454+
 1455+HRESULT WINAPI glDirect3DDevice3::DrawPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
 1456+ DWORD dwStartVertex, DWORD dwNumVertices, DWORD dwFlags)
 1457+{
 1458+ if(!this) return DDERR_INVALIDOBJECT;
 1459+ if(!lpd3dVertexBuffer) return DDERR_INVALIDPARAMS;
 1460+ return glD3DDev7->DrawPrimitiveVB(d3dptPrimitiveType,((glDirect3DVertexBuffer1*)lpd3dVertexBuffer)->GetGLD3DVB7(),
 1461+ dwStartVertex,dwNumVertices,dwFlags);
 1462+}
 1463+HRESULT WINAPI glDirect3DDevice3::End(DWORD dwFlags)
 1464+{
 1465+ if(!this) return DDERR_INVALIDOBJECT;
 1466+ return glD3DDev7->End(dwFlags);
 1467+}
13791468 HRESULT WINAPI EndScene();
13801469 HRESULT WINAPI EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg);
13811470 HRESULT WINAPI GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
Index: ddraw/glDirect3DDevice.h
@@ -57,6 +57,7 @@
5858 class glDirect3DLight;
5959 class glDirectDrawSurface7;
6060 class glDirect3DMaterial3;
 61+class glDirect3DViewport3;
6162 class glDirect3DDevice7 : public IDirect3DDevice7
6263 {
6364 public:
@@ -77,7 +78,7 @@
7879 HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
7980 LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
8081 HRESULT WINAPI DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
81 - LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVerticexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
 82+ LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
8283 HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER7 lpd3dVertexBuffer,
8384 DWORD dwStartVertex, DWORD dwNumVertices, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
8485 HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
@@ -124,6 +125,12 @@
125126 void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
126127 void SetDepthComp();
127128 D3DMATERIALHANDLE AddMaterial(glDirect3DMaterial3* material);
 129+ HRESULT AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
 130+ HRESULT DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
 131+ HRESULT Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags);
 132+ HRESULT BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
 133+ HRESULT End(DWORD dwFlags);
 134+ HRESULT ComputeSphereVisibility3(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
128135 __int64 SelectShader(GLVERTEX *VertexType);
129136 void UpdateNormalMatrix();
130137 GLfloat matWorld[16];
@@ -160,6 +167,9 @@
161168 GLVERTEX vertdata[18];
162169 int texformats[8];
163170 int maxmaterials;
 171+ glDirect3DViewport3 **viewports;
 172+ int viewportcount;
 173+ int maxviewports;
164174 };
165175
166176 #endif //__GLDIRECT3DDEVICE_H
@@ -174,7 +184,7 @@
175185 ULONG WINAPI Release();
176186 HRESULT WINAPI AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
177187 HRESULT WINAPI Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags);
178 - HRESULT WINAPI BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
 188+ HRESULT WINAPI BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
179189 HRESULT WINAPI BeginScene();
180190 HRESULT WINAPI ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
181191 HRESULT WINAPI DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
@@ -181,7 +191,7 @@
182192 HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
183193 LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
184194 HRESULT WINAPI DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
185 - LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVerticexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
 195+ LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
186196 HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
187197 LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
188198 HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
Index: ddraw/glDirect3DVertexBuffer.h
@@ -23,7 +23,7 @@
2424 {
2525 public:
2626 glDirect3DVertexBuffer7(glDirect3D7 *glD3DD7, D3DVERTEXBUFFERDESC desc, DWORD flags);
27 - ~glDirect3DVertexBuffer7();
 27+ virtual ~glDirect3DVertexBuffer7();
2828 HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
2929 ULONG WINAPI AddRef();
3030 ULONG WINAPI Release();
@@ -42,4 +42,25 @@
4343 DWORD flags;
4444 };
4545
 46+
 47+class glDirect3DVertexBuffer1 : public IDirect3DVertexBuffer
 48+{
 49+public:
 50+ glDirect3DVertexBuffer1(glDirect3DVertexBuffer7 *glD3DVB7);
 51+ virtual ~glDirect3DVertexBuffer1();
 52+ HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
 53+ ULONG WINAPI AddRef();
 54+ ULONG WINAPI Release();
 55+ HRESULT WINAPI GetVertexBufferDesc(LPD3DVERTEXBUFFERDESC lpVBDesc);
 56+ HRESULT WINAPI Lock(DWORD dwFlags, LPVOID* lplpData, LPDWORD lpdwSize);
 57+ HRESULT WINAPI Optimize(LPDIRECT3DDEVICE3 lpD3DDevice,DWORD dwFlags);
 58+ HRESULT WINAPI ProcessVertices(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount,
 59+ LPDIRECT3DVERTEXBUFFER lpSrcBuffer, DWORD dwSrcIndex, LPDIRECT3DDEVICE3 lpD3DDevice, DWORD dwFlags);
 60+ HRESULT WINAPI Unlock();
 61+ glDirect3DVertexBuffer7 *GetGLD3DVB7(){return glD3DVB7;}
 62+private:
 63+ glDirect3DVertexBuffer7 *glD3DVB7;
 64+};
 65+
 66+
4667 #endif //__GLDIRECT3DVERTEXBUFFER_H
\ No newline at end of file