Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -22,6 +22,8 @@ |
23 | 23 | #include "glDirectDraw.h"
|
24 | 24 | #include "glDirectDrawSurface.h"
|
25 | 25 | #include "glDirect3DMaterial.h"
|
| 26 | +#include "glDirect3DViewport.h"
|
| 27 | +#include "glDirect3DVertexBuffer.h"
|
26 | 28 | #include "glDirect3DDevice.h"
|
27 | 29 | #include "glDirect3DLight.h"
|
28 | 30 | #include <string>
|
— | — | @@ -212,6 +214,10 @@ |
213 | 215 | materials = (glDirect3DMaterial3**)malloc(32*sizeof(glDirect3DMaterial3*));
|
214 | 216 | materialcount = 1;
|
215 | 217 | materials[0] = NULL;
|
| 218 | + maxviewports = 32;
|
| 219 | + viewportcount = 0;
|
| 220 | + viewports = (glDirect3DViewport3**)malloc(32*sizeof(glDirect3DViewport3*));
|
| 221 | + ZeroMemory(viewports,32*sizeof(glDirect3DViewport3*));
|
216 | 222 | vertices = normals = NULL;
|
217 | 223 | diffuse = specular = NULL;
|
218 | 224 | ZeroMemory(texcoords,8*sizeof(GLfloat*));
|
— | — | @@ -1312,6 +1318,25 @@ |
1313 | 1319 | return materialcount-1;
|
1314 | 1320 | }
|
1315 | 1321 |
|
| 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 | +
|
1316 | 1341 | // IDirect3DDevice3 wrapper
|
1317 | 1342 | glDirect3DDevice3::glDirect3DDevice3(glDirect3DDevice7 *glD3DDev7)
|
1318 | 1343 | {
|
— | — | @@ -1355,26 +1380,90 @@ |
1356 | 1381 |
|
1357 | 1382 | HRESULT WINAPI glDirect3DDevice3::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
|
1358 | 1383 | {
|
| 1384 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1385 | + return glD3DDev7->AddViewport(lpDirect3DViewport);
|
1359 | 1386 | }
|
1360 | 1387 |
|
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 | +}
|
1379 | 1468 | HRESULT WINAPI EndScene();
|
1380 | 1469 | HRESULT WINAPI EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg);
|
1381 | 1470 | HRESULT WINAPI GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -57,6 +57,7 @@ |
58 | 58 | class glDirect3DLight;
|
59 | 59 | class glDirectDrawSurface7;
|
60 | 60 | class glDirect3DMaterial3;
|
| 61 | +class glDirect3DViewport3;
|
61 | 62 | class glDirect3DDevice7 : public IDirect3DDevice7
|
62 | 63 | {
|
63 | 64 | public:
|
— | — | @@ -77,7 +78,7 @@ |
78 | 79 | HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
79 | 80 | LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
80 | 81 | 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);
|
82 | 83 | HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER7 lpd3dVertexBuffer,
|
83 | 84 | DWORD dwStartVertex, DWORD dwNumVertices, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
84 | 85 | HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
|
— | — | @@ -124,6 +125,12 @@ |
125 | 126 | void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
|
126 | 127 | void SetDepthComp();
|
127 | 128 | 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);
|
128 | 135 | __int64 SelectShader(GLVERTEX *VertexType);
|
129 | 136 | void UpdateNormalMatrix();
|
130 | 137 | GLfloat matWorld[16];
|
— | — | @@ -160,6 +167,9 @@ |
161 | 168 | GLVERTEX vertdata[18];
|
162 | 169 | int texformats[8];
|
163 | 170 | int maxmaterials;
|
| 171 | + glDirect3DViewport3 **viewports;
|
| 172 | + int viewportcount;
|
| 173 | + int maxviewports;
|
164 | 174 | };
|
165 | 175 |
|
166 | 176 | #endif //__GLDIRECT3DDEVICE_H
|
— | — | @@ -174,7 +184,7 @@ |
175 | 185 | ULONG WINAPI Release();
|
176 | 186 | HRESULT WINAPI AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
177 | 187 | 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);
|
179 | 189 | HRESULT WINAPI BeginScene();
|
180 | 190 | HRESULT WINAPI ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
|
181 | 191 | HRESULT WINAPI DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
— | — | @@ -181,7 +191,7 @@ |
182 | 192 | HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
183 | 193 | LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
184 | 194 | 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);
|
186 | 196 | HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
|
187 | 197 | LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
188 | 198 | HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
|
Index: ddraw/glDirect3DVertexBuffer.h |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | {
|
25 | 25 | public:
|
26 | 26 | glDirect3DVertexBuffer7(glDirect3D7 *glD3DD7, D3DVERTEXBUFFERDESC desc, DWORD flags);
|
27 | | - ~glDirect3DVertexBuffer7();
|
| 27 | + virtual ~glDirect3DVertexBuffer7();
|
28 | 28 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
29 | 29 | ULONG WINAPI AddRef();
|
30 | 30 | ULONG WINAPI Release();
|
— | — | @@ -42,4 +42,25 @@ |
43 | 43 | DWORD flags;
|
44 | 44 | };
|
45 | 45 |
|
| 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 | +
|
46 | 67 | #endif //__GLDIRECT3DVERTEXBUFFER_H |
\ No newline at end of file |