Index: ddraw/glDirect3D.cpp |
— | — | @@ -188,11 +188,13 @@ |
189 | 189 | this->glDD7 = glDD7;
|
190 | 190 | glDD7->AddRef();
|
191 | 191 | glD3D3 = NULL;
|
| 192 | + glD3D2 = NULL;
|
192 | 193 | }
|
193 | 194 |
|
194 | 195 | glDirect3D7::~glDirect3D7()
|
195 | 196 | {
|
196 | 197 | if(glD3D3) glD3D3->Release();
|
| 198 | + if(glD3D2) glD3D2->Release();
|
197 | 199 | glDD7->Release();
|
198 | 200 | }
|
199 | 201 |
|
— | — | @@ -238,6 +240,22 @@ |
239 | 241 | return D3D_OK;
|
240 | 242 | }
|
241 | 243 | }
|
| 244 | + if(riid == IID_IDirect3D2)
|
| 245 | + {
|
| 246 | + if(glD3D2)
|
| 247 | + {
|
| 248 | + *ppvObj = glD3D2;
|
| 249 | + glD3D2->AddRef();
|
| 250 | + return D3D_OK;
|
| 251 | + }
|
| 252 | + else
|
| 253 | + {
|
| 254 | + this->AddRef();
|
| 255 | + *ppvObj = new glDirect3D2(this);
|
| 256 | + glD3D2 = (glDirect3D2*)*ppvObj;
|
| 257 | + return D3D_OK;
|
| 258 | + }
|
| 259 | + }
|
242 | 260 | return E_NOINTERFACE;
|
243 | 261 | }
|
244 | 262 |
|
— | — | @@ -487,7 +505,7 @@ |
488 | 506 | return ret;
|
489 | 507 | }
|
490 | 508 |
|
491 | | -HRESULT WINAPI glDirect3D3::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 * lplpD3DDevice, LPUNKNOWN pUnkOuter)
|
| 509 | +HRESULT WINAPI glDirect3D3::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 *lplpD3DDevice, LPUNKNOWN pUnkOuter)
|
492 | 510 | {
|
493 | 511 | if(!this) return DDERR_INVALIDPARAMS;
|
494 | 512 | if(pUnkOuter) return DDERR_INVALIDPARAMS;
|
— | — | @@ -538,7 +556,7 @@ |
539 | 557 | return glD3D7->EnumDevices3(lpEnumDevicesCallback,lpUserArg);
|
540 | 558 | }
|
541 | 559 |
|
542 | | -HRESULT WINAPI glDirect3D3::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
|
| 560 | +HRESULT WINAPI glDirect3D3::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
|
543 | 561 | {
|
544 | 562 | if(!this) return DDERR_INVALIDPARAMS;
|
545 | 563 | return glD3D7->EnumZBufferFormats(riidDevice,lpEnumCallback,lpContext);
|
— | — | @@ -553,3 +571,100 @@ |
554 | 572 | if(!this) return DDERR_INVALIDPARAMS;
|
555 | 573 | return glD3D7->FindDevice(lpD3DFDS,lpD3DFDR);
|
556 | 574 | }
|
| 575 | +
|
| 576 | +
|
| 577 | +glDirect3D2::glDirect3D2(glDirect3D7 *glD3D7)
|
| 578 | +{
|
| 579 | + this->glD3D7 = glD3D7;
|
| 580 | + refcount = 1;
|
| 581 | +}
|
| 582 | +
|
| 583 | +glDirect3D2::~glDirect3D2()
|
| 584 | +{
|
| 585 | + glD3D7->Release();
|
| 586 | +}
|
| 587 | +
|
| 588 | +HRESULT WINAPI glDirect3D2::QueryInterface(REFIID riid, void** ppvObj)
|
| 589 | +{
|
| 590 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 591 | + if(riid == IID_IUnknown)
|
| 592 | + {
|
| 593 | + this->AddRef();
|
| 594 | + *ppvObj = this;
|
| 595 | + return DD_OK;
|
| 596 | + }
|
| 597 | + return glD3D7->QueryInterface(riid,ppvObj);
|
| 598 | +}
|
| 599 | +
|
| 600 | +ULONG WINAPI glDirect3D2::AddRef()
|
| 601 | +{
|
| 602 | + if(!this) return 0;
|
| 603 | + refcount++;
|
| 604 | + return refcount;
|
| 605 | +}
|
| 606 | +
|
| 607 | +ULONG WINAPI glDirect3D2::Release()
|
| 608 | +{
|
| 609 | + if(!this) return 0;
|
| 610 | + ULONG ret;
|
| 611 | + refcount--;
|
| 612 | + ret = refcount;
|
| 613 | + if(refcount == 0) delete this;
|
| 614 | + return ret;
|
| 615 | +}
|
| 616 | +
|
| 617 | +HRESULT WINAPI glDirect3D2::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DDEVICE2 *lplpD3DDevice)
|
| 618 | +{
|
| 619 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 620 | + LPDIRECT3DDEVICE7 lpD3DDev7;
|
| 621 | + HRESULT err = glD3D7->CreateDevice(rclsid,((glDirectDrawSurface1*)lpDDS)->GetDDS7(),&lpD3DDev7);
|
| 622 | + if(err == D3D_OK)
|
| 623 | + {
|
| 624 | + lpD3DDev7->QueryInterface(IID_IDirect3DDevice2,(LPVOID*)lplpD3DDevice);
|
| 625 | + lpD3DDev7->Release();
|
| 626 | + return D3D_OK;
|
| 627 | + }
|
| 628 | + return err;
|
| 629 | +}
|
| 630 | +
|
| 631 | +HRESULT WINAPI glDirect3D2::CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter)
|
| 632 | +{
|
| 633 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 634 | + return glD3D7->CreateLight(lplpDirect3DLight,pUnkOuter);
|
| 635 | +}
|
| 636 | +
|
| 637 | +HRESULT WINAPI glDirect3D2::CreateMaterial(LPDIRECT3DMATERIAL2* lplpDirect3DMaterial2, IUnknown* pUnkOuter)
|
| 638 | +{
|
| 639 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 640 | + if(!lplpDirect3DMaterial2) return DDERR_INVALIDPARAMS;
|
| 641 | + glDirect3DMaterial3 *glD3DM3;
|
| 642 | + HRESULT error = glD3D7->CreateMaterial((LPDIRECT3DMATERIAL3*)&glD3DM3,pUnkOuter);
|
| 643 | + if(error) return error;
|
| 644 | + glD3DM3->QueryInterface(IID_IDirect3DMaterial2,(void**)lplpDirect3DMaterial2);
|
| 645 | + glD3DM3->Release();
|
| 646 | + return D3D_OK;
|
| 647 | +}
|
| 648 | +
|
| 649 | +HRESULT WINAPI glDirect3D2::CreateViewport(LPDIRECT3DVIEWPORT2* lplpD3DViewport2, IUnknown* pUnkOuter)
|
| 650 | +{
|
| 651 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 652 | + if(!lplpD3DViewport2) return DDERR_INVALIDPARAMS;
|
| 653 | + glDirect3DMaterial3 *glD3DV3;
|
| 654 | + HRESULT error = glD3D7->CreateViewport((LPDIRECT3DVIEWPORT3*)&glD3DV3,pUnkOuter);
|
| 655 | + if(error) return error;
|
| 656 | + glD3DV3->QueryInterface(IID_IDirect3DViewport2,(void**)lplpD3DViewport2);
|
| 657 | + glD3DV3->Release();
|
| 658 | + return D3D_OK;
|
| 659 | +}
|
| 660 | +
|
| 661 | +HRESULT WINAPI glDirect3D2::EnumDevices(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg)
|
| 662 | +{
|
| 663 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 664 | + return glD3D7->EnumDevices3(lpEnumDevicesCallback,lpUserArg);
|
| 665 | +}
|
| 666 | +
|
| 667 | +HRESULT WINAPI glDirect3D2::FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR)
|
| 668 | +{
|
| 669 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 670 | + return glD3D7->FindDevice(lpD3DFDS,lpD3DFDR);
|
| 671 | +}
|
Index: ddraw/glDirect3D.h |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | class glDirectDraw7;
|
26 | 26 |
|
27 | 27 | class glDirect3D3;
|
| 28 | +class glDirect3D2;
|
28 | 29 | class glDirect3D7 : public IDirect3D7
|
29 | 30 | {
|
30 | 31 | public:
|
— | — | @@ -46,17 +47,18 @@ |
47 | 48 | private:
|
48 | 49 | ULONG refcount;
|
49 | 50 | glDirect3D3 *glD3D3;
|
| 51 | + glDirect3D2 *glD3D2;
|
50 | 52 | };
|
51 | 53 |
|
52 | 54 | class glDirect3D3 : public IDirect3D3
|
53 | 55 | {
|
54 | 56 | public:
|
55 | | - glDirect3D3(glDirect3D7 *glDD7);
|
| 57 | + glDirect3D3(glDirect3D7 *glD3D7);
|
56 | 58 | virtual ~glDirect3D3();
|
57 | 59 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
58 | 60 | ULONG WINAPI AddRef();
|
59 | 61 | ULONG WINAPI Release();
|
60 | | - HRESULT WINAPI CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 * lplpD3DDevice, LPUNKNOWN pUnkOuter);
|
| 62 | + HRESULT WINAPI CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 *lplpD3DDevice, LPUNKNOWN pUnkOuter);
|
61 | 63 | HRESULT WINAPI CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter);
|
62 | 64 | HRESULT WINAPI CreateMaterial(LPDIRECT3DMATERIAL3* lplpDirect3DMaterial, IUnknown* pUnkOuter);
|
63 | 65 | HRESULT WINAPI CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIRECT3DVERTEXBUFFER* lplpD3DVertexBuffer, DWORD dwFlags, LPUNKNOWN pUnkOuter);
|
— | — | @@ -70,5 +72,23 @@ |
71 | 73 | glDirect3D7 *glD3D7;
|
72 | 74 | };
|
73 | 75 |
|
| 76 | +class glDirect3D2 : public IDirect3D2
|
| 77 | +{
|
| 78 | +public:
|
| 79 | + glDirect3D2(glDirect3D7 *glD3D7);
|
| 80 | + virtual ~glDirect3D2();
|
| 81 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 82 | + ULONG WINAPI AddRef();
|
| 83 | + ULONG WINAPI Release();
|
| 84 | + HRESULT WINAPI CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DDEVICE2 *lplpD3DDevice2);
|
| 85 | + HRESULT WINAPI CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter);
|
| 86 | + HRESULT WINAPI CreateMaterial(LPDIRECT3DMATERIAL2* lplpDirect3DMaterial2, IUnknown* pUnkOuter);
|
| 87 | + HRESULT WINAPI CreateViewport(LPDIRECT3DVIEWPORT2* lplpD3DViewport2, IUnknown* pUnkOuter);
|
| 88 | + HRESULT WINAPI EnumDevices(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg);
|
| 89 | + HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
|
| 90 | +private:
|
| 91 | + ULONG refcount;
|
| 92 | + glDirect3D7 *glD3D7;
|
| 93 | +};
|
74 | 94 |
|
75 | 95 | #endif //__GLDIRECT3D_H |
\ No newline at end of file |
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -217,6 +217,10 @@ |
218 | 218 | materialcount = 1;
|
219 | 219 | materials[0] = NULL;
|
220 | 220 | currentmaterial = NULL;
|
| 221 | + maxtextures = 32;
|
| 222 | + textures = (glDirectDrawSurface7**)malloc(32*sizeof(glDirectDrawSurface7*));
|
| 223 | + texturecount = 1;
|
| 224 | + textures[0] = NULL;
|
221 | 225 | maxviewports = 32;
|
222 | 226 | currentviewport = NULL;
|
223 | 227 | viewportcount = 0;
|
— | — | @@ -312,10 +316,36 @@ |
313 | 317 | }
|
314 | 318 | if(riid == IID_IDirect3DDevice3)
|
315 | 319 | {
|
316 | | - this->AddRef();
|
317 | | - *ppvObj = new glDirect3DDevice3(this);
|
318 | | - return D3D_OK;
|
| 320 | + if(glD3DDev3)
|
| 321 | + {
|
| 322 | + *ppvObj = glD3DDev3;
|
| 323 | + glD3DDev3->AddRef();
|
| 324 | + return D3D_OK;
|
| 325 | + }
|
| 326 | + else
|
| 327 | + {
|
| 328 | + this->AddRef();
|
| 329 | + *ppvObj = new glDirect3DDevice3(this);
|
| 330 | + glD3DDev3 = (glDirect3DDevice3*)*ppvObj;
|
| 331 | + return D3D_OK;
|
| 332 | + }
|
319 | 333 | }
|
| 334 | + if(riid == IID_IDirect3DDevice2)
|
| 335 | + {
|
| 336 | + if(glD3DDev2)
|
| 337 | + {
|
| 338 | + *ppvObj = glD3DDev2;
|
| 339 | + glD3DDev2->AddRef();
|
| 340 | + return D3D_OK;
|
| 341 | + }
|
| 342 | + else
|
| 343 | + {
|
| 344 | + this->AddRef();
|
| 345 | + *ppvObj = new glDirect3DDevice2(this);
|
| 346 | + glD3DDev2 = (glDirect3DDevice2*)*ppvObj;
|
| 347 | + return D3D_OK;
|
| 348 | + }
|
| 349 | + }
|
320 | 350 | ERR(E_NOINTERFACE);
|
321 | 351 | }
|
322 | 352 |
|
— | — | @@ -1319,6 +1349,19 @@ |
1320 | 1350 | return materialcount-1;
|
1321 | 1351 | }
|
1322 | 1352 |
|
| 1353 | +D3DTEXTUREHANDLE glDirect3DDevice7::AddTexture(glDirectDrawSurface7 *texture)
|
| 1354 | +{
|
| 1355 | + textures[texturecount] = texture;
|
| 1356 | + texture->AddRef();
|
| 1357 | + texturecount++;
|
| 1358 | + if(texturecount >= maxtextures)
|
| 1359 | + {
|
| 1360 | + maxtextures += 32;
|
| 1361 | + textures = (glDirectDrawSurface7**)realloc(textures,maxtextures*sizeof(glDirectDrawSurface7*));
|
| 1362 | + }
|
| 1363 | + return texturecount-1;
|
| 1364 | +}
|
| 1365 | +
|
1323 | 1366 | HRESULT glDirect3DDevice7::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
|
1324 | 1367 | {
|
1325 | 1368 | if(!this) return DDERR_INVALIDOBJECT;
|
— | — | @@ -1519,6 +1562,15 @@ |
1520 | 1563 | return DDERR_GENERIC;
|
1521 | 1564 | }
|
1522 | 1565 |
|
| 1566 | +HRESULT glDirect3DDevice7::SwapTextureHandles(LPDIRECT3DTEXTURE2 lpD3DTex1, LPDIRECT3DTEXTURE2 lpD3DTex2)
|
| 1567 | +{
|
| 1568 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1569 | + if(!lpD3DTex1) return DDERR_INVALIDPARAMS;
|
| 1570 | + if(!lpD3DTex2) return DDERR_INVALIDPARAMS;
|
| 1571 | + FIXME("glDirect3DDevice7::SwapTextureHandles: stub");
|
| 1572 | + return DDERR_GENERIC;
|
| 1573 | +}
|
| 1574 | +
|
1523 | 1575 | // IDirect3DDevice3 wrapper
|
1524 | 1576 | glDirect3DDevice3::glDirect3DDevice3(glDirect3DDevice7 *glD3DDev7)
|
1525 | 1577 | {
|
— | — | @@ -1528,6 +1580,7 @@ |
1529 | 1581 |
|
1530 | 1582 | glDirect3DDevice3::~glDirect3DDevice3()
|
1531 | 1583 | {
|
| 1584 | + glD3DDev7->glD3DDev3 = NULL;
|
1532 | 1585 | glD3DDev7->Release();
|
1533 | 1586 | }
|
1534 | 1587 |
|
— | — | @@ -1706,7 +1759,7 @@ |
1707 | 1760 | LPDIRECTDRAWSURFACE7 dds7;
|
1708 | 1761 | HRESULT err = glD3DDev7->GetRenderTarget(&dds7);
|
1709 | 1762 | if(!dds7) return err;
|
1710 | | - dds7->QueryInterface(IID_IDirectDrawSurface7,(void**)lplpRenderTarget);
|
| 1763 | + dds7->QueryInterface(IID_IDirectDrawSurface4,(void**)lplpRenderTarget);
|
1711 | 1764 | dds7->Release();
|
1712 | 1765 | return err;
|
1713 | 1766 | }
|
— | — | @@ -1818,4 +1871,300 @@ |
1819 | 1872 | {
|
1820 | 1873 | if(!this) return DDERR_INVALIDOBJECT;
|
1821 | 1874 | return glD3DDev7->Vertex(lpVertex);
|
1822 | | -} |
\ No newline at end of file |
| 1875 | +}
|
| 1876 | +
|
| 1877 | +// IDirect3DDevice2 wrapper
|
| 1878 | +glDirect3DDevice2::glDirect3DDevice2(glDirect3DDevice7 *glD3DDev7)
|
| 1879 | +{
|
| 1880 | + this->glD3DDev7 = glD3DDev7;
|
| 1881 | + refcount = 1;
|
| 1882 | +}
|
| 1883 | +
|
| 1884 | +glDirect3DDevice2::~glDirect3DDevice2()
|
| 1885 | +{
|
| 1886 | + glD3DDev7->glD3DDev2 = NULL;
|
| 1887 | + glD3DDev7->Release();
|
| 1888 | +}
|
| 1889 | +
|
| 1890 | +HRESULT WINAPI glDirect3DDevice2::QueryInterface(REFIID riid, void** ppvObj)
|
| 1891 | +{
|
| 1892 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1893 | + if(riid == IID_IUnknown)
|
| 1894 | + {
|
| 1895 | + this->AddRef();
|
| 1896 | + *ppvObj = this;
|
| 1897 | + return DD_OK;
|
| 1898 | + }
|
| 1899 | + return glD3DDev7->QueryInterface(riid,ppvObj);
|
| 1900 | +}
|
| 1901 | +
|
| 1902 | +ULONG WINAPI glDirect3DDevice2::AddRef()
|
| 1903 | +{
|
| 1904 | + if(!this) return 0;
|
| 1905 | + refcount++;
|
| 1906 | + return refcount;
|
| 1907 | +}
|
| 1908 | +
|
| 1909 | +ULONG WINAPI glDirect3DDevice2::Release()
|
| 1910 | +{
|
| 1911 | + if(!this) return 0;
|
| 1912 | + ULONG ret;
|
| 1913 | + refcount--;
|
| 1914 | + ret = refcount;
|
| 1915 | + if(refcount == 0) delete this;
|
| 1916 | + return ret;
|
| 1917 | +}
|
| 1918 | +
|
| 1919 | +HRESULT WINAPI glDirect3DDevice2::AddViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2)
|
| 1920 | +{
|
| 1921 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1922 | + if(!lpDirect3DViewport2) return DDERR_INVALIDPARAMS;
|
| 1923 | + glDirect3DViewport3 *glD3DV3;
|
| 1924 | + lpDirect3DViewport2->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
|
| 1925 | + HRESULT ret = glD3DDev7->AddViewport(glD3DV3);
|
| 1926 | + glD3DV3->Release();
|
| 1927 | + return ret;
|
| 1928 | +}
|
| 1929 | +
|
| 1930 | +DWORD d3dvttofvf(D3DVERTEXTYPE d3dvt)
|
| 1931 | +{
|
| 1932 | + switch(d3dvt)
|
| 1933 | + {
|
| 1934 | + case D3DVT_VERTEX:
|
| 1935 | + return D3DFVF_VERTEX;
|
| 1936 | + case D3DVT_LVERTEX:
|
| 1937 | + return D3DFVF_LVERTEX;
|
| 1938 | + case D3DVT_TLVERTEX:
|
| 1939 | + return D3DFVF_TLVERTEX;
|
| 1940 | + default:
|
| 1941 | + return 0;
|
| 1942 | + }
|
| 1943 | +}
|
| 1944 | +
|
| 1945 | +HRESULT WINAPI glDirect3DDevice2::Begin(D3DPRIMITIVETYPE d3dpt, D3DVERTEXTYPE d3dvt, DWORD dwFlags)
|
| 1946 | +{
|
| 1947 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1948 | + DWORD vertextype = d3dvttofvf(d3dvt);
|
| 1949 | + if(!vertextype) return DDERR_INVALIDPARAMS;
|
| 1950 | + return glD3DDev7->Begin(d3dpt,vertextype,dwFlags);
|
| 1951 | +}
|
| 1952 | +
|
| 1953 | +HRESULT WINAPI glDirect3DDevice2::BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, D3DVERTEXTYPE dvtVertexType, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags)
|
| 1954 | +{
|
| 1955 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1956 | + DWORD vertextype = d3dvttofvf(dvtVertexType);
|
| 1957 | + if(!vertextype) return DDERR_INVALIDPARAMS;
|
| 1958 | + return glD3DDev7->BeginIndexed(dptPrimitiveType,vertextype,lpvVertices,dwNumVertices,dwFlags);
|
| 1959 | +}
|
| 1960 | +
|
| 1961 | +HRESULT WINAPI glDirect3DDevice2::BeginScene()
|
| 1962 | +{
|
| 1963 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1964 | + return glD3DDev7->BeginScene();
|
| 1965 | +}
|
| 1966 | +
|
| 1967 | +HRESULT WINAPI glDirect3DDevice2::DeleteViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2)
|
| 1968 | +{
|
| 1969 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1970 | + glDirect3DViewport3 *glD3DV3;
|
| 1971 | + lpDirect3DViewport2->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
|
| 1972 | + HRESULT ret = glD3DDev7->DeleteViewport(glD3DV3);
|
| 1973 | + glD3DV3->Release();
|
| 1974 | + return ret;
|
| 1975 | +}
|
| 1976 | +
|
| 1977 | +HRESULT WINAPI glDirect3DDevice2::DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, D3DVERTEXTYPE d3dvtVertexType,
|
| 1978 | + LPVOID lpvVertices, DWORD dwVertexCount, LPWORD dwIndices, DWORD dwIndexCount, DWORD dwFlags)
|
| 1979 | +{
|
| 1980 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1981 | + DWORD vertextype = d3dvttofvf(d3dvtVertexType);
|
| 1982 | + if(!vertextype) return DDERR_INVALIDPARAMS;
|
| 1983 | + return glD3DDev7->DrawIndexedPrimitive(d3dptPrimitiveType,vertextype,lpvVertices,dwVertexCount,dwIndices,dwIndexCount,dwFlags);
|
| 1984 | +}
|
| 1985 | +
|
| 1986 | +HRESULT WINAPI glDirect3DDevice2::DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, D3DVERTEXTYPE dvtVertexType, LPVOID lpvVertices,
|
| 1987 | + DWORD dwVertexCount, DWORD dwFlags)
|
| 1988 | +{
|
| 1989 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1990 | + DWORD vertextype = d3dvttofvf(dvtVertexType);
|
| 1991 | + if(!vertextype) return DDERR_INVALIDPARAMS;
|
| 1992 | + return glD3DDev7->DrawPrimitive(dptPrimitiveType,vertextype,lpvVertices,dwVertexCount,dwFlags);
|
| 1993 | +}
|
| 1994 | +
|
| 1995 | +HRESULT WINAPI glDirect3DDevice2::End(DWORD dwFlags)
|
| 1996 | +{
|
| 1997 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1998 | + return glD3DDev7->End(dwFlags);
|
| 1999 | +}
|
| 2000 | +
|
| 2001 | +HRESULT WINAPI glDirect3DDevice2::EndScene()
|
| 2002 | +{
|
| 2003 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2004 | + return glD3DDev7->EndScene();
|
| 2005 | +}
|
| 2006 | +
|
| 2007 | +HRESULT WINAPI EnumTex2(LPDDPIXELFORMAT ddpf, LPVOID lpUserArg)
|
| 2008 | +{
|
| 2009 | + int *args = (int*)lpUserArg;
|
| 2010 | + LPD3DENUMTEXTUREFORMATSCALLBACK callback = (LPD3DENUMTEXTUREFORMATSCALLBACK)args[0];
|
| 2011 | + DDSURFACEDESC ddsd;
|
| 2012 | + ZeroMemory(&ddsd,sizeof(DDSURFACEDESC));
|
| 2013 | + ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| 2014 | + ddsd.dwFlags = DDSD_CAPS|DDSD_PIXELFORMAT;
|
| 2015 | + ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
| 2016 | + ddsd.ddpfPixelFormat = *ddpf;
|
| 2017 | + HRESULT ret = callback(&ddsd,(LPVOID)args[1]);
|
| 2018 | + return ret;
|
| 2019 | +}
|
| 2020 | +
|
| 2021 | +HRESULT WINAPI glDirect3DDevice2::EnumTextureFormats(LPD3DENUMTEXTUREFORMATSCALLBACK lpd3dEnumTextureProc, LPVOID lpArg)
|
| 2022 | +{
|
| 2023 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2024 | + LPVOID context[2];
|
| 2025 | + context[0] = (LPVOID)lpd3dEnumTextureProc;
|
| 2026 | + context[1] = lpArg;
|
| 2027 | + return glD3DDev7->EnumTextureFormats(EnumTex2,&context);
|
| 2028 | +}
|
| 2029 | +
|
| 2030 | +HRESULT WINAPI glDirect3DDevice2::GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc)
|
| 2031 | +{
|
| 2032 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2033 | + return glD3DDev7->GetCaps3(lpD3DHWDevDesc,lpD3DHELDevDesc);
|
| 2034 | +}
|
| 2035 | +
|
| 2036 | +HRESULT WINAPI glDirect3DDevice2::GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
|
| 2037 | +{
|
| 2038 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2039 | + return glD3DDev7->GetClipStatus(lpD3DClipStatus);
|
| 2040 | +}
|
| 2041 | +
|
| 2042 | +HRESULT WINAPI glDirect3DDevice2::GetCurrentViewport(LPDIRECT3DVIEWPORT2 *lplpd3dViewport2)
|
| 2043 | +{
|
| 2044 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2045 | + glDirect3DViewport3 *glD3DV3;
|
| 2046 | + HRESULT ret = glD3DDev7->GetCurrentViewport((LPDIRECT3DVIEWPORT3*)&glD3DV3);
|
| 2047 | + if(!glD3DV3) return ret;
|
| 2048 | + glD3DV3->QueryInterface(IID_IDirect3DViewport2,(void**)lplpd3dViewport2);
|
| 2049 | + glD3DV3->Release();
|
| 2050 | + return ret;
|
| 2051 | +}
|
| 2052 | +
|
| 2053 | +HRESULT WINAPI glDirect3DDevice2::GetDirect3D(LPDIRECT3D2 *lplpD3D2)
|
| 2054 | +{
|
| 2055 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2056 | + LPDIRECT3D7 d3d7;
|
| 2057 | + HRESULT err = glD3DDev7->GetDirect3D(&d3d7);
|
| 2058 | + if(!d3d7) return err;
|
| 2059 | + d3d7->QueryInterface(IID_IDirect3D2,(void**)lplpD3D2);
|
| 2060 | + d3d7->Release();
|
| 2061 | + return err;
|
| 2062 | +}
|
| 2063 | +
|
| 2064 | +HRESULT WINAPI glDirect3DDevice2::GetLightState(D3DLIGHTSTATETYPE dwLightStateType, LPDWORD lpdwLightState)
|
| 2065 | +{
|
| 2066 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2067 | + return glD3DDev7->GetLightState(dwLightStateType,lpdwLightState);
|
| 2068 | +}
|
| 2069 | +
|
| 2070 | +HRESULT WINAPI glDirect3DDevice2::GetRenderState(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState)
|
| 2071 | +{
|
| 2072 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2073 | + return glD3DDev7->GetRenderState(dwRenderStateType,lpdwRenderState);
|
| 2074 | +}
|
| 2075 | +
|
| 2076 | +HRESULT WINAPI glDirect3DDevice2::GetRenderTarget(LPDIRECTDRAWSURFACE *lplpRenderTarget)
|
| 2077 | +{
|
| 2078 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2079 | + LPDIRECTDRAWSURFACE7 dds7;
|
| 2080 | + HRESULT err = glD3DDev7->GetRenderTarget(&dds7);
|
| 2081 | + if(!dds7) return err;
|
| 2082 | + dds7->QueryInterface(IID_IDirectDrawSurface,(void**)lplpRenderTarget);
|
| 2083 | + dds7->Release();
|
| 2084 | + return err;
|
| 2085 | +}
|
| 2086 | +
|
| 2087 | +HRESULT WINAPI glDirect3DDevice2::GetStats(LPD3DSTATS lpD3DStats)
|
| 2088 | +{
|
| 2089 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2090 | + return glD3DDev7->GetStats(lpD3DStats);
|
| 2091 | +}
|
| 2092 | +
|
| 2093 | +HRESULT WINAPI glDirect3DDevice2::GetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
| 2094 | +{
|
| 2095 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2096 | + return glD3DDev7->GetTransform(dtstTransformStateType,lpD3DMatrix);
|
| 2097 | +}
|
| 2098 | +
|
| 2099 | +HRESULT WINAPI glDirect3DDevice2::Index(WORD wVertexIndex)
|
| 2100 | +{
|
| 2101 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2102 | + return glD3DDev7->Index(wVertexIndex);
|
| 2103 | +}
|
| 2104 | +
|
| 2105 | +HRESULT WINAPI glDirect3DDevice2::MultiplyTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
| 2106 | +{
|
| 2107 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2108 | + return glD3DDev7->MultiplyTransform(dtstTransformStateType,lpD3DMatrix);
|
| 2109 | +}
|
| 2110 | +
|
| 2111 | +HRESULT WINAPI glDirect3DDevice2::NextViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2, LPDIRECT3DVIEWPORT2 *lplpDirect3DViewport2, DWORD dwFlags)
|
| 2112 | +{
|
| 2113 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2114 | + if(!lpDirect3DViewport2) return DDERR_INVALIDPARAMS;
|
| 2115 | + if(!lplpDirect3DViewport2) return DDERR_INVALIDPARAMS;
|
| 2116 | + FIXME("glDirect3DDevice2::NextViewport: stub");
|
| 2117 | + ERR(DDERR_GENERIC);
|
| 2118 | +}
|
| 2119 | +
|
| 2120 | +HRESULT WINAPI glDirect3DDevice2::SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
|
| 2121 | +{
|
| 2122 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2123 | + return glD3DDev7->SetClipStatus(lpD3DClipStatus);
|
| 2124 | +}
|
| 2125 | +
|
| 2126 | +HRESULT WINAPI glDirect3DDevice2::SetCurrentViewport(LPDIRECT3DVIEWPORT2 lpd3dViewport2)
|
| 2127 | +{
|
| 2128 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2129 | + if(!lpd3dViewport2) return glD3DDev7->SetCurrentViewport(NULL);
|
| 2130 | + glDirect3DViewport3 *glD3DV3;
|
| 2131 | + lpd3dViewport2->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
|
| 2132 | + HRESULT ret = glD3DDev7->SetCurrentViewport(glD3DV3);
|
| 2133 | + glD3DV3->Release();
|
| 2134 | + return ret;
|
| 2135 | +}
|
| 2136 | +
|
| 2137 | +HRESULT WINAPI glDirect3DDevice2::SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState)
|
| 2138 | +{
|
| 2139 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2140 | + return glD3DDev7->SetLightState(dwLightStateType,dwLightState);
|
| 2141 | +}
|
| 2142 | +
|
| 2143 | +HRESULT WINAPI glDirect3DDevice2::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState)
|
| 2144 | +{
|
| 2145 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2146 | + return glD3DDev7->SetRenderState(dwRenderStateType,dwRenderState);
|
| 2147 | +}
|
| 2148 | +
|
| 2149 | +HRESULT WINAPI glDirect3DDevice2::SetRenderTarget(LPDIRECTDRAWSURFACE lpNewRenderTarget, DWORD dwFlags)
|
| 2150 | +{
|
| 2151 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2152 | + return glD3DDev7->SetRenderTarget(((glDirectDrawSurface1*)lpNewRenderTarget)->GetDDS7(),dwFlags);
|
| 2153 | +}
|
| 2154 | +
|
| 2155 | +HRESULT WINAPI glDirect3DDevice2::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
| 2156 | +{
|
| 2157 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2158 | + return glD3DDev7->SetTransform(dtstTransformStateType,lpD3DMatrix);
|
| 2159 | +}
|
| 2160 | +
|
| 2161 | +HRESULT WINAPI glDirect3DDevice2::SwapTextureHandles(LPDIRECT3DTEXTURE2 lpD3DTex1, LPDIRECT3DTEXTURE2 lpD3DTex2)
|
| 2162 | +{
|
| 2163 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2164 | + return glD3DDev7->SwapTextureHandles(lpD3DTex1,lpD3DTex2);
|
| 2165 | +}
|
| 2166 | +
|
| 2167 | +HRESULT WINAPI glDirect3DDevice2::Vertex(LPVOID lpVertexType)
|
| 2168 | +{
|
| 2169 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 2170 | + return glD3DDev7->Vertex(lpVertexType);
|
| 2171 | +}
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -58,6 +58,8 @@ |
59 | 59 | class glDirectDrawSurface7;
|
60 | 60 | class glDirect3DMaterial3;
|
61 | 61 | class glDirect3DViewport3;
|
| 62 | +class glDirect3DDevice3;
|
| 63 | +class glDirect3DDevice2;
|
62 | 64 | class glDirect3DDevice7 : public IDirect3DDevice7
|
63 | 65 | {
|
64 | 66 | public:
|
— | — | @@ -125,6 +127,7 @@ |
126 | 128 | void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
|
127 | 129 | void SetDepthComp();
|
128 | 130 | D3DMATERIALHANDLE AddMaterial(glDirect3DMaterial3* material);
|
| 131 | + D3DTEXTUREHANDLE AddTexture(glDirectDrawSurface7* texture);
|
129 | 132 | HRESULT AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
130 | 133 | HRESULT DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
131 | 134 | HRESULT NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport, LPDIRECT3DVIEWPORT3 *lplpAnotherViewport, DWORD dwFlags);
|
— | — | @@ -140,6 +143,7 @@ |
141 | 144 | HRESULT GetLightState(D3DLIGHTSTATETYPE dwLightStateType, LPDWORD lpdwLightState);
|
142 | 145 | HRESULT SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState);
|
143 | 146 | HRESULT GetStats(LPD3DSTATS lpD3DStats);
|
| 147 | + HRESULT SwapTextureHandles(LPDIRECT3DTEXTURE2 lpD3DTex1, LPDIRECT3DTEXTURE2 lpD3DTex2);
|
144 | 148 | __int64 SelectShader(GLVERTEX *VertexType);
|
145 | 149 | GLfloat matWorld[16];
|
146 | 150 | GLfloat matView[16];
|
— | — | @@ -155,8 +159,12 @@ |
156 | 160 | glDirect3DMaterial3 **materials;
|
157 | 161 | glDirect3DMaterial3 *currentmaterial;
|
158 | 162 | int materialcount;
|
| 163 | + glDirectDrawSurface7 **textures;
|
| 164 | + int texturecount;
|
159 | 165 | bool modelview_dirty;
|
160 | 166 | bool projection_dirty;
|
| 167 | + glDirect3DDevice3 *glD3DDev3;
|
| 168 | + glDirect3DDevice2 *glD3DDev2;
|
161 | 169 | private:
|
162 | 170 | HRESULT fvftoglvertex(DWORD dwVertexTypeDesc,LPDWORD vertptr);
|
163 | 171 | ULONG refcount;
|
— | — | @@ -175,6 +183,7 @@ |
176 | 184 | GLVERTEX vertdata[18];
|
177 | 185 | int texformats[8];
|
178 | 186 | int maxmaterials;
|
| 187 | + int maxtextures;
|
179 | 188 | glDirect3DViewport3 **viewports;
|
180 | 189 | glDirect3DViewport3 *currentviewport;
|
181 | 190 | int viewportcount;
|
— | — | @@ -240,4 +249,50 @@ |
241 | 250 | private:
|
242 | 251 | glDirect3DDevice7 *glD3DDev7;
|
243 | 252 | ULONG refcount;
|
| 253 | +};
|
| 254 | +
|
| 255 | +
|
| 256 | +class glDirect3DDevice2 : public IDirect3DDevice2
|
| 257 | +{
|
| 258 | +public:
|
| 259 | + glDirect3DDevice2(glDirect3DDevice7 *glD3DDev7);
|
| 260 | + virtual ~glDirect3DDevice2();
|
| 261 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 262 | + ULONG WINAPI AddRef();
|
| 263 | + ULONG WINAPI Release();
|
| 264 | + HRESULT WINAPI AddViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2);
|
| 265 | + HRESULT WINAPI Begin(D3DPRIMITIVETYPE d3dpt, D3DVERTEXTYPE d3dvt, DWORD dwFlags);
|
| 266 | + HRESULT WINAPI BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, D3DVERTEXTYPE dvtVertexType, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
|
| 267 | + HRESULT WINAPI BeginScene();
|
| 268 | + HRESULT WINAPI DeleteViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2);
|
| 269 | + HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, D3DVERTEXTYPE d3dvtVertexType,
|
| 270 | + LPVOID lpvVertices, DWORD dwVertexCount, LPWORD dwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 271 | + HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, D3DVERTEXTYPE dvtVertexType, LPVOID lpvVertices,
|
| 272 | + DWORD dwVertexCount, DWORD dwFlags);
|
| 273 | + HRESULT WINAPI End(DWORD dwFlags);
|
| 274 | + HRESULT WINAPI EndScene();
|
| 275 | + HRESULT WINAPI EnumTextureFormats(LPD3DENUMTEXTUREFORMATSCALLBACK lpd3dEnumTextureProc, LPVOID lpArg);
|
| 276 | + HRESULT WINAPI GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
|
| 277 | + HRESULT WINAPI GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
| 278 | + HRESULT WINAPI GetCurrentViewport(LPDIRECT3DVIEWPORT2 *lplpd3dViewport2);
|
| 279 | + HRESULT WINAPI GetDirect3D(LPDIRECT3D2 *lplpD3D2);
|
| 280 | + HRESULT WINAPI GetLightState(D3DLIGHTSTATETYPE dwLightStateType, LPDWORD lpdwLightState);
|
| 281 | + HRESULT WINAPI GetRenderState(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState);
|
| 282 | + HRESULT WINAPI GetRenderTarget(LPDIRECTDRAWSURFACE *lplpRenderTarget);
|
| 283 | + HRESULT WINAPI GetStats(LPD3DSTATS lpD3DStats);
|
| 284 | + HRESULT WINAPI GetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 285 | + HRESULT WINAPI Index(WORD wVertexIndex);
|
| 286 | + HRESULT WINAPI MultiplyTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 287 | + HRESULT WINAPI NextViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2, LPDIRECT3DVIEWPORT2 *lplpDirect3DViewport2, DWORD dwFlags);
|
| 288 | + HRESULT WINAPI SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
| 289 | + HRESULT WINAPI SetCurrentViewport(LPDIRECT3DVIEWPORT2 lpd3dViewport2);
|
| 290 | + HRESULT WINAPI SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState);
|
| 291 | + HRESULT WINAPI SetRenderState(D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState);
|
| 292 | + HRESULT WINAPI SetRenderTarget(LPDIRECTDRAWSURFACE lpNewRenderTarget, DWORD dwFlags);
|
| 293 | + HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 294 | + HRESULT WINAPI SwapTextureHandles(LPDIRECT3DTEXTURE2 lpD3DTex1, LPDIRECT3DTEXTURE2 lpD3DTex2);
|
| 295 | + HRESULT WINAPI Vertex(LPVOID lpVertexType);
|
| 296 | +private:
|
| 297 | + glDirect3DDevice7 *glD3DDev7;
|
| 298 | + ULONG refcount;
|
244 | 299 | }; |
\ No newline at end of file |
Index: ddraw/glDirect3DMaterial.cpp |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | material.hTexture = 0;
|
36 | 36 | material.dwRampSize = 0;
|
37 | 37 | handle = 0;
|
| 38 | + glD3DM2 = NULL;
|
38 | 39 | }
|
39 | 40 |
|
40 | 41 | glDirect3DMaterial3::~glDirect3DMaterial3()
|
— | — | @@ -43,7 +44,7 @@ |
44 | 45 |
|
45 | 46 | HRESULT WINAPI glDirect3DMaterial3::QueryInterface(REFIID riid, void** ppvObj)
|
46 | 47 | {
|
47 | | - if(!this) return DDERR_INVALIDPARAMS;
|
| 48 | + if(!this) return DDERR_INVALIDOBJECT;
|
48 | 49 | if(riid == IID_IUnknown)
|
49 | 50 | {
|
50 | 51 | this->AddRef();
|
— | — | @@ -50,6 +51,28 @@ |
51 | 52 | *ppvObj = this;
|
52 | 53 | return DD_OK;
|
53 | 54 | }
|
| 55 | + if(riid == IID_IDirect3DMaterial3)
|
| 56 | + {
|
| 57 | + this->AddRef();
|
| 58 | + *ppvObj = this;
|
| 59 | + return DD_OK;
|
| 60 | + }
|
| 61 | + if(riid == IID_IDirect3DMaterial2)
|
| 62 | + {
|
| 63 | + if(glD3DM2)
|
| 64 | + {
|
| 65 | + *ppvObj = glD3DM2;
|
| 66 | + glD3DM2->AddRef();
|
| 67 | + return D3D_OK;
|
| 68 | + }
|
| 69 | + else
|
| 70 | + {
|
| 71 | + this->AddRef();
|
| 72 | + *ppvObj = new glDirect3DMaterial2(this);
|
| 73 | + glD3DM2 = (glDirect3DMaterial2*)*ppvObj;
|
| 74 | + return D3D_OK;
|
| 75 | + }
|
| 76 | + }
|
54 | 77 | return E_NOINTERFACE;
|
55 | 78 | }
|
56 | 79 |
|
— | — | @@ -73,7 +96,7 @@ |
74 | 97 | HRESULT WINAPI glDirect3DMaterial3::GetHandle(LPDIRECT3DDEVICE3 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle)
|
75 | 98 | {
|
76 | 99 | if(!this) return DDERR_INVALIDOBJECT;
|
77 | | - if(!lpDirect3DDevice) return DDERR_INVALIDOBJECT;
|
| 100 | + if(!lpDirect3DDevice) return DDERR_INVALIDPARAMS;
|
78 | 101 | glDirect3DDevice3 *dev3 = (glDirect3DDevice3*)lpDirect3DDevice;
|
79 | 102 | if(handle)
|
80 | 103 | {
|
— | — | @@ -127,4 +150,68 @@ |
128 | 151 | mat7.emissive = material.emissive;
|
129 | 152 | mat7.power = material.power;
|
130 | 153 | device->SetMaterial(&mat7);
|
131 | | -} |
\ No newline at end of file |
| 154 | +}
|
| 155 | +
|
| 156 | +glDirect3DMaterial2::glDirect3DMaterial2(glDirect3DMaterial3 *glD3DM3)
|
| 157 | +{
|
| 158 | + refcount = 1;
|
| 159 | + this->glD3DM3 = glD3DM3;
|
| 160 | +}
|
| 161 | +
|
| 162 | +glDirect3DMaterial2::~glDirect3DMaterial2()
|
| 163 | +{
|
| 164 | + glD3DM3->glD3DM2 = NULL;
|
| 165 | + glD3DM3->Release();
|
| 166 | +}
|
| 167 | +
|
| 168 | +ULONG WINAPI glDirect3DMaterial2::AddRef()
|
| 169 | +{
|
| 170 | + if(!this) return 0;
|
| 171 | + refcount++;
|
| 172 | + return refcount;
|
| 173 | +}
|
| 174 | +
|
| 175 | +ULONG WINAPI glDirect3DMaterial2::Release()
|
| 176 | +{
|
| 177 | + if(!this) return 0;
|
| 178 | + ULONG ret;
|
| 179 | + refcount--;
|
| 180 | + ret = refcount;
|
| 181 | + if(refcount == 0) delete this;
|
| 182 | + return ret;
|
| 183 | +}
|
| 184 | +
|
| 185 | +HRESULT WINAPI glDirect3DMaterial2::QueryInterface(REFIID riid, void** ppvObj)
|
| 186 | +{
|
| 187 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 188 | + if(riid == IID_IUnknown)
|
| 189 | + {
|
| 190 | + this->AddRef();
|
| 191 | + *ppvObj = this;
|
| 192 | + return D3D_OK;
|
| 193 | + }
|
| 194 | + return glD3DM3->QueryInterface(riid,ppvObj);
|
| 195 | +}
|
| 196 | +
|
| 197 | +HRESULT WINAPI glDirect3DMaterial2::GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle)
|
| 198 | +{
|
| 199 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 200 | + if(!lpDirect3DDevice) return DDERR_INVALIDPARAMS;
|
| 201 | + glDirect3DDevice2 *glD3DDev2 = (glDirect3DDevice2*)lpDirect3DDevice;
|
| 202 | + glDirect3DDevice3 *glD3DDev3;
|
| 203 | + glD3DDev2->QueryInterface(IID_IDirect3DDevice3,(void**)&glD3DDev3);
|
| 204 | + HRESULT ret = glD3DM3->GetHandle(glD3DDev3,lpHandle);
|
| 205 | + glD3DDev3->Release();
|
| 206 | + return ret;
|
| 207 | +}
|
| 208 | +
|
| 209 | +HRESULT WINAPI glDirect3DMaterial2::GetMaterial(LPD3DMATERIAL lpMat)
|
| 210 | +{
|
| 211 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 212 | + return glD3DM3->GetMaterial(lpMat);
|
| 213 | +}
|
| 214 | +HRESULT WINAPI glDirect3DMaterial2::SetMaterial(LPD3DMATERIAL lpMat)
|
| 215 | +{
|
| 216 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 217 | + return glD3DM3->SetMaterial(lpMat);
|
| 218 | +}
|
Index: ddraw/glDirect3DMaterial.h |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | #ifndef __GLDIRECT3DMATERIAL_H
|
21 | 21 | #define __GLDIRECT3DMATERIAL_H
|
22 | 22 |
|
| 23 | +class glDirect3DMaterial2;
|
23 | 24 | class glDirect3DMaterial3 : public IDirect3DMaterial3
|
24 | 25 | {
|
25 | 26 | public:
|
— | — | @@ -35,6 +36,7 @@ |
36 | 37 | void unbind();
|
37 | 38 | D3DMATERIAL material;
|
38 | 39 | D3DMATERIALHANDLE handle;
|
| 40 | + glDirect3DMaterial2 *glD3DM2;
|
39 | 41 | private:
|
40 | 42 | ULONG refcount;
|
41 | 43 | bool current;
|
— | — | @@ -41,4 +43,20 @@ |
42 | 44 | glDirect3DDevice7 *device;
|
43 | 45 | };
|
44 | 46 |
|
| 47 | +class glDirect3DMaterial2 : public IDirect3DMaterial2
|
| 48 | +{
|
| 49 | +public:
|
| 50 | + glDirect3DMaterial2(glDirect3DMaterial3 *glD3DM3);
|
| 51 | + virtual ~glDirect3DMaterial2();
|
| 52 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 53 | + ULONG WINAPI AddRef();
|
| 54 | + ULONG WINAPI Release();
|
| 55 | + HRESULT WINAPI GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle);
|
| 56 | + HRESULT WINAPI GetMaterial(LPD3DMATERIAL lpMat);
|
| 57 | + HRESULT WINAPI SetMaterial(LPD3DMATERIAL lpMat);
|
| 58 | +private:
|
| 59 | + ULONG refcount;
|
| 60 | + glDirect3DMaterial3 *glD3DM3;
|
| 61 | +};
|
| 62 | +
|
45 | 63 | #endif //__GLDIRECT3DMATERIAL_H |
\ No newline at end of file |
Index: ddraw/glDirect3DTexture.cpp |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | #include "glDirectDraw.h"
|
23 | 23 | #include "glDirectDrawSurface.h"
|
24 | 24 | #include "glDirect3DTexture.h"
|
| 25 | +#include "glDirect3DDevice.h"
|
25 | 26 |
|
26 | 27 | glDirect3DTexture2::glDirect3DTexture2(glDirectDrawSurface7 *glDDS7)
|
27 | 28 | {
|
— | — | @@ -65,6 +66,12 @@ |
66 | 67 | HRESULT WINAPI glDirect3DTexture2::GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice2, LPD3DTEXTUREHANDLE lpHandle)
|
67 | 68 | {
|
68 | 69 | if(!this) return DDERR_INVALIDOBJECT;
|
| 70 | + if(!lpDirect3DDevice2) return DDERR_INVALIDPARAMS;
|
| 71 | + glDirect3DDevice7 *glD3DDev7;
|
| 72 | + lpDirect3DDevice2->QueryInterface(IID_IDirect3DDevice7,(void**)&glD3DDev7);
|
| 73 | + HRESULT ret = glDDS7->GetHandle(glD3DDev7,lpHandle);
|
| 74 | + glD3DDev7->Release();
|
| 75 | + return ret;
|
69 | 76 | FIXME("glDirect3DTexture2::GetHandle: stub");
|
70 | 77 | return DDERR_GENERIC;
|
71 | 78 | }
|
Index: ddraw/glDirect3DViewport.cpp |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | lights[i] = NULL;
|
48 | 48 | refcount = 1;
|
49 | 49 | current = false;
|
| 50 | + glD3DV2 = NULL;
|
50 | 51 | }
|
51 | 52 |
|
52 | 53 | glDirect3DViewport3::~glDirect3DViewport3()
|
— | — | @@ -54,13 +55,35 @@ |
55 | 56 |
|
56 | 57 | HRESULT WINAPI glDirect3DViewport3::QueryInterface(REFIID riid, void** ppvObj)
|
57 | 58 | {
|
58 | | - if(!this) return DDERR_INVALIDPARAMS;
|
| 59 | + if(!this) return DDERR_INVALIDOBJECT;
|
59 | 60 | if(riid == IID_IUnknown)
|
60 | 61 | {
|
61 | 62 | this->AddRef();
|
62 | 63 | *ppvObj = this;
|
63 | | - return DD_OK;
|
| 64 | + return D3D_OK;
|
64 | 65 | }
|
| 66 | + if(riid == IID_IDirect3DViewport3)
|
| 67 | + {
|
| 68 | + this->AddRef();
|
| 69 | + *ppvObj = this;
|
| 70 | + return D3D_OK;
|
| 71 | + }
|
| 72 | + if(riid == IID_IDirect3DViewport2)
|
| 73 | + {
|
| 74 | + if(glD3DV2)
|
| 75 | + {
|
| 76 | + *ppvObj = glD3DV2;
|
| 77 | + glD3DV2->AddRef();
|
| 78 | + return D3D_OK;
|
| 79 | + }
|
| 80 | + else
|
| 81 | + {
|
| 82 | + this->AddRef();
|
| 83 | + *ppvObj = new glDirect3DViewport2(this);
|
| 84 | + glD3DV2 = (glDirect3DViewport2*)*ppvObj;
|
| 85 | + return D3D_OK;
|
| 86 | + }
|
| 87 | + }
|
65 | 88 | return E_NOINTERFACE;
|
66 | 89 | }
|
67 | 90 |
|
— | — | @@ -304,4 +327,122 @@ |
305 | 328 | }
|
306 | 329 | else device->LightEnable(i,FALSE);
|
307 | 330 | }
|
308 | | -} |
\ No newline at end of file |
| 331 | +}
|
| 332 | +
|
| 333 | +
|
| 334 | +glDirect3DViewport2::glDirect3DViewport2(glDirect3DViewport3 *glD3DV3)
|
| 335 | +{
|
| 336 | + this->glD3DV3 = glD3DV3;
|
| 337 | + refcount = 1;
|
| 338 | +}
|
| 339 | +
|
| 340 | +glDirect3DViewport2::~glDirect3DViewport2()
|
| 341 | +{
|
| 342 | + glD3DV3->glD3DV2 = NULL;
|
| 343 | + glD3DV3->Release();
|
| 344 | +}
|
| 345 | +
|
| 346 | +ULONG WINAPI glDirect3DViewport2::AddRef()
|
| 347 | +{
|
| 348 | + if(!this) return 0;
|
| 349 | + refcount++;
|
| 350 | + return refcount;
|
| 351 | +}
|
| 352 | +
|
| 353 | +ULONG WINAPI glDirect3DViewport2::Release()
|
| 354 | +{
|
| 355 | + if(!this) return 0;
|
| 356 | + ULONG ret;
|
| 357 | + refcount--;
|
| 358 | + ret = refcount;
|
| 359 | + if(refcount == 0) delete this;
|
| 360 | + return ret;
|
| 361 | +}
|
| 362 | +
|
| 363 | +HRESULT WINAPI glDirect3DViewport2::QueryInterface(REFIID riid, void** ppvObj)
|
| 364 | +{
|
| 365 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 366 | + if(riid == IID_IUnknown)
|
| 367 | + {
|
| 368 | + this->AddRef();
|
| 369 | + *ppvObj = this;
|
| 370 | + return D3D_OK;
|
| 371 | + }
|
| 372 | + return glD3DV3->QueryInterface(riid,ppvObj);
|
| 373 | +}
|
| 374 | +
|
| 375 | +HRESULT WINAPI glDirect3DViewport2::AddLight(LPDIRECT3DLIGHT lpLight)
|
| 376 | +{
|
| 377 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 378 | + return glD3DV3->AddLight(lpLight);
|
| 379 | +}
|
| 380 | +HRESULT WINAPI glDirect3DViewport2::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
|
| 381 | +{
|
| 382 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 383 | + return glD3DV3->Clear(dwCount,lpRects,dwFlags);
|
| 384 | +}
|
| 385 | +HRESULT WINAPI glDirect3DViewport2::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
|
| 386 | +{
|
| 387 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 388 | + return glD3DV3->DeleteLight(lpDirect3DLight);
|
| 389 | +}
|
| 390 | +HRESULT WINAPI glDirect3DViewport2::GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
|
| 391 | +{
|
| 392 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 393 | + return glD3DV3->GetBackground(lphMat,lpValid);
|
| 394 | +}
|
| 395 | +HRESULT WINAPI glDirect3DViewport2::GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
|
| 396 | +{
|
| 397 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 398 | + return glD3DV3->GetBackgroundDepth(lplpDDSurface,lpValid);
|
| 399 | +}
|
| 400 | +HRESULT WINAPI glDirect3DViewport2::GetViewport(LPD3DVIEWPORT lpData)
|
| 401 | +{
|
| 402 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 403 | + return glD3DV3->GetViewport(lpData);
|
| 404 | +}
|
| 405 | +HRESULT WINAPI glDirect3DViewport2::GetViewport2(LPD3DVIEWPORT2 lpData)
|
| 406 | +{
|
| 407 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 408 | + return glD3DV3->GetViewport2(lpData);
|
| 409 | +}
|
| 410 | +HRESULT WINAPI glDirect3DViewport2::Initialize(LPDIRECT3D lpDirect3D)
|
| 411 | +{
|
| 412 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 413 | + return glD3DV3->Initialize(lpDirect3D);
|
| 414 | +}
|
| 415 | +HRESULT WINAPI glDirect3DViewport2::LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData)
|
| 416 | +{
|
| 417 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 418 | + return glD3DV3->LightElements(dwElementCount,lpData);
|
| 419 | +}
|
| 420 | +HRESULT WINAPI glDirect3DViewport2::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
|
| 421 | +{
|
| 422 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 423 | + return glD3DV3->NextLight(lpDirect3DLight,lplpDirect3DLight,dwFlags);
|
| 424 | +}
|
| 425 | +HRESULT WINAPI glDirect3DViewport2::SetBackground(D3DMATERIALHANDLE hMat)
|
| 426 | +{
|
| 427 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 428 | + return glD3DV3->SetBackground(hMat);
|
| 429 | +}
|
| 430 | +HRESULT WINAPI glDirect3DViewport2::SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface)
|
| 431 | +{
|
| 432 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 433 | + return glD3DV3->SetBackgroundDepth(lpDDSurface);
|
| 434 | +}
|
| 435 | +HRESULT WINAPI glDirect3DViewport2::SetViewport(LPD3DVIEWPORT lpData)
|
| 436 | +{
|
| 437 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 438 | + return glD3DV3->SetViewport(lpData);
|
| 439 | +}
|
| 440 | +HRESULT WINAPI glDirect3DViewport2::SetViewport2(LPD3DVIEWPORT2 lpData)
|
| 441 | +{
|
| 442 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 443 | + return glD3DV3->SetViewport2(lpData);
|
| 444 | +}
|
| 445 | +HRESULT WINAPI glDirect3DViewport2::TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
|
| 446 | +{
|
| 447 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 448 | + return glD3DV3->TransformVertices(dwVertexCount,lpData,dwFlags,lpOffscreen);
|
| 449 | +}
|
Index: ddraw/glDirect3DViewport.h |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | class glDirect3DLight;
|
24 | 24 | class glDirect3DDevice7;
|
25 | 25 | class glDirectDrawSurface7;
|
| 26 | +class glDirect3DViewport2;
|
26 | 27 | class glDirect3DViewport3 : public IDirect3DViewport3
|
27 | 28 | {
|
28 | 29 | public:
|
— | — | @@ -52,6 +53,7 @@ |
53 | 54 | void SetDevice(glDirect3DDevice7 *device){this->device = device;};
|
54 | 55 | void Sync();
|
55 | 56 | void SyncLights();
|
| 57 | + glDirect3DViewport2 *glD3DV2;
|
56 | 58 | private:
|
57 | 59 | ULONG refcount;
|
58 | 60 | glDirect3DLight *lights[8];
|
— | — | @@ -66,4 +68,32 @@ |
67 | 69 | bool current;
|
68 | 70 | };
|
69 | 71 |
|
| 72 | +class glDirect3DViewport2 : public IDirect3DViewport2
|
| 73 | +{
|
| 74 | +public:
|
| 75 | + glDirect3DViewport2(glDirect3DViewport3 *glD3DV3);
|
| 76 | + virtual ~glDirect3DViewport2();
|
| 77 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 78 | + ULONG WINAPI AddRef();
|
| 79 | + ULONG WINAPI Release();
|
| 80 | + HRESULT WINAPI AddLight(LPDIRECT3DLIGHT lpLight);
|
| 81 | + HRESULT WINAPI Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
|
| 82 | + HRESULT WINAPI DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight);
|
| 83 | + HRESULT WINAPI GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
|
| 84 | + HRESULT WINAPI GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
|
| 85 | + HRESULT WINAPI GetViewport(LPD3DVIEWPORT lpData);
|
| 86 | + HRESULT WINAPI GetViewport2(LPD3DVIEWPORT2 lpData);
|
| 87 | + HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
|
| 88 | + HRESULT WINAPI LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData);
|
| 89 | + HRESULT WINAPI NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
|
| 90 | + HRESULT WINAPI SetBackground(D3DMATERIALHANDLE hMat);
|
| 91 | + HRESULT WINAPI SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface);
|
| 92 | + HRESULT WINAPI SetViewport(LPD3DVIEWPORT lpData);
|
| 93 | + HRESULT WINAPI SetViewport2(LPD3DVIEWPORT2 lpData);
|
| 94 | + HRESULT WINAPI TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
|
| 95 | +private:
|
| 96 | + glDirect3DViewport3 *glD3DV3;
|
| 97 | + int refcount;
|
| 98 | +};
|
| 99 | +
|
70 | 100 | #endif //__GLDIRECT3DVIEWPORT_H |
\ No newline at end of file |
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -644,8 +644,10 @@ |
645 | 645 | }
|
646 | 646 | if(riid == IID_IDirect3D2)
|
647 | 647 | {
|
648 | | - FIXME("Add IDirect3D Interfaces\n");
|
649 | | - ERR(DDERR_GENERIC);
|
| 648 | + glDirect3D7 *tmp = new glDirect3D7(this);
|
| 649 | + tmp->QueryInterface(IID_IDirect3D2,ppvObj);
|
| 650 | + tmp->Release();
|
| 651 | + return DD_OK;
|
650 | 652 | }
|
651 | 653 | if(riid == IID_IDirect3D3)
|
652 | 654 | {
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -40,6 +40,8 @@ |
41 | 41 | {
|
42 | 42 | hasstencil = false;
|
43 | 43 | dirty = 2;
|
| 44 | + handle = 0;
|
| 45 | + device = NULL;
|
44 | 46 | locked = 0;
|
45 | 47 | pagelocked = 0;
|
46 | 48 | flipcount = 0;
|
— | — | @@ -326,6 +328,7 @@ |
327 | 329 | if(buffer) free(buffer);
|
328 | 330 | if(bigbuffer) free(bigbuffer);
|
329 | 331 | if(zbuffer) zbuffer->Release();
|
| 332 | + if(device) device->Release();
|
330 | 333 | ddInterface->DeleteSurface(this);
|
331 | 334 | }
|
332 | 335 | HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
|
— | — | @@ -1144,6 +1147,22 @@ |
1145 | 1148 | }
|
1146 | 1149 | }
|
1147 | 1150 |
|
| 1151 | +HRESULT glDirectDrawSurface7::GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle)
|
| 1152 | +{
|
| 1153 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 1154 | + if(!glD3DDev7) return DDERR_INVALIDPARAMS;
|
| 1155 | + if(handle)
|
| 1156 | + {
|
| 1157 | + if(device != glD3DDev7) return DDERR_INVALIDOBJECT;
|
| 1158 | + *lpHandle = handle;
|
| 1159 | + return D3D_OK;
|
| 1160 | + }
|
| 1161 | + device = glD3DDev7;
|
| 1162 | + handle = device->AddTexture(this);
|
| 1163 | + *lpHandle = handle;
|
| 1164 | + return D3D_OK;
|
| 1165 | +}
|
| 1166 | +
|
1148 | 1167 | // DDRAW1 wrapper
|
1149 | 1168 | glDirectDrawSurface1::glDirectDrawSurface1(glDirectDrawSurface7 *gl_DDS7)
|
1150 | 1169 | {
|
— | — | @@ -1184,7 +1203,7 @@ |
1185 | 1204 | HRESULT WINAPI glDirectDrawSurface1::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
|
1186 | 1205 | {
|
1187 | 1206 | if(!this) return DDERR_INVALIDPARAMS;
|
1188 | | - return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
|
| 1207 | + return glDDS7->AddAttachedSurface(((glDirectDrawSurface1*)lpDDSAttachedSurface)->GetDDS7());
|
1189 | 1208 | }
|
1190 | 1209 | HRESULT WINAPI glDirectDrawSurface1::AddOverlayDirtyRect(LPRECT lpRect)
|
1191 | 1210 | {
|
— | — | @@ -1410,7 +1429,7 @@ |
1411 | 1430 | HRESULT WINAPI glDirectDrawSurface2::AddAttachedSurface(LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface)
|
1412 | 1431 | {
|
1413 | 1432 | if(!this) return DDERR_INVALIDPARAMS;
|
1414 | | - return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
|
| 1433 | + return glDDS7->AddAttachedSurface(((glDirectDrawSurface2*)lpDDSAttachedSurface)->GetDDS7());
|
1415 | 1434 | }
|
1416 | 1435 | HRESULT WINAPI glDirectDrawSurface2::AddOverlayDirtyRect(LPRECT lpRect)
|
1417 | 1436 | {
|
— | — | @@ -1650,7 +1669,7 @@ |
1651 | 1670 | HRESULT WINAPI glDirectDrawSurface3::AddAttachedSurface(LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface)
|
1652 | 1671 | {
|
1653 | 1672 | if(!this) return DDERR_INVALIDPARAMS;
|
1654 | | - return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
|
| 1673 | + return glDDS7->AddAttachedSurface(((glDirectDrawSurface3*)lpDDSAttachedSurface)->GetDDS7());
|
1655 | 1674 | }
|
1656 | 1675 | HRESULT WINAPI glDirectDrawSurface3::AddOverlayDirtyRect(LPRECT lpRect)
|
1657 | 1676 | {
|
— | — | @@ -1895,7 +1914,7 @@ |
1896 | 1915 | HRESULT WINAPI glDirectDrawSurface4::AddAttachedSurface(LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface)
|
1897 | 1916 | {
|
1898 | 1917 | if(!this) return DDERR_INVALIDPARAMS;
|
1899 | | - return glDDS7->AddAttachedSurface((LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface);
|
| 1918 | + return glDDS7->AddAttachedSurface(((glDirectDrawSurface4*)lpDDSAttachedSurface)->GetDDS7());
|
1900 | 1919 | }
|
1901 | 1920 | HRESULT WINAPI glDirectDrawSurface4::AddOverlayDirtyRect(LPRECT lpRect)
|
1902 | 1921 | {
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 | class glDirectDrawSurface3;
|
35 | 35 | class glDirectDrawSurface4;
|
36 | 36 | class glDirect3DTexture2;
|
| 37 | +class glDirect3DDevice7;
|
37 | 38 | class glDirectDrawSurface7 : public IDirectDrawSurface7
|
38 | 39 | {
|
39 | 40 | public:
|
— | — | @@ -105,6 +106,7 @@ |
106 | 107 | void RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface);
|
107 | 108 | // Special ddraw2->ddraw7 api
|
108 | 109 | HRESULT WINAPI Unlock2(LPVOID lpSurfaceData);
|
| 110 | + HRESULT GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle);
|
109 | 111 | glDirectDrawSurface1 *dds1;
|
110 | 112 | glDirectDrawSurface2 *dds2;
|
111 | 113 | glDirectDrawSurface3 *dds3;
|
— | — | @@ -127,6 +129,7 @@ |
128 | 130 | glDirectDrawPalette *palette;
|
129 | 131 | HGLRC hRC;
|
130 | 132 | glDirectDrawSurface7 *zbuffer;
|
| 133 | + D3DMATERIALHANDLE handle;
|
131 | 134 | private:
|
132 | 135 | ULONG refcount;
|
133 | 136 | int locked;
|
— | — | @@ -139,6 +142,7 @@ |
140 | 143 | glDirectDrawClipper *clipper;
|
141 | 144 | int pagelocked;
|
142 | 145 | GLint magfilter,minfilter;
|
| 146 | + glDirect3DDevice7 *device;
|
143 | 147 | };
|
144 | 148 |
|
145 | 149 | // Legacy DDRAW Interfaces
|
Index: ddraw/shadergen.cpp |
— | — | @@ -567,10 +567,11 @@ |
568 | 568 | GLint srclen = strlen(src);
|
569 | 569 | glShaderSource(genshaders[index].shader.vs,1,&src,&srclen);
|
570 | 570 | glCompileShader(genshaders[index].shader.vs);
|
571 | | - GLint loglen,result;
|
| 571 | + GLint result;
|
572 | 572 | char *infolog = NULL;
|
573 | 573 | glGetShaderiv(genshaders[index].shader.vs,GL_COMPILE_STATUS,&result);
|
574 | 574 | #ifdef _DEBUG
|
| 575 | + GLint loglen;
|
575 | 576 | if(!result)
|
576 | 577 | {
|
577 | 578 | glGetShaderiv(genshaders[index].shader.vs,GL_INFO_LOG_LENGTH,&loglen);
|