| Index: ddraw/glDirect3D.cpp |
| — | — | @@ -208,7 +208,7 @@ |
| 209 | 209 | TRACE_ENTER(4,14,this,24,&rclsid,14,lpDDS,14,lplpD3DDevice);
|
| 210 | 210 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 211 | 211 | HRESULT ret;
|
| 212 | | - glDirect3DDevice7 *glD3DDev7 = new glDirect3DDevice7(rclsid,this,(glDirectDrawSurface7*)lpDDS);
|
| | 212 | + glDirect3DDevice7 *glD3DDev7 = new glDirect3DDevice7(rclsid,this,(glDirectDrawSurface7*)lpDDS,NULL);
|
| 213 | 213 | if(!glD3DDev7) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
| 214 | 214 | if(FAILED(glD3DDev7->err()))
|
| 215 | 215 | {
|
| Index: ddraw/glDirect3DDevice.cpp |
| — | — | @@ -271,15 +271,12 @@ |
| 272 | 272 | }
|
| 273 | 273 | }
|
| 274 | 274 |
|
| 275 | | -glDirect3DDevice7::glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7)
|
| | 275 | +glDirect3DDevice7::glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7, IUnknown *creator)
|
| 276 | 276 | {
|
| 277 | 277 | TRACE_ENTER(4,14,this,24,&rclsid,14,glD3D7,14,glDDS7);
|
| 278 | 278 | d3ddesc = d3ddesc_default;
|
| 279 | 279 | d3ddesc3 = d3ddesc3_default;
|
| 280 | 280 | int zbuffer = 0;
|
| 281 | | - glD3DDev3 = NULL;
|
| 282 | | - glD3DDev2 = NULL;
|
| 283 | | - glD3DDev1 = NULL;
|
| 284 | 281 | maxmaterials = 32;
|
| 285 | 282 | materials = (glDirect3DMaterial3**)malloc(32*sizeof(glDirect3DMaterial3*));
|
| 286 | 283 | if(!materials)
|
| — | — | @@ -339,7 +336,7 @@ |
| 340 | 337 | this->glD3D7 = glD3D7;
|
| 341 | 338 | glD3D7->AddRef();
|
| 342 | 339 | this->glDDS7 = glDDS7;
|
| 343 | | - glDDS7->AddRef();
|
| | 340 | + if(!creator) glDDS7->AddRef();
|
| 344 | 341 | renderer = this->glD3D7->glDD7->renderer;
|
| 345 | 342 | ZeroMemory(&viewport,sizeof(D3DVIEWPORT7));
|
| 346 | 343 | if(glDDS7->GetZBuffer()) zbuffer = 1;
|
| — | — | @@ -367,6 +364,10 @@ |
| 368 | 365 | scalex = scaley = 0;
|
| 369 | 366 | mhWorld = mhView = mhProjection = 0;
|
| 370 | 367 | glRenderer_InitD3D(renderer,zbuffer);
|
| | 368 | + glD3DDev3 = new glDirect3DDevice3(this);
|
| | 369 | + glD3DDev2 = new glDirect3DDevice2(this);
|
| | 370 | + glD3DDev1 = new glDirect3DDevice1(this);
|
| | 371 | + this->creator = creator;
|
| 371 | 372 | error = D3D_OK;
|
| 372 | 373 | TRACE_EXIT(-1,0);
|
| 373 | 374 | }
|
| — | — | @@ -406,8 +407,11 @@ |
| 407 | 408 | free(materials);
|
| 408 | 409 | free(textures);
|
| 409 | 410 | if(matrices) free(matrices);
|
| | 411 | + if (glD3DDev3) delete glD3DDev3;
|
| | 412 | + if (glD3DDev2) delete glD3DDev2;
|
| | 413 | + if (glD3DDev1) delete glD3DDev1;
|
| 410 | 414 | glD3D7->Release();
|
| 411 | | - glDDS7->Release();
|
| | 415 | + if(!creator) glDDS7->Release();
|
| 412 | 416 | TRACE_EXIT(-1,0);
|
| 413 | 417 | }
|
| 414 | 418 |
|
| — | — | @@ -446,65 +450,29 @@ |
| 447 | 451 | }
|
| 448 | 452 | if(riid == IID_IDirect3DDevice3)
|
| 449 | 453 | {
|
| 450 | | - if(glD3DDev3)
|
| 451 | | - {
|
| 452 | | - *ppvObj = glD3DDev3;
|
| 453 | | - glD3DDev3->AddRef();
|
| 454 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 455 | | - TRACE_EXIT(23,D3D_OK);
|
| 456 | | - return D3D_OK;
|
| 457 | | - }
|
| 458 | | - else
|
| 459 | | - {
|
| 460 | | - this->AddRef();
|
| 461 | | - *ppvObj = new glDirect3DDevice3(this);
|
| 462 | | - glD3DDev3 = (glDirect3DDevice3*)*ppvObj;
|
| 463 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 464 | | - TRACE_EXIT(23,D3D_OK);
|
| 465 | | - return D3D_OK;
|
| 466 | | - }
|
| | 454 | + *ppvObj = glD3DDev3;
|
| | 455 | + glD3DDev3->AddRef();
|
| | 456 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 457 | + TRACE_EXIT(23,D3D_OK);
|
| | 458 | + return D3D_OK;
|
| 467 | 459 | }
|
| 468 | 460 | if(riid == IID_IDirect3DDevice2)
|
| 469 | 461 | {
|
| 470 | | - if(glD3DDev2)
|
| 471 | | - {
|
| 472 | | - *ppvObj = glD3DDev2;
|
| 473 | | - glD3DDev2->AddRef();
|
| 474 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 475 | | - TRACE_EXIT(23,D3D_OK);
|
| 476 | | - return D3D_OK;
|
| 477 | | - }
|
| 478 | | - else
|
| 479 | | - {
|
| 480 | | - this->AddRef();
|
| 481 | | - *ppvObj = new glDirect3DDevice2(this);
|
| 482 | | - glD3DDev2 = (glDirect3DDevice2*)*ppvObj;
|
| 483 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 484 | | - TRACE_EXIT(23,D3D_OK);
|
| 485 | | - return D3D_OK;
|
| 486 | | - }
|
| | 462 | + *ppvObj = glD3DDev2;
|
| | 463 | + glD3DDev2->AddRef();
|
| | 464 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 465 | + TRACE_EXIT(23,D3D_OK);
|
| | 466 | + return D3D_OK;
|
| 487 | 467 | }
|
| 488 | 468 | if(riid == IID_IDirect3DDevice)
|
| 489 | 469 | {
|
| 490 | | - if(glD3DDev1)
|
| 491 | | - {
|
| 492 | | - *ppvObj = glD3DDev1;
|
| 493 | | - glD3DDev1->AddRef();
|
| 494 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 495 | | - TRACE_EXIT(23,D3D_OK);
|
| 496 | | - return D3D_OK;
|
| 497 | | - }
|
| 498 | | - else
|
| 499 | | - {
|
| 500 | | - this->AddRef();
|
| 501 | | - *ppvObj = new glDirect3DDevice1(this);
|
| 502 | | - glD3DDev1 = (glDirect3DDevice1*)*ppvObj;
|
| 503 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 504 | | - TRACE_EXIT(23,D3D_OK);
|
| 505 | | - return D3D_OK;
|
| 506 | | - }
|
| | 470 | + *ppvObj = glD3DDev1;
|
| | 471 | + glD3DDev1->AddRef();
|
| | 472 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 473 | + TRACE_EXIT(23,D3D_OK);
|
| | 474 | + return D3D_OK;
|
| 507 | 475 | }
|
| 508 | | - if (glDDS7) TRACE_RET(HRESULT, 23, glDDS7->QueryInterface(riid, ppvObj));
|
| | 476 | + if (creator) TRACE_RET(HRESULT, 23, creator->QueryInterface(riid, ppvObj));
|
| 509 | 477 | TRACE_EXIT(23,E_NOINTERFACE);
|
| 510 | 478 | return E_NOINTERFACE;
|
| 511 | 479 | }
|
| — | — | @@ -511,6 +479,22 @@ |
| 512 | 480 |
|
| 513 | 481 | ULONG WINAPI glDirect3DDevice7::AddRef()
|
| 514 | 482 | {
|
| | 483 | + TRACE_ENTER(1, 14, this);
|
| | 484 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 485 | + if (creator) TRACE_RET(ULONG, 8, creator->AddRef());
|
| | 486 | + TRACE_RET(ULONG, 8, AddRefInternal());
|
| | 487 | +}
|
| | 488 | +
|
| | 489 | +ULONG WINAPI glDirect3DDevice7::Release()
|
| | 490 | +{
|
| | 491 | + TRACE_ENTER(1, 14, this);
|
| | 492 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 493 | + if (creator) TRACE_RET(ULONG, 8, creator->Release());
|
| | 494 | + TRACE_RET(ULONG, 8, ReleaseInternal());
|
| | 495 | +}
|
| | 496 | +
|
| | 497 | +ULONG glDirect3DDevice7::AddRefInternal()
|
| | 498 | +{
|
| 515 | 499 | TRACE_ENTER(1,14,this);
|
| 516 | 500 | if(!this) TRACE_RET(ULONG,8,0);
|
| 517 | 501 | refcount++;
|
| — | — | @@ -517,7 +501,7 @@ |
| 518 | 502 | TRACE_EXIT(8,refcount);
|
| 519 | 503 | return refcount;
|
| 520 | 504 | }
|
| 521 | | -ULONG WINAPI glDirect3DDevice7::Release()
|
| | 505 | +ULONG glDirect3DDevice7::ReleaseInternal()
|
| 522 | 506 | {
|
| 523 | 507 | TRACE_ENTER(1,14,this);
|
| 524 | 508 | if(!this) TRACE_RET(ULONG,8,0);
|
| — | — | @@ -1458,7 +1442,7 @@ |
| 1459 | 1443 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 1460 | 1444 | lpNewRenderTarget->GetSurfaceDesc(&ddsd);
|
| 1461 | 1445 | if(!(ddsd.ddsCaps.dwCaps & DDSCAPS_3DDEVICE)) TRACE_RET(HRESULT,23,DDERR_INVALIDSURFACETYPE);
|
| 1462 | | - glDDS7->Release();
|
| | 1446 | + if(glDDS7) glDDS7->Release();
|
| 1463 | 1447 | glDDS7 = (glDirectDrawSurface7*)lpNewRenderTarget;
|
| 1464 | 1448 | glDDS7->AddRef();
|
| 1465 | 1449 | TRACE_EXIT(23,D3D_OK);
|
| — | — | @@ -2918,18 +2902,9 @@ |
| 2919 | 2903 | {
|
| 2920 | 2904 | TRACE_ENTER(2,14,this,14,glD3DDev7);
|
| 2921 | 2905 | this->glD3DDev7 = glD3DDev7;
|
| 2922 | | - refcount = 1;
|
| 2923 | 2906 | TRACE_EXIT(-1,0);
|
| 2924 | 2907 | }
|
| 2925 | 2908 |
|
| 2926 | | -glDirect3DDevice3::~glDirect3DDevice3()
|
| 2927 | | -{
|
| 2928 | | - TRACE_ENTER(1,14,this);
|
| 2929 | | - glD3DDev7->glD3DDev3 = NULL;
|
| 2930 | | - glD3DDev7->Release();
|
| 2931 | | - TRACE_EXIT(-1,0);
|
| 2932 | | -}
|
| 2933 | | -
|
| 2934 | 2909 | HRESULT WINAPI glDirect3DDevice3::QueryInterface(REFIID riid, void** ppvObj)
|
| 2935 | 2910 | {
|
| 2936 | 2911 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -2949,9 +2924,7 @@ |
| 2950 | 2925 | {
|
| 2951 | 2926 | TRACE_ENTER(1,14,this);
|
| 2952 | 2927 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2953 | | - refcount++;
|
| 2954 | | - TRACE_EXIT(8,refcount);
|
| 2955 | | - return refcount;
|
| | 2928 | + TRACE_RET(ULONG, 8, glD3DDev7->AddRef());
|
| 2956 | 2929 | }
|
| 2957 | 2930 |
|
| 2958 | 2931 | ULONG WINAPI glDirect3DDevice3::Release()
|
| — | — | @@ -2958,12 +2931,7 @@ |
| 2959 | 2932 | {
|
| 2960 | 2933 | TRACE_ENTER(1,14,this);
|
| 2961 | 2934 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2962 | | - ULONG ret;
|
| 2963 | | - refcount--;
|
| 2964 | | - ret = refcount;
|
| 2965 | | - if(refcount == 0) delete this;
|
| 2966 | | - TRACE_EXIT(8,ret);
|
| 2967 | | - return ret;
|
| | 2935 | + TRACE_RET(ULONG, 8, glD3DDev7->Release());
|
| 2968 | 2936 | }
|
| 2969 | 2937 |
|
| 2970 | 2938 | HRESULT WINAPI glDirect3DDevice3::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
|
| — | — | @@ -3277,18 +3245,9 @@ |
| 3278 | 3246 | TRACE_ENTER(2,14,this,14,glD3DDev7);
|
| 3279 | 3247 | this->glD3DDev7 = glD3DDev7;
|
| 3280 | 3248 | glD3DDev7->InitDX5();
|
| 3281 | | - refcount = 1;
|
| 3282 | 3249 | TRACE_EXIT(-1,0);
|
| 3283 | 3250 | }
|
| 3284 | 3251 |
|
| 3285 | | -glDirect3DDevice2::~glDirect3DDevice2()
|
| 3286 | | -{
|
| 3287 | | - TRACE_ENTER(1,14,this);
|
| 3288 | | - glD3DDev7->glD3DDev2 = NULL;
|
| 3289 | | - glD3DDev7->Release();
|
| 3290 | | - TRACE_EXIT(-1,0);
|
| 3291 | | -}
|
| 3292 | | -
|
| 3293 | 3252 | HRESULT WINAPI glDirect3DDevice2::QueryInterface(REFIID riid, void** ppvObj)
|
| 3294 | 3253 | {
|
| 3295 | 3254 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -3308,9 +3267,7 @@ |
| 3309 | 3268 | {
|
| 3310 | 3269 | TRACE_ENTER(1,14,this);
|
| 3311 | 3270 | if(!this) TRACE_RET(ULONG,8,0);
|
| 3312 | | - refcount++;
|
| 3313 | | - TRACE_EXIT(8,refcount);
|
| 3314 | | - return refcount;
|
| | 3271 | + TRACE_RET(ULONG, 8, glD3DDev7->AddRef());
|
| 3315 | 3272 | }
|
| 3316 | 3273 |
|
| 3317 | 3274 | ULONG WINAPI glDirect3DDevice2::Release()
|
| — | — | @@ -3317,12 +3274,7 @@ |
| 3318 | 3275 | {
|
| 3319 | 3276 | TRACE_ENTER(1,14,this);
|
| 3320 | 3277 | if(!this) TRACE_RET(ULONG,8,0);
|
| 3321 | | - ULONG ret;
|
| 3322 | | - refcount--;
|
| 3323 | | - ret = refcount;
|
| 3324 | | - if(refcount == 0) delete this;
|
| 3325 | | - TRACE_EXIT(8,ret);
|
| 3326 | | - return ret;
|
| | 3278 | + TRACE_RET(ULONG, 8, glD3DDev7->Release());
|
| 3327 | 3279 | }
|
| 3328 | 3280 |
|
| 3329 | 3281 | HRESULT WINAPI glDirect3DDevice2::AddViewport(LPDIRECT3DVIEWPORT2 lpDirect3DViewport2)
|
| — | — | @@ -3628,18 +3580,9 @@ |
| 3629 | 3581 | TRACE_ENTER(2,14,this,14,glD3DDev7);
|
| 3630 | 3582 | this->glD3DDev7 = glD3DDev7;
|
| 3631 | 3583 | glD3DDev7->InitDX5();
|
| 3632 | | - refcount = 1;
|
| 3633 | 3584 | TRACE_EXIT(-1,0);
|
| 3634 | 3585 | }
|
| 3635 | 3586 |
|
| 3636 | | -glDirect3DDevice1::~glDirect3DDevice1()
|
| 3637 | | -{
|
| 3638 | | - TRACE_ENTER(1,14,this);
|
| 3639 | | - glD3DDev7->glD3DDev1 = NULL;
|
| 3640 | | - glD3DDev7->Release();
|
| 3641 | | - TRACE_EXIT(-1,0);
|
| 3642 | | -}
|
| 3643 | | -
|
| 3644 | 3587 | HRESULT WINAPI glDirect3DDevice1::QueryInterface(REFIID riid, void** ppvObj)
|
| 3645 | 3588 | {
|
| 3646 | 3589 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -3659,9 +3602,7 @@ |
| 3660 | 3603 | {
|
| 3661 | 3604 | TRACE_ENTER(1,14,this);
|
| 3662 | 3605 | if(!this) TRACE_RET(ULONG,8,0);
|
| 3663 | | - refcount++;
|
| 3664 | | - TRACE_EXIT(8,refcount);
|
| 3665 | | - return refcount;
|
| | 3606 | + TRACE_RET(ULONG, 8, glD3DDev7->AddRef());
|
| 3666 | 3607 | }
|
| 3667 | 3608 |
|
| 3668 | 3609 | ULONG WINAPI glDirect3DDevice1::Release()
|
| — | — | @@ -3668,12 +3609,7 @@ |
| 3669 | 3610 | {
|
| 3670 | 3611 | TRACE_ENTER(1,14,this);
|
| 3671 | 3612 | if(!this) TRACE_RET(ULONG,8,0);
|
| 3672 | | - ULONG ret;
|
| 3673 | | - refcount--;
|
| 3674 | | - ret = refcount;
|
| 3675 | | - if(refcount == 0) delete this;
|
| 3676 | | - TRACE_EXIT(8,ret);
|
| 3677 | | - return ret;
|
| | 3613 | + TRACE_RET(ULONG, 8, glD3DDev7->Release());
|
| 3678 | 3614 | }
|
| 3679 | 3615 |
|
| 3680 | 3616 | HRESULT WINAPI glDirect3DDevice1::AddViewport(LPDIRECT3DVIEWPORT lpDirect3DViewport)
|
| 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);
|
| | 74 | + glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7, IUnknown *creator);
|
| 75 | 75 | virtual ~glDirect3DDevice7();
|
| 76 | 76 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 77 | 77 | ULONG WINAPI AddRef();
|
| — | — | @@ -170,6 +170,8 @@ |
| 171 | 171 | void InitDX5();
|
| 172 | 172 | __int64 SelectShader(GLVERTEX *VertexType);
|
| 173 | 173 | void SetScale(D3DVALUE x, D3DVALUE y){scalex = x; scaley = y;}
|
| | 174 | + ULONG AddRefInternal();
|
| | 175 | + ULONG ReleaseInternal();
|
| 174 | 176 | GLfloat matWorld[16];
|
| 175 | 177 | GLfloat matView[16];
|
| 176 | 178 | GLfloat matProjection[16];
|
| — | — | @@ -232,6 +234,7 @@ |
| 233 | 235 | D3DDEVICEDESC7 d3ddesc;
|
| 234 | 236 | D3DDEVICEDESC d3ddesc3;
|
| 235 | 237 | glRenderer *renderer;
|
| | 238 | + IUnknown *creator;
|
| 236 | 239 | };
|
| 237 | 240 |
|
| 238 | 241 | #endif //__GLDIRECT3DDEVICE_H
|
| — | — | @@ -240,7 +243,6 @@ |
| 241 | 244 | {
|
| 242 | 245 | public:
|
| 243 | 246 | glDirect3DDevice3(glDirect3DDevice7 *glD3DDev7);
|
| 244 | | - virtual ~glDirect3DDevice3();
|
| 245 | 247 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 246 | 248 | ULONG WINAPI AddRef();
|
| 247 | 249 | ULONG WINAPI Release();
|
| — | — | @@ -292,7 +294,6 @@ |
| 293 | 295 | glDirect3DDevice7 *GetGLD3DDev7(){return glD3DDev7;}
|
| 294 | 296 | private:
|
| 295 | 297 | glDirect3DDevice7 *glD3DDev7;
|
| 296 | | - ULONG refcount;
|
| 297 | 298 | };
|
| 298 | 299 |
|
| 299 | 300 |
|
| — | — | @@ -300,7 +301,6 @@ |
| 301 | 302 | {
|
| 302 | 303 | public:
|
| 303 | 304 | glDirect3DDevice2(glDirect3DDevice7 *glD3DDev7);
|
| 304 | | - virtual ~glDirect3DDevice2();
|
| 305 | 305 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 306 | 306 | ULONG WINAPI AddRef();
|
| 307 | 307 | ULONG WINAPI Release();
|
| — | — | @@ -338,7 +338,6 @@ |
| 339 | 339 | HRESULT WINAPI Vertex(LPVOID lpVertexType);
|
| 340 | 340 | private:
|
| 341 | 341 | glDirect3DDevice7 *glD3DDev7;
|
| 342 | | - ULONG refcount;
|
| 343 | 342 | };
|
| 344 | 343 |
|
| 345 | 344 | class glDirect3DDevice1 : public IDirect3DDevice
|
| — | — | @@ -345,7 +344,6 @@ |
| 346 | 345 | {
|
| 347 | 346 | public:
|
| 348 | 347 | glDirect3DDevice1(glDirect3DDevice7 *glD3DDev7);
|
| 349 | | - virtual ~glDirect3DDevice1();
|
| 350 | 348 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 351 | 349 | ULONG WINAPI AddRef();
|
| 352 | 350 | ULONG WINAPI Release();
|
| — | — | @@ -372,5 +370,4 @@ |
| 373 | 371 | HRESULT WINAPI SwapTextureHandles(LPDIRECT3DTEXTURE lpD3DTex1, LPDIRECT3DTEXTURE lpD3DTex2);
|
| 374 | 372 | private:
|
| 375 | 373 | glDirect3DDevice7 *glD3DDev7;
|
| 376 | | - ULONG refcount;
|
| 377 | 374 | }; |
| \ No newline at end of file |
| Index: ddraw/glDirectDrawSurface.cpp |
| — | — | @@ -47,6 +47,7 @@ |
| 48 | 48 | dirty = 2;
|
| 49 | 49 | handle = 0;
|
| 50 | 50 | device = NULL;
|
| | 51 | + device1 = NULL;
|
| 51 | 52 | locked = 0;
|
| 52 | 53 | pagelocked = 0;
|
| 53 | 54 | flipcount = 0;
|
| — | — | @@ -424,7 +425,8 @@ |
| 425 | 426 | if(bigbuffer) free(bigbuffer);
|
| 426 | 427 | if(zbuffer) zbuffer_iface->Release();
|
| 427 | 428 | if(miptexture) miptexture->Release();
|
| 428 | | - if(device) device->Release();
|
| | 429 | + if (device) device->Release();
|
| | 430 | + if (device1) delete device1;
|
| 429 | 431 | ddInterface->DeleteSurface(this);
|
| 430 | 432 | if (creator) creator->Release();
|
| 431 | 433 | TRACE_EXIT(-1,0);
|
| — | — | @@ -431,6 +433,7 @@ |
| 432 | 434 | }
|
| 433 | 435 | HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
|
| 434 | 436 | {
|
| | 437 | + HRESULT ret;
|
| 435 | 438 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| 436 | 439 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 437 | 440 | if(!ppvObj) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| — | — | @@ -500,34 +503,34 @@ |
| 501 | 504 | }
|
| 502 | 505 | if (riid == IID_IDirectDrawColorControl)
|
| 503 | 506 | {
|
| 504 | | - FIXME("Add color control\n");
|
| | 507 | + DEBUG("FIXME: Add color control\n");
|
| 505 | 508 | TRACE_EXIT(23, E_NOINTERFACE);
|
| 506 | | - ERR(E_NOINTERFACE);
|
| | 509 | + return E_NOINTERFACE;
|
| 507 | 510 | }
|
| 508 | 511 | if ((riid == IID_IDirect3DHALDevice) || (riid == IID_IDirect3DRGBDevice) ||
|
| 509 | 512 | (riid == IID_IDirect3DRampDevice) || (riid == IID_IDirect3DRefDevice))
|
| 510 | 513 | {
|
| 511 | 514 |
|
| 512 | | - if(!device)
|
| | 515 | + if(!device1)
|
| 513 | 516 | {
|
| 514 | 517 | glDirect3D7 *tmpd3d;
|
| 515 | | - glDirect3DDevice7 *tmpdev;
|
| 516 | 518 | ddInterface->QueryInterface(IID_IDirect3D7,(void**)&tmpd3d);
|
| 517 | 519 | if(!tmpd3d) TRACE_RET(HRESULT,23,E_NOINTERFACE);
|
| 518 | | - tmpd3d->CreateDevice(riid,this,(LPDIRECT3DDEVICE7*)&tmpdev);
|
| 519 | | - if(!tmpdev)
|
| | 520 | + device1 = new glDirect3DDevice7(riid, tmpd3d, this, dds1);
|
| | 521 | + if (FAILED(device1->err()))
|
| 520 | 522 | {
|
| | 523 | + ret = device1->err();
|
| | 524 | + delete device1;
|
| 521 | 525 | tmpd3d->Release();
|
| 522 | | - TRACE_EXIT(23,E_NOINTERFACE);
|
| 523 | | - return E_NOINTERFACE;
|
| | 526 | + TRACE_EXIT(23, ret);
|
| | 527 | + return ret;
|
| 524 | 528 | }
|
| 525 | | - HRESULT ret = tmpdev->QueryInterface(IID_IDirect3DDevice,ppvObj);
|
| 526 | | - tmpdev->SetRenderTarget(this,0);
|
| 527 | | - tmpdev->Release();
|
| | 529 | + *ppvObj = device1->glD3DDev1;
|
| | 530 | + device1->glD3DDev1->AddRef();
|
| 528 | 531 | tmpd3d->Release();
|
| 529 | 532 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 530 | | - TRACE_EXIT(23,ret);
|
| 531 | | - return ret;
|
| | 533 | + TRACE_EXIT(23,DD_OK);
|
| | 534 | + return DD_OK;
|
| 532 | 535 | }
|
| 533 | 536 | else
|
| 534 | 537 | {
|
| Index: ddraw/glDirectDrawSurface.h |
| — | — | @@ -173,6 +173,7 @@ |
| 174 | 174 | int surfacetype; // 0-generic memory, 1-GDI surface, 2-OpenGL Texture
|
| 175 | 175 | int pagelocked;
|
| 176 | 176 | GLint magfilter,minfilter;
|
| | 177 | + glDirect3DDevice7 *device1;
|
| 177 | 178 | glDirect3DDevice7 *device;
|
| 178 | 179 | bool overlay;
|
| 179 | 180 | IUnknown *zbuffer_iface;
|