| Index: ddraw/glDirect3DViewport.cpp |
| — | — | @@ -47,10 +47,17 @@ |
| 48 | 48 | refcount = 1;
|
| 49 | 49 | current = false;
|
| 50 | 50 | glD3DV2 = NULL;
|
| | 51 | + glD3DV1 = NULL;
|
| 51 | 52 | }
|
| 52 | 53 |
|
| 53 | 54 | glDirect3DViewport3::~glDirect3DViewport3()
|
| 54 | 55 | {
|
| | 56 | + if(device) device->Release();
|
| | 57 | + if(backZ) backZ->Release();
|
| | 58 | + for(int i = 0; i < 8; i++)
|
| | 59 | + {
|
| | 60 | + if(lights[i]) lights[i]->Release();
|
| | 61 | + }
|
| 55 | 62 | }
|
| 56 | 63 |
|
| 57 | 64 | HRESULT WINAPI glDirect3DViewport3::QueryInterface(REFIID riid, void** ppvObj)
|
| — | — | @@ -84,6 +91,22 @@ |
| 85 | 92 | return D3D_OK;
|
| 86 | 93 | }
|
| 87 | 94 | }
|
| | 95 | + if(riid == IID_IDirect3DViewport)
|
| | 96 | + {
|
| | 97 | + if(glD3DV1)
|
| | 98 | + {
|
| | 99 | + *ppvObj = glD3DV1;
|
| | 100 | + glD3DV1->AddRef();
|
| | 101 | + return D3D_OK;
|
| | 102 | + }
|
| | 103 | + else
|
| | 104 | + {
|
| | 105 | + this->AddRef();
|
| | 106 | + *ppvObj = new glDirect3DViewport1(this);
|
| | 107 | + glD3DV1 = (glDirect3DViewport1*)*ppvObj;
|
| | 108 | + return D3D_OK;
|
| | 109 | + }
|
| | 110 | + }
|
| 88 | 111 | return E_NOINTERFACE;
|
| 89 | 112 | }
|
| 90 | 113 |
|
| — | — | @@ -446,3 +469,111 @@ |
| 447 | 470 | if(!this) return DDERR_INVALIDOBJECT;
|
| 448 | 471 | return glD3DV3->TransformVertices(dwVertexCount,lpData,dwFlags,lpOffscreen);
|
| 449 | 472 | }
|
| | 473 | +
|
| | 474 | +
|
| | 475 | +glDirect3DViewport1::glDirect3DViewport1(glDirect3DViewport3 *glD3DV3)
|
| | 476 | +{
|
| | 477 | + this->glD3DV3 = glD3DV3;
|
| | 478 | + refcount = 1;
|
| | 479 | +}
|
| | 480 | +
|
| | 481 | +glDirect3DViewport1::~glDirect3DViewport1()
|
| | 482 | +{
|
| | 483 | + glD3DV3->glD3DV1 = NULL;
|
| | 484 | + glD3DV3->Release();
|
| | 485 | +}
|
| | 486 | +
|
| | 487 | +ULONG WINAPI glDirect3DViewport1::AddRef()
|
| | 488 | +{
|
| | 489 | + if(!this) return 0;
|
| | 490 | + refcount++;
|
| | 491 | + return refcount;
|
| | 492 | +}
|
| | 493 | +
|
| | 494 | +ULONG WINAPI glDirect3DViewport1::Release()
|
| | 495 | +{
|
| | 496 | + if(!this) return 0;
|
| | 497 | + ULONG ret;
|
| | 498 | + refcount--;
|
| | 499 | + ret = refcount;
|
| | 500 | + if(refcount == 0) delete this;
|
| | 501 | + return ret;
|
| | 502 | +}
|
| | 503 | +
|
| | 504 | +HRESULT WINAPI glDirect3DViewport1::QueryInterface(REFIID riid, void** ppvObj)
|
| | 505 | +{
|
| | 506 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 507 | + if(riid == IID_IUnknown)
|
| | 508 | + {
|
| | 509 | + this->AddRef();
|
| | 510 | + *ppvObj = this;
|
| | 511 | + return D3D_OK;
|
| | 512 | + }
|
| | 513 | + return glD3DV3->QueryInterface(riid,ppvObj);
|
| | 514 | +}
|
| | 515 | +
|
| | 516 | +HRESULT WINAPI glDirect3DViewport1::AddLight(LPDIRECT3DLIGHT lpLight)
|
| | 517 | +{
|
| | 518 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 519 | + return glD3DV3->AddLight(lpLight);
|
| | 520 | +}
|
| | 521 | +HRESULT WINAPI glDirect3DViewport1::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
|
| | 522 | +{
|
| | 523 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 524 | + return glD3DV3->Clear(dwCount,lpRects,dwFlags);
|
| | 525 | +}
|
| | 526 | +HRESULT WINAPI glDirect3DViewport1::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
|
| | 527 | +{
|
| | 528 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 529 | + return glD3DV3->DeleteLight(lpDirect3DLight);
|
| | 530 | +}
|
| | 531 | +HRESULT WINAPI glDirect3DViewport1::GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
|
| | 532 | +{
|
| | 533 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 534 | + return glD3DV3->GetBackground(lphMat,lpValid);
|
| | 535 | +}
|
| | 536 | +HRESULT WINAPI glDirect3DViewport1::GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
|
| | 537 | +{
|
| | 538 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 539 | + return glD3DV3->GetBackgroundDepth(lplpDDSurface,lpValid);
|
| | 540 | +}
|
| | 541 | +HRESULT WINAPI glDirect3DViewport1::GetViewport(LPD3DVIEWPORT lpData)
|
| | 542 | +{
|
| | 543 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 544 | + return glD3DV3->GetViewport(lpData);
|
| | 545 | +}
|
| | 546 | +HRESULT WINAPI glDirect3DViewport1::Initialize(LPDIRECT3D lpDirect3D)
|
| | 547 | +{
|
| | 548 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 549 | + return glD3DV3->Initialize(lpDirect3D);
|
| | 550 | +}
|
| | 551 | +HRESULT WINAPI glDirect3DViewport1::LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData)
|
| | 552 | +{
|
| | 553 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 554 | + return glD3DV3->LightElements(dwElementCount,lpData);
|
| | 555 | +}
|
| | 556 | +HRESULT WINAPI glDirect3DViewport1::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
|
| | 557 | +{
|
| | 558 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 559 | + return glD3DV3->NextLight(lpDirect3DLight,lplpDirect3DLight,dwFlags);
|
| | 560 | +}
|
| | 561 | +HRESULT WINAPI glDirect3DViewport1::SetBackground(D3DMATERIALHANDLE hMat)
|
| | 562 | +{
|
| | 563 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 564 | + return glD3DV3->SetBackground(hMat);
|
| | 565 | +}
|
| | 566 | +HRESULT WINAPI glDirect3DViewport1::SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface)
|
| | 567 | +{
|
| | 568 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 569 | + return glD3DV3->SetBackgroundDepth(lpDDSurface);
|
| | 570 | +}
|
| | 571 | +HRESULT WINAPI glDirect3DViewport1::SetViewport(LPD3DVIEWPORT lpData)
|
| | 572 | +{
|
| | 573 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 574 | + return glD3DV3->SetViewport(lpData);
|
| | 575 | +}
|
| | 576 | +HRESULT WINAPI glDirect3DViewport1::TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
|
| | 577 | +{
|
| | 578 | + if(!this) return DDERR_INVALIDOBJECT;
|
| | 579 | + return glD3DV3->TransformVertices(dwVertexCount,lpData,dwFlags,lpOffscreen);
|
| | 580 | +}
|
| Index: ddraw/glDirect3DViewport.h |
| — | — | @@ -22,6 +22,7 @@ |
| 23 | 23 | class glDirect3DLight;
|
| 24 | 24 | class glDirect3DDevice7;
|
| 25 | 25 | class glDirectDrawSurface7;
|
| | 26 | +class glDirect3DViewport1;
|
| 26 | 27 | class glDirect3DViewport2;
|
| 27 | 28 | class glDirect3DViewport3 : public IDirect3DViewport3
|
| 28 | 29 | {
|
| — | — | @@ -54,6 +55,7 @@ |
| 55 | 56 | void Sync();
|
| 56 | 57 | void SyncLights();
|
| 57 | 58 | glDirect3DViewport2 *glD3DV2;
|
| | 59 | + glDirect3DViewport1 *glD3DV1;
|
| 58 | 60 | private:
|
| 59 | 61 | ULONG refcount;
|
| 60 | 62 | glDirect3DLight *lights[8];
|
| — | — | @@ -96,4 +98,30 @@ |
| 97 | 99 | int refcount;
|
| 98 | 100 | };
|
| 99 | 101 |
|
| | 102 | +class glDirect3DViewport1 : public IDirect3DViewport
|
| | 103 | +{
|
| | 104 | +public:
|
| | 105 | + glDirect3DViewport1(glDirect3DViewport3 *glD3DV3);
|
| | 106 | + virtual ~glDirect3DViewport1();
|
| | 107 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| | 108 | + ULONG WINAPI AddRef();
|
| | 109 | + ULONG WINAPI Release();
|
| | 110 | + HRESULT WINAPI AddLight(LPDIRECT3DLIGHT lpLight);
|
| | 111 | + HRESULT WINAPI Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
|
| | 112 | + HRESULT WINAPI DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight);
|
| | 113 | + HRESULT WINAPI GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
|
| | 114 | + HRESULT WINAPI GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
|
| | 115 | + HRESULT WINAPI GetViewport(LPD3DVIEWPORT lpData);
|
| | 116 | + HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
|
| | 117 | + HRESULT WINAPI LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData);
|
| | 118 | + HRESULT WINAPI NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
|
| | 119 | + HRESULT WINAPI SetBackground(D3DMATERIALHANDLE hMat);
|
| | 120 | + HRESULT WINAPI SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface);
|
| | 121 | + HRESULT WINAPI SetViewport(LPD3DVIEWPORT lpData);
|
| | 122 | + HRESULT WINAPI TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
|
| | 123 | +private:
|
| | 124 | + glDirect3DViewport3 *glD3DV3;
|
| | 125 | + int refcount;
|
| | 126 | +};
|
| | 127 | +
|
| 100 | 128 | #endif //__GLDIRECT3DVIEWPORT_H |
| \ No newline at end of file |