Index: ddraw/glDirect3D.cpp |
— | — | @@ -175,64 +175,24 @@ |
176 | 176 | d3ddesc_default.wMaxSimultaneousTextures
|
177 | 177 | };
|
178 | 178 |
|
179 | | -const D3DDevice devices[3] =
|
180 | | -{
|
181 | | - {
|
182 | | - "Simulated RGB Rasterizer",
|
183 | | - "DXGL RGB Rasterizer",
|
184 | | - },
|
185 | | - {
|
186 | | - "DXGL Hardware Accelerator",
|
187 | | - "DXGL D3D HAL",
|
188 | | - },
|
189 | | - {
|
190 | | - "DXGL Hardware Accelerator with Transform and Lighting",
|
191 | | - "DXGL D3D T&L HAL",
|
192 | | - }
|
193 | | -};
|
194 | 179 | glDirect3D7::glDirect3D7(glDirectDraw7 *gl_DD7)
|
195 | 180 | {
|
196 | 181 | TRACE_ENTER(1,14,this,14,gl_DD7);
|
197 | | - d3ddesc = d3ddesc_default;
|
198 | | - d3ddesc3 = d3ddesc3_default;
|
199 | | - refcount=1;
|
200 | | - glD3D3 = NULL;
|
201 | | - glD3D2 = NULL;
|
202 | | - glD3D1 = NULL;
|
203 | 182 | glDD7 = gl_DD7;
|
204 | | - glDD7->AddRef();
|
205 | | - memcpy(stored_devices, devices, 3 * sizeof(D3DDevice));
|
206 | 183 | TRACE_EXIT(-1, 0);
|
207 | 184 | }
|
208 | 185 |
|
209 | | -glDirect3D7::~glDirect3D7()
|
210 | | -{
|
211 | | - TRACE_ENTER(1,14,this);
|
212 | | - glDD7->Release();
|
213 | | - if(glD3D3) glD3D3->Release();
|
214 | | - if(glD3D2) glD3D2->Release();
|
215 | | - if(glD3D1) glD3D1->Release();
|
216 | | - TRACE_EXIT(-1,0);
|
217 | | -}
|
218 | | -
|
219 | 186 | ULONG WINAPI glDirect3D7::AddRef()
|
220 | 187 | {
|
221 | 188 | TRACE_ENTER(1,14,this);
|
222 | 189 | if(!this) TRACE_RET(ULONG,8,0);
|
223 | | - refcount++;
|
224 | | - TRACE_EXIT(8,refcount);
|
225 | | - return refcount;
|
| 190 | + TRACE_RET(ULONG, 8, glDD7->AddRef());
|
226 | 191 | }
|
227 | 192 | ULONG WINAPI glDirect3D7::Release()
|
228 | 193 | {
|
229 | 194 | TRACE_ENTER(1,14,this);
|
230 | 195 | if(!this) TRACE_RET(ULONG,8,0);
|
231 | | - ULONG ret;
|
232 | | - refcount--;
|
233 | | - ret = refcount;
|
234 | | - if(refcount == 0) delete this;
|
235 | | - TRACE_EXIT(8,refcount);
|
236 | | - return ret;
|
| 196 | + TRACE_RET(ULONG, 8, glDD7->Release());
|
237 | 197 | }
|
238 | 198 |
|
239 | 199 | HRESULT WINAPI glDirect3D7::QueryInterface(REFIID riid, void** ppvObj)
|
— | — | @@ -239,77 +199,7 @@ |
240 | 200 | {
|
241 | 201 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
242 | 202 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
243 | | - if(!ppvObj) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
244 | | - if(riid == IID_IUnknown)
|
245 | | - {
|
246 | | - this->AddRef();
|
247 | | - *ppvObj = this;
|
248 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
249 | | - TRACE_EXIT(23,D3D_OK);
|
250 | | - return D3D_OK;
|
251 | | - }
|
252 | | - if(riid == IID_IDirect3D3)
|
253 | | - {
|
254 | | - if(glD3D3)
|
255 | | - {
|
256 | | - *ppvObj = glD3D3;
|
257 | | - glD3D3->AddRef();
|
258 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
259 | | - TRACE_EXIT(23,D3D_OK);
|
260 | | - return D3D_OK;
|
261 | | - }
|
262 | | - else
|
263 | | - {
|
264 | | - this->AddRef();
|
265 | | - *ppvObj = new glDirect3D3(this);
|
266 | | - glD3D3 = (glDirect3D3*)*ppvObj;
|
267 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
268 | | - TRACE_EXIT(23,D3D_OK);
|
269 | | - return D3D_OK;
|
270 | | - }
|
271 | | - }
|
272 | | - if(riid == IID_IDirect3D2)
|
273 | | - {
|
274 | | - if(glD3D2)
|
275 | | - {
|
276 | | - *ppvObj = glD3D2;
|
277 | | - glD3D2->AddRef();
|
278 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
279 | | - TRACE_EXIT(23,D3D_OK);
|
280 | | - return D3D_OK;
|
281 | | - }
|
282 | | - else
|
283 | | - {
|
284 | | - this->AddRef();
|
285 | | - *ppvObj = new glDirect3D2(this);
|
286 | | - glD3D2 = (glDirect3D2*)*ppvObj;
|
287 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
288 | | - TRACE_EXIT(23,D3D_OK);
|
289 | | - return D3D_OK;
|
290 | | - }
|
291 | | - }
|
292 | | - if(riid == IID_IDirect3D)
|
293 | | - {
|
294 | | - if(glD3D1)
|
295 | | - {
|
296 | | - *ppvObj = glD3D1;
|
297 | | - glD3D1->AddRef();
|
298 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
299 | | - TRACE_EXIT(23,D3D_OK);
|
300 | | - return D3D_OK;
|
301 | | - }
|
302 | | - else
|
303 | | - {
|
304 | | - this->AddRef();
|
305 | | - *ppvObj = new glDirect3D1(this);
|
306 | | - glD3D1 = (glDirect3D1*)*ppvObj;
|
307 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
308 | | - TRACE_EXIT(23,D3D_OK);
|
309 | | - return D3D_OK;
|
310 | | - }
|
311 | | - }
|
312 | | - TRACE_EXIT(23,E_NOINTERFACE);
|
313 | | - return E_NOINTERFACE;
|
| 203 | + TRACE_RET(HRESULT, 23, glDD7->QueryInterface(riid, ppvObj));
|
314 | 204 | }
|
315 | 205 |
|
316 | 206 |
|
— | — | @@ -382,7 +272,7 @@ |
383 | 273 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
384 | 274 | if(!lpEnumDevicesCallback) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
385 | 275 | HRESULT result;
|
386 | | - D3DDEVICEDESC7 desc = d3ddesc;
|
| 276 | + D3DDEVICEDESC7 desc = glDD7->d3ddesc;
|
387 | 277 | for(int i = 0; i < 3; i++)
|
388 | 278 | {
|
389 | 279 | switch(i)
|
— | — | @@ -399,7 +289,7 @@ |
400 | 290 | desc.dwDevCaps |= D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_HWTRANSFORMANDLIGHT;
|
401 | 291 | break;
|
402 | 292 | }
|
403 | | - result = lpEnumDevicesCallback(stored_devices[i].name,stored_devices[i].devname,&desc,lpUserArg);
|
| 293 | + result = lpEnumDevicesCallback(glDD7->stored_devices[i].name,glDD7->stored_devices[i].devname,&desc,lpUserArg);
|
404 | 294 | if(result != D3DENUMRET_OK) break;
|
405 | 295 | }
|
406 | 296 | TRACE_EXIT(23,D3D_OK);
|
— | — | @@ -412,12 +302,12 @@ |
413 | 303 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
414 | 304 | if(!lpEnumDevicesCallback) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
415 | 305 | HRESULT result;
|
416 | | - D3DDEVICEDESC desc = d3ddesc3;
|
| 306 | + D3DDEVICEDESC desc = glDD7->d3ddesc3;
|
417 | 307 | GUID guid = IID_IDirect3DRGBDevice;
|
418 | | - result = lpEnumDevicesCallback(&guid,stored_devices[0].name,stored_devices[0].devname,&desc,&desc,lpUserArg);
|
| 308 | + result = lpEnumDevicesCallback(&guid,glDD7->stored_devices[0].name,glDD7->stored_devices[0].devname,&desc,&desc,lpUserArg);
|
419 | 309 | if(result != D3DENUMRET_OK) TRACE_RET(HRESULT,23,D3D_OK);
|
420 | 310 | guid = IID_IDirect3DHALDevice;
|
421 | | - result = lpEnumDevicesCallback(&guid,stored_devices[1].name,stored_devices[1].devname,&desc,&desc,lpUserArg);
|
| 311 | + result = lpEnumDevicesCallback(&guid,glDD7->stored_devices[1].name,glDD7->stored_devices[1].devname,&desc,&desc,lpUserArg);
|
422 | 312 | TRACE_EXIT(23,D3D_OK);
|
423 | 313 | return D3D_OK;
|
424 | 314 | }
|
— | — | @@ -477,58 +367,58 @@ |
478 | 368 | {
|
479 | 369 | if(lpD3DFDS->dwFlags & D3DFDS_ALPHACMPCAPS)
|
480 | 370 | {
|
481 | | - if((d3ddesc.dpcTriCaps.dwAlphaCmpCaps & lpD3DFDS->dpcPrimCaps.dwAlphaCmpCaps)
|
| 371 | + if((glDD7->d3ddesc.dpcTriCaps.dwAlphaCmpCaps & lpD3DFDS->dpcPrimCaps.dwAlphaCmpCaps)
|
482 | 372 | != lpD3DFDS->dpcPrimCaps.dwAlphaCmpCaps) found = false;
|
483 | 373 | }
|
484 | 374 | if(lpD3DFDS->dwFlags & D3DFDS_DSTBLENDCAPS)
|
485 | 375 | {
|
486 | | - if((d3ddesc.dpcTriCaps.dwDestBlendCaps & lpD3DFDS->dpcPrimCaps.dwDestBlendCaps)
|
| 376 | + if ((glDD7->d3ddesc.dpcTriCaps.dwDestBlendCaps & lpD3DFDS->dpcPrimCaps.dwDestBlendCaps)
|
487 | 377 | != lpD3DFDS->dpcPrimCaps.dwDestBlendCaps) found = false;
|
488 | 378 | }
|
489 | 379 | if(lpD3DFDS->dwFlags & D3DFDS_MISCCAPS)
|
490 | 380 | {
|
491 | | - if((d3ddesc.dpcTriCaps.dwMiscCaps & lpD3DFDS->dpcPrimCaps.dwMiscCaps)
|
| 381 | + if ((glDD7->d3ddesc.dpcTriCaps.dwMiscCaps & lpD3DFDS->dpcPrimCaps.dwMiscCaps)
|
492 | 382 | != lpD3DFDS->dpcPrimCaps.dwMiscCaps) found = false;
|
493 | 383 | }
|
494 | 384 | if(lpD3DFDS->dwFlags & D3DFDS_RASTERCAPS)
|
495 | 385 | {
|
496 | | - if((d3ddesc.dpcTriCaps.dwRasterCaps & lpD3DFDS->dpcPrimCaps.dwRasterCaps)
|
| 386 | + if ((glDD7->d3ddesc.dpcTriCaps.dwRasterCaps & lpD3DFDS->dpcPrimCaps.dwRasterCaps)
|
497 | 387 | != lpD3DFDS->dpcPrimCaps.dwRasterCaps) found = false;
|
498 | 388 | }
|
499 | 389 | if(lpD3DFDS->dwFlags & D3DFDS_SHADECAPS)
|
500 | 390 | {
|
501 | | - if((d3ddesc.dpcTriCaps.dwShadeCaps & lpD3DFDS->dpcPrimCaps.dwShadeCaps)
|
| 391 | + if ((glDD7->d3ddesc.dpcTriCaps.dwShadeCaps & lpD3DFDS->dpcPrimCaps.dwShadeCaps)
|
502 | 392 | != lpD3DFDS->dpcPrimCaps.dwShadeCaps) found = false;
|
503 | 393 | }
|
504 | 394 | if(lpD3DFDS->dwFlags & D3DFDS_SRCBLENDCAPS)
|
505 | 395 | {
|
506 | | - if((d3ddesc.dpcTriCaps.dwSrcBlendCaps & lpD3DFDS->dpcPrimCaps.dwSrcBlendCaps)
|
| 396 | + if ((glDD7->d3ddesc.dpcTriCaps.dwSrcBlendCaps & lpD3DFDS->dpcPrimCaps.dwSrcBlendCaps)
|
507 | 397 | != lpD3DFDS->dpcPrimCaps.dwSrcBlendCaps) found = false;
|
508 | 398 | }
|
509 | 399 | if(lpD3DFDS->dwFlags & D3DFDS_TEXTUREBLENDCAPS)
|
510 | 400 | {
|
511 | | - if((d3ddesc.dpcTriCaps.dwTextureBlendCaps & lpD3DFDS->dpcPrimCaps.dwTextureBlendCaps)
|
| 401 | + if ((glDD7->d3ddesc.dpcTriCaps.dwTextureBlendCaps & lpD3DFDS->dpcPrimCaps.dwTextureBlendCaps)
|
512 | 402 | != lpD3DFDS->dpcPrimCaps.dwTextureBlendCaps) found = false;
|
513 | 403 | }
|
514 | 404 | if(lpD3DFDS->dwFlags & D3DFDS_TEXTURECAPS)
|
515 | 405 | {
|
516 | | - if((d3ddesc.dpcTriCaps.dwTextureCaps & lpD3DFDS->dpcPrimCaps.dwTextureCaps)
|
| 406 | + if ((glDD7->d3ddesc.dpcTriCaps.dwTextureCaps & lpD3DFDS->dpcPrimCaps.dwTextureCaps)
|
517 | 407 | != lpD3DFDS->dpcPrimCaps.dwTextureCaps) found = false;
|
518 | 408 | }
|
519 | 409 | if(lpD3DFDS->dwFlags & D3DFDS_TEXTUREFILTERCAPS)
|
520 | 410 | {
|
521 | | - if((d3ddesc.dpcTriCaps.dwTextureFilterCaps & lpD3DFDS->dpcPrimCaps.dwTextureFilterCaps)
|
| 411 | + if ((glDD7->d3ddesc.dpcTriCaps.dwTextureFilterCaps & lpD3DFDS->dpcPrimCaps.dwTextureFilterCaps)
|
522 | 412 | != lpD3DFDS->dpcPrimCaps.dwTextureFilterCaps) found = false;
|
523 | 413 | }
|
524 | 414 | if(lpD3DFDS->dwCaps & D3DFDS_ZCMPCAPS)
|
525 | 415 | {
|
526 | | - if((d3ddesc.dpcTriCaps.dwZCmpCaps & lpD3DFDS->dpcPrimCaps.dwZCmpCaps)
|
| 416 | + if ((glDD7->d3ddesc.dpcTriCaps.dwZCmpCaps & lpD3DFDS->dpcPrimCaps.dwZCmpCaps)
|
527 | 417 | != lpD3DFDS->dpcPrimCaps.dwZCmpCaps) found = false;
|
528 | 418 | }
|
529 | 419 | }
|
530 | 420 | if(lpD3DFDS->dwFlags & D3DFDS_COLORMODEL)
|
531 | 421 | {
|
532 | | - if((d3ddesc3.dcmColorModel & lpD3DFDS->dcmColorModel) != lpD3DFDS->dcmColorModel) found = false;
|
| 422 | + if ((glDD7->d3ddesc3.dcmColorModel & lpD3DFDS->dcmColorModel) != lpD3DFDS->dcmColorModel) found = false;
|
533 | 423 | }
|
534 | 424 | if(lpD3DFDS->dwFlags & D3DFDS_GUID)
|
535 | 425 | {
|
— | — | @@ -546,8 +436,8 @@ |
547 | 437 | else if(!lpD3DFDS->bHardware) guid = IID_IDirect3DRGBDevice;
|
548 | 438 | }
|
549 | 439 | if(!found) TRACE_RET(HRESULT,23,DDERR_NOTFOUND);
|
550 | | - if(guid == IID_IDirect3DRGBDevice) lpD3DFDR->ddSwDesc = d3ddesc3;
|
551 | | - else lpD3DFDR->ddHwDesc = d3ddesc3;
|
| 440 | + if(guid == IID_IDirect3DRGBDevice) lpD3DFDR->ddSwDesc = glDD7->d3ddesc3;
|
| 441 | + else lpD3DFDR->ddHwDesc = glDD7->d3ddesc3;
|
552 | 442 | lpD3DFDR->guid = guid;
|
553 | 443 | TRACE_EXIT(23,D3D_OK);
|
554 | 444 | return D3D_OK;
|
— | — | @@ -559,18 +449,9 @@ |
560 | 450 | {
|
561 | 451 | TRACE_ENTER(2,14,this,14,glD3D7);
|
562 | 452 | this->glD3D7 = glD3D7;
|
563 | | - refcount = 1;
|
564 | 453 | TRACE_EXIT(-1,0);
|
565 | 454 | }
|
566 | 455 |
|
567 | | -glDirect3D3::~glDirect3D3()
|
568 | | -{
|
569 | | - TRACE_ENTER(1,14,this);
|
570 | | - glD3D7->Release();
|
571 | | - glD3D7->glD3D3 = NULL;
|
572 | | - TRACE_EXIT(-1,0);
|
573 | | -}
|
574 | | -
|
575 | 456 | HRESULT WINAPI glDirect3D3::QueryInterface(REFIID riid, void** ppvObj)
|
576 | 457 | {
|
577 | 458 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
— | — | @@ -590,9 +471,7 @@ |
591 | 472 | {
|
592 | 473 | TRACE_ENTER(1,14,this);
|
593 | 474 | if(!this) TRACE_RET(ULONG,8,0);
|
594 | | - refcount++;
|
595 | | - TRACE_EXIT(8,refcount);
|
596 | | - return refcount;
|
| 475 | + TRACE_RET(ULONG, 8, glD3D7->glDD7->AddRef1());
|
597 | 476 | }
|
598 | 477 |
|
599 | 478 | ULONG WINAPI glDirect3D3::Release()
|
— | — | @@ -599,12 +478,7 @@ |
600 | 479 | {
|
601 | 480 | TRACE_ENTER(1,14,this);
|
602 | 481 | if(!this) TRACE_RET(ULONG,8,0);
|
603 | | - ULONG ret;
|
604 | | - refcount--;
|
605 | | - ret = refcount;
|
606 | | - if(refcount == 0) delete this;
|
607 | | - TRACE_EXIT(8,ret);
|
608 | | - return ret;
|
| 482 | + TRACE_RET(ULONG, 8, glD3D7->glDD7->Release1());
|
609 | 483 | }
|
610 | 484 |
|
611 | 485 | HRESULT WINAPI glDirect3D3::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE4 lpDDS, LPDIRECT3DDEVICE3 *lplpD3DDevice, LPUNKNOWN pUnkOuter)
|
— | — | @@ -694,18 +568,9 @@ |
695 | 569 | {
|
696 | 570 | TRACE_ENTER(2,14,this,14,glD3D7);
|
697 | 571 | this->glD3D7 = glD3D7;
|
698 | | - refcount = 1;
|
699 | 572 | TRACE_EXIT(-1,0);
|
700 | 573 | }
|
701 | 574 |
|
702 | | -glDirect3D2::~glDirect3D2()
|
703 | | -{
|
704 | | - TRACE_ENTER(1,14,this);
|
705 | | - glD3D7->Release();
|
706 | | - glD3D7->glD3D2 = NULL;
|
707 | | - TRACE_EXIT(-1,0);
|
708 | | -}
|
709 | | -
|
710 | 575 | HRESULT WINAPI glDirect3D2::QueryInterface(REFIID riid, void** ppvObj)
|
711 | 576 | {
|
712 | 577 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
— | — | @@ -725,9 +590,7 @@ |
726 | 591 | {
|
727 | 592 | TRACE_ENTER(1,14,this);
|
728 | 593 | if(!this) TRACE_RET(ULONG,8,0);
|
729 | | - refcount++;
|
730 | | - TRACE_EXIT(8,refcount);
|
731 | | - return refcount;
|
| 594 | + TRACE_RET(ULONG, 8, glD3D7->glDD7->AddRef1());
|
732 | 595 | }
|
733 | 596 |
|
734 | 597 | ULONG WINAPI glDirect3D2::Release()
|
— | — | @@ -734,12 +597,7 @@ |
735 | 598 | {
|
736 | 599 | TRACE_ENTER(1,14,this);
|
737 | 600 | if(!this) TRACE_RET(ULONG,8,0);
|
738 | | - ULONG ret;
|
739 | | - refcount--;
|
740 | | - ret = refcount;
|
741 | | - if(refcount == 0) delete this;
|
742 | | - TRACE_EXIT(8,ret);
|
743 | | - return ret;
|
| 601 | + TRACE_RET(ULONG, 8, glD3D7->glDD7->Release1());
|
744 | 602 | }
|
745 | 603 |
|
746 | 604 | HRESULT WINAPI glDirect3D2::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DDEVICE2 *lplpD3DDevice)
|
— | — | @@ -816,18 +674,9 @@ |
817 | 675 | {
|
818 | 676 | TRACE_ENTER(2,14,this,14,glD3D7);
|
819 | 677 | this->glD3D7 = glD3D7;
|
820 | | - refcount = 1;
|
821 | 678 | TRACE_EXIT(-1,0);
|
822 | 679 | }
|
823 | 680 |
|
824 | | -glDirect3D1::~glDirect3D1()
|
825 | | -{
|
826 | | - TRACE_ENTER(1,14,this);
|
827 | | - glD3D7->Release();
|
828 | | - glD3D7->glD3D1 = NULL;
|
829 | | - TRACE_EXIT(-1,0);
|
830 | | -}
|
831 | | -
|
832 | 681 | HRESULT WINAPI glDirect3D1::QueryInterface(REFIID riid, void** ppvObj)
|
833 | 682 | {
|
834 | 683 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
— | — | @@ -847,9 +696,7 @@ |
848 | 697 | {
|
849 | 698 | TRACE_ENTER(1,14,this);
|
850 | 699 | if(!this) TRACE_RET(ULONG,8,0);
|
851 | | - refcount++;
|
852 | | - TRACE_EXIT(8,refcount);
|
853 | | - return refcount;
|
| 700 | + TRACE_RET(ULONG, 8, glD3D7->glDD7->AddRef1());
|
854 | 701 | }
|
855 | 702 |
|
856 | 703 | ULONG WINAPI glDirect3D1::Release()
|
— | — | @@ -856,12 +703,7 @@ |
857 | 704 | {
|
858 | 705 | TRACE_ENTER(1,14,this);
|
859 | 706 | if(!this) TRACE_RET(ULONG,8,0);
|
860 | | - ULONG ret;
|
861 | | - refcount--;
|
862 | | - ret = refcount;
|
863 | | - if(refcount == 0) delete this;
|
864 | | - TRACE_EXIT(8,ret);
|
865 | | - return ret;
|
| 707 | + TRACE_RET(ULONG, 8, glD3D7->glDD7->Release1());
|
866 | 708 | }
|
867 | 709 |
|
868 | 710 | HRESULT WINAPI glDirect3D1::CreateLight(LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter)
|
Index: ddraw/glDirect3D.h |
— | — | @@ -27,17 +27,10 @@ |
28 | 28 | class glDirect3D2;
|
29 | 29 | class glDirect3D1;
|
30 | 30 |
|
31 | | -struct D3DDevice
|
32 | | -{
|
33 | | - char name[64];
|
34 | | - char devname[64];
|
35 | | -};
|
36 | | -
|
37 | 31 | class glDirect3D7 : public IDirect3D7
|
38 | 32 | {
|
39 | 33 | public:
|
40 | 34 | glDirect3D7(glDirectDraw7 *gl_DD7);
|
41 | | - virtual ~glDirect3D7();
|
42 | 35 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
43 | 36 | ULONG WINAPI AddRef();
|
44 | 37 | ULONG WINAPI Release();
|
— | — | @@ -51,15 +44,7 @@ |
52 | 45 | HRESULT WINAPI EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext);
|
53 | 46 | HRESULT WINAPI EvictManagedTextures();
|
54 | 47 | HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
|
55 | | - glDirect3D3 *glD3D3;
|
56 | | - glDirect3D2 *glD3D2;
|
57 | | - glDirect3D1 *glD3D1;
|
58 | 48 | glDirectDraw7 *glDD7;
|
59 | | -private:
|
60 | | - D3DDevice stored_devices[3];
|
61 | | - ULONG refcount;
|
62 | | - D3DDEVICEDESC7 d3ddesc;
|
63 | | - D3DDEVICEDESC d3ddesc3;
|
64 | 49 | };
|
65 | 50 |
|
66 | 51 | class glDirect3D3 : public IDirect3D3
|
— | — | @@ -66,7 +51,6 @@ |
67 | 52 | {
|
68 | 53 | public:
|
69 | 54 | glDirect3D3(glDirect3D7 *glD3D7);
|
70 | | - virtual ~glDirect3D3();
|
71 | 55 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
72 | 56 | ULONG WINAPI AddRef();
|
73 | 57 | ULONG WINAPI Release();
|
— | — | @@ -80,7 +64,6 @@ |
81 | 65 | HRESULT WINAPI EvictManagedTextures();
|
82 | 66 | HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
|
83 | 67 | private:
|
84 | | - ULONG refcount;
|
85 | 68 | glDirect3D7 *glD3D7;
|
86 | 69 | };
|
87 | 70 |
|
— | — | @@ -88,7 +71,6 @@ |
89 | 72 | {
|
90 | 73 | public:
|
91 | 74 | glDirect3D2(glDirect3D7 *glD3D7);
|
92 | | - virtual ~glDirect3D2();
|
93 | 75 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
94 | 76 | ULONG WINAPI AddRef();
|
95 | 77 | ULONG WINAPI Release();
|
— | — | @@ -99,7 +81,6 @@ |
100 | 82 | HRESULT WINAPI EnumDevices(LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg);
|
101 | 83 | HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
|
102 | 84 | private:
|
103 | | - ULONG refcount;
|
104 | 85 | glDirect3D7 *glD3D7;
|
105 | 86 | };
|
106 | 87 |
|
— | — | @@ -107,7 +88,6 @@ |
108 | 89 | {
|
109 | 90 | public:
|
110 | 91 | glDirect3D1(glDirect3D7 *glD3D7);
|
111 | | - virtual ~glDirect3D1();
|
112 | 92 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
113 | 93 | ULONG WINAPI AddRef();
|
114 | 94 | ULONG WINAPI Release();
|
— | — | @@ -118,7 +98,6 @@ |
119 | 99 | HRESULT WINAPI FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR);
|
120 | 100 | HRESULT WINAPI Initialize(REFIID lpREFIID);
|
121 | 101 | private:
|
122 | | - ULONG refcount;
|
123 | 102 | glDirect3D7 *glD3D7;
|
124 | 103 | };
|
125 | 104 |
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -2453,10 +2453,10 @@ |
2454 | 2454 | (*output)[i+dest].dvTV = input[i+start].dvTV;
|
2455 | 2455 | diffuse.r = diffuse.g = diffuse.b = diffuse.a = 0;
|
2456 | 2456 | specular.r = specular.g = specular.b = specular.a = 0;
|
2457 | | - ambient.r = (D3DVALUE)RGBA_GETRED(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0;
|
2458 | | - ambient.g = (D3DVALUE)RGBA_GETGREEN(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0;
|
2459 | | - ambient.b = (D3DVALUE)RGBA_GETBLUE(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0;
|
2460 | | - ambient.a = (D3DVALUE)RGBA_GETALPHA(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0;
|
| 2457 | + ambient.r = (D3DVALUE)RGBA_GETRED(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0f;
|
| 2458 | + ambient.g = (D3DVALUE)RGBA_GETGREEN(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0f;
|
| 2459 | + ambient.b = (D3DVALUE)RGBA_GETBLUE(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0f;
|
| 2460 | + ambient.a = (D3DVALUE)RGBA_GETALPHA(renderstate[D3DRENDERSTATE_AMBIENT]) / 255.0f;
|
2461 | 2461 | for(int l = 0; l < 8; l++)
|
2462 | 2462 | {
|
2463 | 2463 | if(gllights[l] != -1)
|
— | — | @@ -2496,15 +2496,15 @@ |
2497 | 2497 | length = len3(V);
|
2498 | 2498 | if((length > lights[gllights[l]]->light.dvRange) && (lights[gllights[l]]->light.dvRange != 0.0)) continue;
|
2499 | 2499 | normalize(V);
|
2500 | | - attenuation = 1.0/(lights[gllights[l]]->light.dvAttenuation0+(length*lights[gllights[l]]->light.dvAttenuation1)
|
| 2500 | + attenuation = 1.0f/(lights[gllights[l]]->light.dvAttenuation0+(length*lights[gllights[l]]->light.dvAttenuation1)
|
2501 | 2501 | +((length*length)*lights[gllights[l]]->light.dvAttenuation2));
|
2502 | | - NdotV = max(0.0,dot3((float*)&input[i+start].dvNX,V));
|
| 2502 | + NdotV = max(0.0f,dot3((float*)&input[i+start].dvNX,V));
|
2503 | 2503 | AddVec3(V,eye);
|
2504 | 2504 | normalize(V);
|
2505 | | - NdotHV = max(0.0,dot3((float*)&input[i+start].dvNX,V));
|
2506 | | - if(NdotV == 0.0) pf = 0.0;
|
2507 | | - else if(material.dvPower != 0.0) pf = pow(NdotHV,material.dvPower);
|
2508 | | - else pf = 0.0;
|
| 2505 | + NdotHV = max(0.0f,dot3((float*)&input[i+start].dvNX,V));
|
| 2506 | + if(NdotV == 0.0f) pf = 0.0f;
|
| 2507 | + else if(material.dvPower != 0.0f) pf = pow(NdotHV,material.dvPower);
|
| 2508 | + else pf = 0.0f;
|
2509 | 2509 | color1 = lights[gllights[l]]->light.dcvDiffuse;
|
2510 | 2510 | MulD3DCVFloat(&color1,NdotV*attenuation);
|
2511 | 2511 | AddD3DCV(&diffuse,&color1);
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -39,6 +39,22 @@ |
40 | 40 | 0,0,0,0,
|
41 | 41 | 0,0};
|
42 | 42 |
|
| 43 | +const D3DDevice d3ddevices[3] =
|
| 44 | +{
|
| 45 | + {
|
| 46 | + "Simulated RGB Rasterizer",
|
| 47 | + "DXGL RGB Rasterizer",
|
| 48 | + },
|
| 49 | + {
|
| 50 | + "DXGL Hardware Accelerator",
|
| 51 | + "DXGL D3D HAL",
|
| 52 | + },
|
| 53 | + {
|
| 54 | + "DXGL Hardware Accelerator with Transform and Lighting",
|
| 55 | + "DXGL D3D T&L HAL",
|
| 56 | + }
|
| 57 | +};
|
| 58 | +
|
43 | 59 | void DiscardDuplicateModes(DEVMODE **array, DWORD *count)
|
44 | 60 | {
|
45 | 61 | DEVMODE *newarray = (DEVMODE *)malloc(sizeof(DEVMODE)*(*count));
|
— | — | @@ -557,17 +573,26 @@ |
558 | 574 | glDirectDraw7::glDirectDraw7()
|
559 | 575 | {
|
560 | 576 | TRACE_ENTER(1,14,this);
|
561 | | - glDD1 = NULL;
|
562 | | - glDD2 = NULL;
|
563 | | - glDD4 = NULL;
|
564 | | - glD3D7 = NULL;
|
| 577 | + glDD1 = new glDirectDraw1(this);
|
| 578 | + glDD2 = new glDirectDraw2(this);
|
| 579 | + glDD4 = new glDirectDraw4(this);
|
| 580 | + glD3D7 = new glDirect3D7(this);
|
| 581 | + glD3D3 = new glDirect3D3(glD3D7);
|
| 582 | + glD3D2 = new glDirect3D2(glD3D7);
|
| 583 | + glD3D1 = new glDirect3D1(glD3D7);
|
565 | 584 | clippers = NULL;
|
566 | 585 | surfaces = NULL;
|
567 | 586 | initialized = false;
|
568 | 587 | devid.liDriverVersion.QuadPart = DXGLVERQWORD;
|
569 | | - refcount = 1;
|
| 588 | + refcount7 = 1;
|
| 589 | + refcount4 = 0;
|
| 590 | + refcount2 = 0;
|
| 591 | + refcount1 = 0;
|
570 | 592 | renderer = NULL;
|
571 | | - TRACE_EXIT(-1,0);
|
| 593 | + d3ddesc = d3ddesc_default;
|
| 594 | + d3ddesc3 = d3ddesc3_default;
|
| 595 | + memcpy(stored_devices, d3ddevices, 3 * sizeof(D3DDevice));
|
| 596 | + TRACE_EXIT(-1, 0);
|
572 | 597 | }
|
573 | 598 |
|
574 | 599 | glDirectDraw7::glDirectDraw7(GUID FAR* lpGUID, IUnknown FAR* pUnkOuter)
|
— | — | @@ -574,7 +599,14 @@ |
575 | 600 | {
|
576 | 601 | TRACE_ENTER(3,14,this,24,lpGUID,14,pUnkOuter);
|
577 | 602 | initialized = false;
|
578 | | - if(((ULONG_PTR)lpGUID > 2) && !IsReadablePointer(lpGUID))
|
| 603 | + glDD1 = new glDirectDraw1(this);
|
| 604 | + glDD2 = new glDirectDraw2(this);
|
| 605 | + glDD4 = new glDirectDraw4(this);
|
| 606 | + glD3D7 = new glDirect3D7(this);
|
| 607 | + glD3D3 = new glDirect3D3(glD3D7);
|
| 608 | + glD3D2 = new glDirect3D2(glD3D7);
|
| 609 | + glD3D1 = new glDirect3D1(glD3D7);
|
| 610 | + if (((ULONG_PTR)lpGUID > 2) && !IsReadablePointer(lpGUID))
|
579 | 611 | {
|
580 | 612 | error = DDERR_INVALIDPARAMS ;
|
581 | 613 | TRACE_EXIT(-1,0);
|
— | — | @@ -601,8 +633,11 @@ |
602 | 634 | devid.liDriverVersion.QuadPart = DXGLVERQWORD;
|
603 | 635 | renderer = NULL;
|
604 | 636 | error = glDirectDraw7::Initialize(lpGUID);
|
605 | | - refcount = 1;
|
606 | | - TRACE_EXIT(-1,0);
|
| 637 | + refcount7 = 1;
|
| 638 | + refcount4 = 0;
|
| 639 | + refcount2 = 0;
|
| 640 | + refcount1 = 0;
|
| 641 | + TRACE_EXIT(-1, 0);
|
607 | 642 | }
|
608 | 643 |
|
609 | 644 | glDirectDraw7::~glDirectDraw7()
|
— | — | @@ -637,6 +672,13 @@ |
638 | 673 | }
|
639 | 674 | renderer = NULL;
|
640 | 675 | }
|
| 676 | + if (glDD1) delete glDD1;
|
| 677 | + if (glDD2) delete glDD2;
|
| 678 | + if (glDD4) delete glDD4;
|
| 679 | + if (glD3D7) delete glD3D7;
|
| 680 | + if (glD3D3) delete glD3D3;
|
| 681 | + if (glD3D2) delete glD3D2;
|
| 682 | + if (glD3D1) delete glD3D1;
|
641 | 683 | TRACE_EXIT(-1,0);
|
642 | 684 | }
|
643 | 685 |
|
— | — | @@ -645,7 +687,7 @@ |
646 | 688 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
647 | 689 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
648 | 690 | if(!ppvObj) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
649 | | - if(riid == IID_IUnknown)
|
| 691 | + if((riid == IID_IUnknown) || (riid == IID_IDirectDraw7))
|
650 | 692 | {
|
651 | 693 | this->AddRef();
|
652 | 694 | *ppvObj = this;
|
— | — | @@ -655,72 +697,24 @@ |
656 | 698 | }
|
657 | 699 | if(riid == IID_IDirectDraw)
|
658 | 700 | {
|
659 | | - if(glDD1)
|
660 | | - {
|
661 | | - *ppvObj = glDD1;
|
662 | | - glDD1->AddRef();
|
663 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
664 | | - TRACE_EXIT(23,DD_OK);
|
665 | | - return DD_OK;
|
666 | | - }
|
667 | | - else
|
668 | | - {
|
669 | | - // Create an IDirectDraw1 interface
|
670 | | - this->AddRef();
|
671 | | - *ppvObj = new glDirectDraw1(this);
|
672 | | - glDD1 = (glDirectDraw1*)*ppvObj;
|
673 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
674 | | - TRACE_EXIT(23,DD_OK);
|
675 | | - return DD_OK;
|
676 | | - }
|
| 701 | + this->AddRef1();
|
| 702 | + *ppvObj = glDD1;
|
| 703 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 704 | + TRACE_EXIT(23,DD_OK);
|
| 705 | + return DD_OK;
|
677 | 706 | }
|
678 | 707 | if(riid == IID_IDirectDraw2)
|
679 | 708 | {
|
680 | | - if(glDD2)
|
681 | | - {
|
682 | | - *ppvObj = glDD2;
|
683 | | - glDD2->AddRef();
|
684 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
685 | | - TRACE_EXIT(23,DD_OK);
|
686 | | - return DD_OK;
|
687 | | - }
|
688 | | - else
|
689 | | - {
|
690 | | - // Create an IDirectDraw2 interface
|
691 | | - this->AddRef();
|
692 | | - *ppvObj = new glDirectDraw2(this);
|
693 | | - glDD2 = (glDirectDraw2*)*ppvObj;
|
694 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
695 | | - TRACE_EXIT(23,DD_OK);
|
696 | | - return DD_OK;
|
697 | | - }
|
| 709 | + this->AddRef2();
|
| 710 | + *ppvObj = glDD2;
|
| 711 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 712 | + TRACE_EXIT(23,DD_OK);
|
| 713 | + return DD_OK;
|
698 | 714 | }
|
699 | 715 | if(riid == IID_IDirectDraw4)
|
700 | 716 | {
|
701 | | - if(glDD4)
|
702 | | - {
|
703 | | - *ppvObj = glDD4;
|
704 | | - glDD4->AddRef();
|
705 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
706 | | - TRACE_EXIT(23,DD_OK);
|
707 | | - return DD_OK;
|
708 | | - }
|
709 | | - else
|
710 | | - {
|
711 | | - // Create an IDirectDraw4 interface
|
712 | | - this->AddRef();
|
713 | | - *ppvObj = new glDirectDraw4(this);
|
714 | | - glDD4 = (glDirectDraw4*)*ppvObj;
|
715 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
716 | | - TRACE_EXIT(23,DD_OK);
|
717 | | - return DD_OK;
|
718 | | - }
|
719 | | - }
|
720 | | - if(riid == IID_IDirectDraw7)
|
721 | | - {
|
722 | | - // Probably non-DX compliant, but give a copy of the IDirectDraw7 interface
|
723 | | - this->AddRef();
|
724 | | - *ppvObj = this;
|
| 717 | + this->AddRef4();
|
| 718 | + *ppvObj = glDD4;
|
725 | 719 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
726 | 720 | TRACE_EXIT(23,DD_OK);
|
727 | 721 | return DD_OK;
|
— | — | @@ -727,9 +721,8 @@ |
728 | 722 | }
|
729 | 723 | if(riid == IID_IDirect3D)
|
730 | 724 | {
|
731 | | - glDirect3D7 *tmp = new glDirect3D7(this);
|
732 | | - tmp->QueryInterface(IID_IDirect3D,ppvObj);
|
733 | | - tmp->Release();
|
| 725 | + this->AddRef1();
|
| 726 | + *ppvObj = glD3D1;
|
734 | 727 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
735 | 728 | TRACE_EXIT(23,DD_OK);
|
736 | 729 | return DD_OK;
|
— | — | @@ -736,9 +729,8 @@ |
737 | 730 | }
|
738 | 731 | if(riid == IID_IDirect3D2)
|
739 | 732 | {
|
740 | | - glDirect3D7 *tmp = new glDirect3D7(this);
|
741 | | - tmp->QueryInterface(IID_IDirect3D2,ppvObj);
|
742 | | - tmp->Release();
|
| 733 | + this->AddRef1();
|
| 734 | + *ppvObj = glD3D2;
|
743 | 735 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
744 | 736 | TRACE_EXIT(23,DD_OK);
|
745 | 737 | return DD_OK;
|
— | — | @@ -745,9 +737,8 @@ |
746 | 738 | }
|
747 | 739 | if(riid == IID_IDirect3D3)
|
748 | 740 | {
|
749 | | - glDirect3D7 *tmp = new glDirect3D7(this);
|
750 | | - tmp->QueryInterface(IID_IDirect3D3,ppvObj);
|
751 | | - tmp->Release();
|
| 741 | + this->AddRef1();
|
| 742 | + *ppvObj = glD3D3;
|
752 | 743 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
753 | 744 | TRACE_EXIT(23,DD_OK);
|
754 | 745 | return DD_OK;
|
— | — | @@ -754,7 +745,8 @@ |
755 | 746 | }
|
756 | 747 | if(riid == IID_IDirect3D7)
|
757 | 748 | {
|
758 | | - *ppvObj = new glDirect3D7(this);
|
| 749 | + this->AddRef();
|
| 750 | + *ppvObj = glD3D7;
|
759 | 751 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
760 | 752 | TRACE_EXIT(23,DD_OK);
|
761 | 753 | return DD_OK;
|
— | — | @@ -770,15 +762,15 @@ |
771 | 763 | ERR(DDERR_GENERIC);
|
772 | 764 | }*/
|
773 | 765 | TRACE_EXIT(23,E_NOINTERFACE);
|
774 | | - ERR(E_NOINTERFACE);
|
| 766 | + return E_NOINTERFACE;
|
775 | 767 | }
|
776 | 768 | ULONG WINAPI glDirectDraw7::AddRef()
|
777 | 769 | {
|
778 | 770 | TRACE_ENTER(1,14,this);
|
779 | 771 | if(!this) TRACE_RET(ULONG,8,0);
|
780 | | - refcount++;
|
781 | | - TRACE_EXIT(8,refcount);
|
782 | | - return refcount;
|
| 772 | + refcount7++;
|
| 773 | + TRACE_EXIT(8,refcount7);
|
| 774 | + return refcount7;
|
783 | 775 | }
|
784 | 776 | ULONG WINAPI glDirectDraw7::Release()
|
785 | 777 | {
|
— | — | @@ -785,13 +777,81 @@ |
786 | 778 | TRACE_ENTER(1,14,this);
|
787 | 779 | if(!this) TRACE_RET(ULONG,8,0);
|
788 | 780 | ULONG ret;
|
789 | | - refcount--;
|
790 | | - ret = refcount;
|
791 | | - if(refcount == 0)
|
| 781 | + if (refcount7 == 0) TRACE_RET(ULONG,8,0);
|
| 782 | + refcount7--;
|
| 783 | + ret = refcount7;
|
| 784 | + if((refcount7 == 0) && (refcount4 == 0) && (refcount2 == 0) && (refcount1 == 0))
|
792 | 785 | delete this;
|
793 | 786 | TRACE_EXIT(8,ret);
|
794 | 787 | return ret;
|
795 | 788 | }
|
| 789 | +
|
| 790 | +ULONG WINAPI glDirectDraw7::AddRef4()
|
| 791 | +{
|
| 792 | + TRACE_ENTER(1, 14, this);
|
| 793 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| 794 | + refcount4++;
|
| 795 | + TRACE_EXIT(8, refcount4);
|
| 796 | + return refcount4;
|
| 797 | +}
|
| 798 | +ULONG WINAPI glDirectDraw7::Release4()
|
| 799 | +{
|
| 800 | + TRACE_ENTER(1, 14, this);
|
| 801 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| 802 | + ULONG ret;
|
| 803 | + if (refcount4 == 0) TRACE_RET(ULONG, 8, 0);
|
| 804 | + refcount4--;
|
| 805 | + ret = refcount4;
|
| 806 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount2 == 0) && (refcount1 == 0))
|
| 807 | + delete this;
|
| 808 | + TRACE_EXIT(8, ret);
|
| 809 | + return ret;
|
| 810 | +}
|
| 811 | +
|
| 812 | +ULONG WINAPI glDirectDraw7::AddRef2()
|
| 813 | +{
|
| 814 | + TRACE_ENTER(1, 14, this);
|
| 815 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| 816 | + refcount2++;
|
| 817 | + TRACE_EXIT(8, refcount2);
|
| 818 | + return refcount2;
|
| 819 | +}
|
| 820 | +ULONG WINAPI glDirectDraw7::Release2()
|
| 821 | +{
|
| 822 | + TRACE_ENTER(1, 14, this);
|
| 823 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| 824 | + ULONG ret;
|
| 825 | + if (refcount2 == 0) TRACE_RET(ULONG, 8, 0);
|
| 826 | + refcount2--;
|
| 827 | + ret = refcount2;
|
| 828 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount2 == 0) && (refcount1 == 0))
|
| 829 | + delete this;
|
| 830 | + TRACE_EXIT(8, ret);
|
| 831 | + return ret;
|
| 832 | +}
|
| 833 | +
|
| 834 | +ULONG WINAPI glDirectDraw7::AddRef1()
|
| 835 | +{
|
| 836 | + TRACE_ENTER(1, 14, this);
|
| 837 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| 838 | + refcount1++;
|
| 839 | + TRACE_EXIT(8, refcount1);
|
| 840 | + return refcount1;
|
| 841 | +}
|
| 842 | +ULONG WINAPI glDirectDraw7::Release1()
|
| 843 | +{
|
| 844 | + TRACE_ENTER(1, 14, this);
|
| 845 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| 846 | + ULONG ret;
|
| 847 | + if (refcount1 == 0) TRACE_RET(ULONG, 8, 0);
|
| 848 | + refcount1--;
|
| 849 | + ret = refcount1;
|
| 850 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount2 == 0) && (refcount1 == 0))
|
| 851 | + delete this;
|
| 852 | + TRACE_EXIT(8, ret);
|
| 853 | + return ret;
|
| 854 | +}
|
| 855 | +
|
796 | 856 | HRESULT WINAPI glDirectDraw7::Compact()
|
797 | 857 | {
|
798 | 858 | TRACE_ENTER(1,14,this);
|
— | — | @@ -1277,10 +1337,6 @@ |
1278 | 1338 | if(initialized) TRACE_RET(HRESULT,23,DDERR_ALREADYINITIALIZED);
|
1279 | 1339 | devid = devid_default;
|
1280 | 1340 | primarylost = true;
|
1281 | | - glD3D7 = NULL;
|
1282 | | - glDD1 = NULL;
|
1283 | | - glDD2 = NULL;
|
1284 | | - glDD4 = NULL;
|
1285 | 1341 | renderer = NULL;
|
1286 | 1342 | primary = NULL;
|
1287 | 1343 | lastsync = false;
|
— | — | @@ -1908,16 +1964,8 @@ |
1909 | 1965 | {
|
1910 | 1966 | TRACE_ENTER(2,14,this,14,gl_DD7);
|
1911 | 1967 | glDD7 = gl_DD7;
|
1912 | | - refcount = 1;
|
1913 | 1968 | TRACE_EXIT(-1,0);
|
1914 | 1969 | }
|
1915 | | -glDirectDraw1::~glDirectDraw1()
|
1916 | | -{
|
1917 | | - TRACE_ENTER(1,14,this);
|
1918 | | - glDD7->glDD1 = NULL;
|
1919 | | - glDD7->Release();
|
1920 | | - TRACE_EXIT(-1,0);
|
1921 | | -}
|
1922 | 1970 | HRESULT WINAPI glDirectDraw1::QueryInterface(REFIID riid, void** ppvObj)
|
1923 | 1971 | {
|
1924 | 1972 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
— | — | @@ -1938,20 +1986,13 @@ |
1939 | 1987 | {
|
1940 | 1988 | TRACE_ENTER(1,14,this);
|
1941 | 1989 | if(!this) TRACE_RET(ULONG,8,0);
|
1942 | | - refcount++;
|
1943 | | - TRACE_EXIT(8,refcount);
|
1944 | | - return refcount;
|
| 1990 | + TRACE_RET(ULONG, 8, glDD7->AddRef1());
|
1945 | 1991 | }
|
1946 | 1992 | ULONG WINAPI glDirectDraw1::Release()
|
1947 | 1993 | {
|
1948 | 1994 | TRACE_ENTER(1,14,this);
|
1949 | 1995 | if(!this) TRACE_RET(ULONG,8,0);
|
1950 | | - ULONG ret;
|
1951 | | - refcount--;
|
1952 | | - ret = refcount;
|
1953 | | - if(refcount == 0) delete this;
|
1954 | | - TRACE_EXIT(8,ret);
|
1955 | | - return ret;
|
| 1996 | + TRACE_RET(ULONG, 8, glDD7->Release1());
|
1956 | 1997 | }
|
1957 | 1998 | HRESULT WINAPI glDirectDraw1::Compact()
|
1958 | 1999 | {
|
— | — | @@ -2117,16 +2158,8 @@ |
2118 | 2159 | {
|
2119 | 2160 | TRACE_ENTER(2,14,this,14,gl_DD7);
|
2120 | 2161 | glDD7 = gl_DD7;
|
2121 | | - refcount = 1;
|
2122 | 2162 | TRACE_EXIT(-1,0);
|
2123 | 2163 | }
|
2124 | | -glDirectDraw2::~glDirectDraw2()
|
2125 | | -{
|
2126 | | - TRACE_ENTER(1,14,this);
|
2127 | | - glDD7->glDD2 = NULL;
|
2128 | | - glDD7->Release();
|
2129 | | - TRACE_EXIT(-1,0);
|
2130 | | -}
|
2131 | 2164 | HRESULT WINAPI glDirectDraw2::QueryInterface(REFIID riid, void** ppvObj)
|
2132 | 2165 | {
|
2133 | 2166 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
— | — | @@ -2145,20 +2178,13 @@ |
2146 | 2179 | {
|
2147 | 2180 | TRACE_ENTER(1,14,this);
|
2148 | 2181 | if(!this) TRACE_RET(ULONG,8,0);
|
2149 | | - refcount++;
|
2150 | | - TRACE_EXIT(8,refcount);
|
2151 | | - return refcount;
|
| 2182 | + TRACE_RET(ULONG, 8, glDD7->AddRef2());
|
2152 | 2183 | }
|
2153 | 2184 | ULONG WINAPI glDirectDraw2::Release()
|
2154 | 2185 | {
|
2155 | 2186 | TRACE_ENTER(1,14,this);
|
2156 | 2187 | if(!this) TRACE_RET(ULONG,8,0);
|
2157 | | - ULONG ret;
|
2158 | | - refcount--;
|
2159 | | - ret = refcount;
|
2160 | | - if(refcount == 0) delete this;
|
2161 | | - TRACE_EXIT(8,ret);
|
2162 | | - return ret;
|
| 2188 | + TRACE_RET(ULONG, 8, glDD7->Release2());
|
2163 | 2189 | }
|
2164 | 2190 | HRESULT WINAPI glDirectDraw2::Compact()
|
2165 | 2191 | {
|
— | — | @@ -2349,16 +2375,8 @@ |
2350 | 2376 | {
|
2351 | 2377 | TRACE_ENTER(2,14,this,14,gl_DD7);
|
2352 | 2378 | glDD7 = gl_DD7;
|
2353 | | - refcount = 1;
|
2354 | 2379 | TRACE_EXIT(-1,0);
|
2355 | 2380 | }
|
2356 | | -glDirectDraw4::~glDirectDraw4()
|
2357 | | -{
|
2358 | | - TRACE_ENTER(1,14,this);
|
2359 | | - glDD7->glDD4 = NULL;
|
2360 | | - glDD7->Release();
|
2361 | | - TRACE_EXIT(-1,0);
|
2362 | | -}
|
2363 | 2381 | HRESULT WINAPI glDirectDraw4::QueryInterface(REFIID riid, void** ppvObj)
|
2364 | 2382 | {
|
2365 | 2383 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
— | — | @@ -2376,20 +2394,13 @@ |
2377 | 2395 | {
|
2378 | 2396 | TRACE_ENTER(1,14,this);
|
2379 | 2397 | if(!this) TRACE_RET(ULONG,8,0);
|
2380 | | - refcount++;
|
2381 | | - TRACE_EXIT(8,refcount);
|
2382 | | - return refcount;
|
| 2398 | + TRACE_RET(ULONG, 8, glDD7->AddRef());
|
2383 | 2399 | }
|
2384 | 2400 | ULONG WINAPI glDirectDraw4::Release()
|
2385 | 2401 | {
|
2386 | 2402 | TRACE_ENTER(1,14,this);
|
2387 | 2403 | if(!this) TRACE_RET(ULONG,8,0);
|
2388 | | - ULONG ret;
|
2389 | | - refcount--;
|
2390 | | - ret = refcount;
|
2391 | | - if(refcount == 0) delete this;
|
2392 | | - TRACE_EXIT(8,ret);
|
2393 | | - return ret;
|
| 2404 | + TRACE_RET(ULONG, 8, glDD7->Release());
|
2394 | 2405 | }
|
2395 | 2406 | HRESULT WINAPI glDirectDraw4::Compact()
|
2396 | 2407 | {
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -24,8 +24,17 @@ |
25 | 25 | class glDirectDrawSurface7;
|
26 | 26 | struct glDirectDrawClipper;
|
27 | 27 | class glDirect3D7;
|
| 28 | +class glDirect3D3;
|
| 29 | +class glDirect3D2;
|
| 30 | +class glDirect3D1;
|
28 | 31 | struct glRenderer;
|
29 | 32 |
|
| 33 | +struct D3DDevice
|
| 34 | +{
|
| 35 | + char name[64];
|
| 36 | + char devname[64];
|
| 37 | +};
|
| 38 | +
|
30 | 39 | class glDirectDraw1;
|
31 | 40 | class glDirectDraw2;
|
32 | 41 | class glDirectDraw4;
|
— | — | @@ -72,6 +81,12 @@ |
73 | 82 | HRESULT WINAPI EvaluateMode(DWORD dwFlags, DWORD *pSecondsUntilTimeout);
|
74 | 83 |
|
75 | 84 | // internal functions
|
| 85 | + ULONG WINAPI AddRef4();
|
| 86 | + ULONG WINAPI Release4();
|
| 87 | + ULONG WINAPI AddRef2();
|
| 88 | + ULONG WINAPI Release2();
|
| 89 | + ULONG WINAPI AddRef1();
|
| 90 | + ULONG WINAPI Release1();
|
76 | 91 | HRESULT CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface);
|
77 | 92 | HRESULT err() {return error;}
|
78 | 93 | void RemoveSurface(glDirectDrawSurface7 *surface);
|
— | — | @@ -95,9 +110,12 @@ |
96 | 111 | DDDEVICEIDENTIFIER2 devid;
|
97 | 112 | glRenderer *renderer;
|
98 | 113 | glDirectDrawSurface7 *tmpsurface;
|
| 114 | + D3DDevice stored_devices[3];
|
| 115 | + D3DDEVICEDESC7 d3ddesc;
|
| 116 | + D3DDEVICEDESC d3ddesc3;
|
99 | 117 | private:
|
100 | 118 | HRESULT error;
|
101 | | - ULONG refcount;
|
| 119 | + ULONG refcount7, refcount4, refcount2, refcount1;
|
102 | 120 | HWND hWnd;
|
103 | 121 | bool fullscreen;
|
104 | 122 | bool fpupreserve;
|
— | — | @@ -112,6 +130,9 @@ |
113 | 131 | DEVMODE oldmode;
|
114 | 132 | bool initialized;
|
115 | 133 | glDirect3D7 *glD3D7;
|
| 134 | + glDirect3D3 *glD3D3;
|
| 135 | + glDirect3D2 *glD3D2;
|
| 136 | + glDirect3D1 *glD3D1;
|
116 | 137 | DWORD timer;
|
117 | 138 | bool devwnd;
|
118 | 139 | };
|
— | — | @@ -120,7 +141,6 @@ |
121 | 142 | {
|
122 | 143 | public:
|
123 | 144 | glDirectDraw1(glDirectDraw7 *gl_DD7);
|
124 | | - virtual ~glDirectDraw1();
|
125 | 145 | // ddraw 1+ api
|
126 | 146 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
127 | 147 | ULONG WINAPI AddRef();
|
— | — | @@ -147,7 +167,6 @@ |
148 | 168 | HRESULT WINAPI WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent);
|
149 | 169 | HRESULT err() {return glDD7->err();}
|
150 | 170 | private:
|
151 | | - ULONG refcount;
|
152 | 171 | glDirectDraw7 *glDD7;
|
153 | 172 | };
|
154 | 173 |
|
— | — | @@ -155,7 +174,6 @@ |
156 | 175 | {
|
157 | 176 | public:
|
158 | 177 | glDirectDraw2(glDirectDraw7 *gl_DD7);
|
159 | | - virtual ~glDirectDraw2();
|
160 | 178 | // ddraw 1+ api
|
161 | 179 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
162 | 180 | ULONG WINAPI AddRef();
|
— | — | @@ -185,7 +203,6 @@ |
186 | 204 |
|
187 | 205 | HRESULT err() {return glDD7->err();}
|
188 | 206 | private:
|
189 | | - ULONG refcount;
|
190 | 207 | glDirectDraw7 *glDD7;
|
191 | 208 | };
|
192 | 209 | class glDirectDraw4 : public IDirectDraw4
|
— | — | @@ -192,7 +209,6 @@ |
193 | 210 | {
|
194 | 211 | public:
|
195 | 212 | glDirectDraw4(glDirectDraw7 *gl_DD7);
|
196 | | - virtual ~glDirectDraw4();
|
197 | 213 | // ddraw 1+ api
|
198 | 214 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
199 | 215 | ULONG WINAPI AddRef();
|
— | — | @@ -227,7 +243,6 @@ |
228 | 244 |
|
229 | 245 | HRESULT err() {return glDD7->err();}
|
230 | 246 | private:
|
231 | | - ULONG refcount;
|
232 | 247 | glDirectDraw7 *glDD7;
|
233 | 248 | };
|
234 | 249 |
|