Index: ddraw/glDirect3D.cpp |
— | — | @@ -202,13 +202,20 @@ |
203 | 203 | TRACE_RET(HRESULT, 23, glDD7->QueryInterface(riid, ppvObj));
|
204 | 204 | }
|
205 | 205 |
|
206 | | -
|
207 | 206 | HRESULT WINAPI glDirect3D7::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7 *lplpD3DDevice)
|
208 | 207 | {
|
209 | | - TRACE_ENTER(4,14,this,24,&rclsid,14,lpDDS,14,lplpD3DDevice);
|
| 208 | + TRACE_ENTER(4, 14, this, 24, &rclsid, 14, lpDDS, 14, lplpD3DDevice);
|
| 209 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 210 | + TRACE_RET(HRESULLT, 23, CreateDevice2(rclsid, lpDDS, lplpD3DDevice, 7));
|
| 211 | +}
|
| 212 | +
|
| 213 | +HRESULT glDirect3D7::CreateDevice2(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7 *lplpD3DDevice, int version)
|
| 214 | +{
|
| 215 | + TRACE_ENTER(5,14,this,24,&rclsid,14,lpDDS,14,lplpD3DDevice,11,version);
|
210 | 216 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 217 | + if(!lplpD3DDevice) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
211 | 218 | HRESULT ret;
|
212 | | - glDirect3DDevice7 *glD3DDev7 = new glDirect3DDevice7(rclsid,this,(glDirectDrawSurface7*)lpDDS,NULL);
|
| 219 | + glDirect3DDevice7 *glD3DDev7 = new glDirect3DDevice7(rclsid,this,(glDirectDrawSurface7*)lpDDS,NULL,version);
|
213 | 220 | if(!glD3DDev7) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
214 | 221 | if(FAILED(glD3DDev7->err()))
|
215 | 222 | {
|
— | — | @@ -487,7 +494,7 @@ |
488 | 495 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
489 | 496 | if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
490 | 497 | LPDIRECT3DDEVICE7 lpD3DDev7;
|
491 | | - HRESULT err = glD3D7->CreateDevice(rclsid,((glDirectDrawSurface4*)lpDDS)->GetDDS7(),&lpD3DDev7);
|
| 498 | + HRESULT err = glD3D7->CreateDevice2(rclsid,((glDirectDrawSurface4*)lpDDS)->GetDDS7(),&lpD3DDev7,3);
|
492 | 499 | if(err == D3D_OK)
|
493 | 500 | {
|
494 | 501 | lpD3DDev7->QueryInterface(IID_IDirect3DDevice3,(LPVOID*)lplpD3DDevice);
|
— | — | @@ -606,7 +613,7 @@ |
607 | 614 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
608 | 615 | if(!lplpD3DDevice) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
609 | 616 | LPDIRECT3DDEVICE7 lpD3DDev7;
|
610 | | - HRESULT err = glD3D7->CreateDevice(rclsid,((glDirectDrawSurface1*)lpDDS)->GetDDS7(),&lpD3DDev7);
|
| 617 | + HRESULT err = glD3D7->CreateDevice2(rclsid,((glDirectDrawSurface1*)lpDDS)->GetDDS7(),&lpD3DDev7,2);
|
611 | 618 | if(err == D3D_OK)
|
612 | 619 | {
|
613 | 620 | lpD3DDev7->QueryInterface(IID_IDirect3DDevice2,(LPVOID*)lplpD3DDevice);
|
Index: ddraw/glDirect3D.h |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | HRESULT WINAPI EvictManagedTextures();
|
47 | 47 | HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
|
48 | 48 | glDirectDraw7 *glDD7;
|
| 49 | + HRESULT CreateDevice2(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7 *lplpD3DDevice, int version);
|
49 | 50 | };
|
50 | 51 |
|
51 | 52 | class glDirect3D3 : public IDirect3D3
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -271,9 +271,10 @@ |
272 | 272 | }
|
273 | 273 | }
|
274 | 274 |
|
275 | | -glDirect3DDevice7::glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7, IUnknown *creator)
|
| 275 | +glDirect3DDevice7::glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7, IUnknown *creator, int version)
|
276 | 276 | {
|
277 | 277 | TRACE_ENTER(4,14,this,24,&rclsid,14,glD3D7,14,glDDS7);
|
| 278 | + this->version = version;
|
278 | 279 | d3ddesc = d3ddesc_default;
|
279 | 280 | d3ddesc3 = d3ddesc3_default;
|
280 | 281 | int zbuffer = 0;
|
— | — | @@ -440,39 +441,45 @@ |
441 | 442 | TRACE_EXIT(23,D3D_OK);
|
442 | 443 | return D3D_OK;
|
443 | 444 | }
|
444 | | - if(riid == IID_IDirect3DDevice7)
|
| 445 | + if (creator) TRACE_RET(HRESULT, 23, creator->QueryInterface(riid, ppvObj));
|
| 446 | + if (version == 7)
|
445 | 447 | {
|
446 | | - this->AddRef();
|
447 | | - *ppvObj = this;
|
448 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
449 | | - TRACE_EXIT(23,D3D_OK);
|
450 | | - return D3D_OK;
|
| 448 | + if (riid == IID_IDirect3DDevice7)
|
| 449 | + {
|
| 450 | + this->AddRef();
|
| 451 | + *ppvObj = this;
|
| 452 | + TRACE_VAR("*ppvObj", 14, *ppvObj);
|
| 453 | + TRACE_EXIT(23, D3D_OK);
|
| 454 | + return D3D_OK;
|
| 455 | + }
|
451 | 456 | }
|
452 | | - if(riid == IID_IDirect3DDevice3)
|
| 457 | + else
|
453 | 458 | {
|
454 | | - *ppvObj = glD3DDev3;
|
455 | | - glD3DDev3->AddRef();
|
456 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
457 | | - TRACE_EXIT(23,D3D_OK);
|
458 | | - return D3D_OK;
|
| 459 | + if ((riid == IID_IDirect3DDevice3) && (version >= 3))
|
| 460 | + {
|
| 461 | + *ppvObj = glD3DDev3;
|
| 462 | + glD3DDev3->AddRef();
|
| 463 | + TRACE_VAR("*ppvObj", 14, *ppvObj);
|
| 464 | + TRACE_EXIT(23, D3D_OK);
|
| 465 | + return D3D_OK;
|
| 466 | + }
|
| 467 | + if ((riid == IID_IDirect3DDevice2) && (version >= 2))
|
| 468 | + {
|
| 469 | + *ppvObj = glD3DDev2;
|
| 470 | + glD3DDev2->AddRef();
|
| 471 | + TRACE_VAR("*ppvObj", 14, *ppvObj);
|
| 472 | + TRACE_EXIT(23, D3D_OK);
|
| 473 | + return D3D_OK;
|
| 474 | + }
|
| 475 | + if (riid == IID_IDirect3DDevice)
|
| 476 | + {
|
| 477 | + *ppvObj = glD3DDev1;
|
| 478 | + glD3DDev1->AddRef();
|
| 479 | + TRACE_VAR("*ppvObj", 14, *ppvObj);
|
| 480 | + TRACE_EXIT(23, D3D_OK);
|
| 481 | + return D3D_OK;
|
| 482 | + }
|
459 | 483 | }
|
460 | | - if(riid == IID_IDirect3DDevice2)
|
461 | | - {
|
462 | | - *ppvObj = glD3DDev2;
|
463 | | - glD3DDev2->AddRef();
|
464 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
465 | | - TRACE_EXIT(23,D3D_OK);
|
466 | | - return D3D_OK;
|
467 | | - }
|
468 | | - if(riid == IID_IDirect3DDevice)
|
469 | | - {
|
470 | | - *ppvObj = glD3DDev1;
|
471 | | - glD3DDev1->AddRef();
|
472 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
473 | | - TRACE_EXIT(23,D3D_OK);
|
474 | | - return D3D_OK;
|
475 | | - }
|
476 | | - if (creator) TRACE_RET(HRESULT, 23, creator->QueryInterface(riid, ppvObj));
|
477 | 484 | TRACE_EXIT(23,E_NOINTERFACE);
|
478 | 485 | return E_NOINTERFACE;
|
479 | 486 | }
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | class glDirect3DDevice7 : public IDirect3DDevice7
|
72 | 72 | {
|
73 | 73 | public:
|
74 | | - glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7, IUnknown *creator);
|
| 74 | + glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7, IUnknown *creator, int version);
|
75 | 75 | virtual ~glDirect3DDevice7();
|
76 | 76 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
77 | 77 | ULONG WINAPI AddRef();
|
— | — | @@ -235,6 +235,7 @@ |
236 | 236 | D3DDEVICEDESC d3ddesc3;
|
237 | 237 | glRenderer *renderer;
|
238 | 238 | IUnknown *creator;
|
| 239 | + int version;
|
239 | 240 | };
|
240 | 241 |
|
241 | 242 | #endif //__GLDIRECT3DDEVICE_H
|
— | — | @@ -336,6 +337,7 @@ |
337 | 338 | HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
338 | 339 | HRESULT WINAPI SwapTextureHandles(LPDIRECT3DTEXTURE2 lpD3DTex1, LPDIRECT3DTEXTURE2 lpD3DTex2);
|
339 | 340 | HRESULT WINAPI Vertex(LPVOID lpVertexType);
|
| 341 | + glDirect3DDevice7 *GetGLD3DDev7(){ return glD3DDev7; }
|
340 | 342 | private:
|
341 | 343 | glDirect3DDevice7 *glD3DDev7;
|
342 | 344 | };
|
— | — | @@ -368,6 +370,7 @@ |
369 | 371 | LPD3DRECT lpRect);
|
370 | 372 | HRESULT WINAPI SetMatrix(D3DMATRIXHANDLE d3dMatHandle, LPD3DMATRIX lpD3DMatrix);
|
371 | 373 | HRESULT WINAPI SwapTextureHandles(LPDIRECT3DTEXTURE lpD3DTex1, LPDIRECT3DTEXTURE lpD3DTex2);
|
| 374 | + glDirect3DDevice7 *GetGLD3DDev7(){ return glD3DDev7; }
|
372 | 375 | private:
|
373 | 376 | glDirect3DDevice7 *glD3DDev7;
|
374 | 377 | }; |
\ No newline at end of file |
Index: ddraw/glDirect3DMaterial.cpp |
— | — | @@ -233,10 +233,8 @@ |
234 | 234 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
235 | 235 | if(!lpDirect3DDevice) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
236 | 236 | glDirect3DDevice2 *glD3DDev2 = (glDirect3DDevice2*)lpDirect3DDevice;
|
237 | | - glDirect3DDevice3 *glD3DDev3;
|
238 | | - glD3DDev2->QueryInterface(IID_IDirect3DDevice3,(void**)&glD3DDev3);
|
| 237 | + glDirect3DDevice3 *glD3DDev3 = glD3DDev2->GetGLD3DDev7()->glD3DDev3;
|
239 | 238 | HRESULT ret = glD3DM3->GetHandle(glD3DDev3,lpHandle);
|
240 | | - glD3DDev3->Release();
|
241 | 239 | TRACE_EXIT(23,ret);
|
242 | 240 | return ret;
|
243 | 241 | }
|
— | — | @@ -296,10 +294,8 @@ |
297 | 295 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
298 | 296 | if(!lpDirect3DDevice) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
299 | 297 | glDirect3DDevice1 *glD3DDev1 = (glDirect3DDevice1*)lpDirect3DDevice;
|
300 | | - glDirect3DDevice3 *glD3DDev3;
|
301 | | - glD3DDev1->QueryInterface(IID_IDirect3DDevice3,(void**)&glD3DDev3);
|
| 298 | + glDirect3DDevice3 *glD3DDev3 = glD3DDev1->GetGLD3DDev7()->glD3DDev3;
|
302 | 299 | HRESULT ret = glD3DM3->GetHandle(glD3DDev3,lpHandle);
|
303 | | - glD3DDev3->Release();
|
304 | 300 | TRACE_EXIT(23,ret);
|
305 | 301 | return ret;
|
306 | 302 | }
|
Index: ddraw/glDirect3DTexture.cpp |
— | — | @@ -66,10 +66,8 @@ |
67 | 67 | TRACE_ENTER(3,14,this,14,lpDirect3DDevice2,14,lpHandle);
|
68 | 68 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
69 | 69 | if(!lpDirect3DDevice2) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
70 | | - glDirect3DDevice7 *glD3DDev7;
|
71 | | - lpDirect3DDevice2->QueryInterface(IID_IDirect3DDevice7,(void**)&glD3DDev7);
|
| 70 | + glDirect3DDevice7 *glD3DDev7 = ((glDirect3DDevice2*)lpDirect3DDevice2)->GetGLD3DDev7();
|
72 | 71 | HRESULT ret = glDDS7->GetHandle(glD3DDev7,lpHandle);
|
73 | | - glD3DDev7->Release();
|
74 | 72 | TRACE_EXIT(23,ret);
|
75 | 73 | return ret;
|
76 | 74 | }
|
— | — | @@ -127,10 +125,8 @@ |
128 | 126 | TRACE_ENTER(3,14,this,14,lpDirect3DDevice,14,lpHandle);
|
129 | 127 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
130 | 128 | if(!lpDirect3DDevice) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
131 | | - glDirect3DDevice7 *glD3DDev7;
|
132 | | - lpDirect3DDevice->QueryInterface(IID_IDirect3DDevice7,(void**)&glD3DDev7);
|
| 129 | + glDirect3DDevice7 *glD3DDev7 = ((glDirect3DDevice1*)lpDirect3DDevice)->GetGLD3DDev7();
|
133 | 130 | HRESULT ret = glDDS7->GetHandle(glD3DDev7,lpHandle);
|
134 | | - glD3DDev7->Release();
|
135 | 131 | TRACE_EXIT(23,ret);
|
136 | 132 | return ret;
|
137 | 133 | }
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | glDirect3D7 *tmpd3d;
|
519 | 519 | ddInterface->QueryInterface(IID_IDirect3D7,(void**)&tmpd3d);
|
520 | 520 | if(!tmpd3d) TRACE_RET(HRESULT,23,E_NOINTERFACE);
|
521 | | - device1 = new glDirect3DDevice7(riid, tmpd3d, this, dds1);
|
| 521 | + device1 = new glDirect3DDevice7(riid, tmpd3d, this, dds1, 1);
|
522 | 522 | if (FAILED(device1->err()))
|
523 | 523 | {
|
524 | 524 | ret = device1->err();
|
— | — | @@ -535,10 +535,11 @@ |
536 | 536 | }
|
537 | 537 | else
|
538 | 538 | {
|
539 | | - HRESULT ret = device1->QueryInterface(IID_IDirect3DDevice,ppvObj);
|
| 539 | + *ppvObj = device1->glD3DDev1;
|
| 540 | + device1->glD3DDev1->AddRef();
|
540 | 541 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
541 | | - TRACE_EXIT(23,ret);
|
542 | | - return ret;
|
| 542 | + TRACE_EXIT(23,DD_OK);
|
| 543 | + return DD_OK;
|
543 | 544 | }
|
544 | 545 | }
|
545 | 546 | if (version == 7)
|