Index: ddraw/ddraw.cpp |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | glDirectDraw7 *myddraw7;
|
109 | 109 | glDirectDraw1 *myddraw;
|
110 | 110 | HRESULT error;
|
111 | | - myddraw7 = new glDirectDraw7(lpGUID,lplpDD,pUnkOuter);
|
| 111 | + myddraw7 = new glDirectDraw7(lpGUID,pUnkOuter);
|
112 | 112 | error = myddraw7->err();
|
113 | 113 | if(error != DD_OK)
|
114 | 114 | {
|
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | glDirectDraw7 *myddraw;
|
132 | 132 | HRESULT error;
|
133 | 133 | if(iid != IID_IDirectDraw7) ERR(DDERR_UNSUPPORTED);
|
134 | | - myddraw = new glDirectDraw7(lpGUID,(LPDIRECTDRAW FAR *)lplpDD,pUnkOuter);
|
| 134 | + myddraw = new glDirectDraw7(lpGUID,pUnkOuter);
|
135 | 135 | error = myddraw->err();
|
136 | 136 | if(error != DD_OK)
|
137 | 137 | {
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -542,56 +542,23 @@ |
543 | 543 | }
|
544 | 544 |
|
545 | 545 | // DDRAW7/common routines
|
546 | | -glDirectDraw7::glDirectDraw7(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter)
|
| 546 | +
|
| 547 | +glDirectDraw7::glDirectDraw7()
|
547 | 548 | {
|
548 | | - hDC = NULL;
|
549 | | - hRC = NULL;
|
550 | | - hRenderWnd = NULL;
|
551 | | - primary = NULL;
|
552 | | - fullscreen = false;
|
553 | | - fpupreserve = false;
|
554 | | - fpusetup = false;
|
555 | | - threadsafe = false;
|
556 | | - nowindowchanges = false;
|
557 | | - timer = timeGetTime();
|
558 | | - ZeroMemory(&oldmode,sizeof(DEVMODE));
|
559 | | - surfaces = (glDirectDrawSurface7 **)malloc(1024*sizeof(glDirectDrawSurface7 *));
|
560 | | - if(!surfaces)
|
| 549 | + initialized = false;
|
| 550 | + refcount = 1;
|
| 551 | +}
|
| 552 | +
|
| 553 | +glDirectDraw7::glDirectDraw7(GUID FAR* lpGUID, IUnknown FAR* pUnkOuter)
|
| 554 | +{
|
| 555 | + initialized = false;
|
| 556 | + if(pUnkOuter)
|
561 | 557 | {
|
562 | | - error = DDERR_OUTOFMEMORY;
|
| 558 | + error = DDERR_INVALIDPARAMS ;
|
563 | 559 | return;
|
564 | 560 | }
|
565 | | - ZeroMemory(surfaces,1024*sizeof(glDirectDrawSurface7 *));
|
566 | | - surfacecount = 0;
|
567 | | - surfacecountmax = 1024;
|
568 | | - clippers = (glDirectDrawClipper **)malloc(1024*sizeof(glDirectDrawClipper *));
|
569 | | - if(!clippers)
|
570 | | - {
|
571 | | - error = DDERR_OUTOFMEMORY;
|
572 | | - return;
|
573 | | - }
|
574 | | - ZeroMemory(clippers,1024*sizeof(glDirectDrawClipper *));
|
575 | | - clippercount = 0;
|
576 | | - clippercountmax = 1024;
|
577 | | - if(directdraw_created) error = DDERR_DIRECTDRAWALREADYCREATED;
|
578 | | - bool useguid = false;
|
579 | | - if(pUnkOuter) error = DDERR_INVALIDPARAMS ;
|
580 | | - switch((INT_PTR)lpGUID)
|
581 | | - {
|
582 | | - case NULL:
|
583 | | - break;
|
584 | | - case DDCREATE_EMULATIONONLY:
|
585 | | - DEBUG("DDRAW software emulation not supported, using OpenGL.\n");
|
586 | | - break;
|
587 | | - case DDCREATE_HARDWAREONLY:
|
588 | | - DEBUG("DDCREATE_HARDWAREONLY unnecessarily called.\n");
|
589 | | - break;
|
590 | | - default:
|
591 | | - useguid = true;
|
592 | | - FIXME("Display GUIDs not yet supported, using primary.\n");
|
593 | | - }
|
| 561 | + error = glDirectDraw7::Initialize(lpGUID);
|
594 | 562 | refcount = 1;
|
595 | | - error = 0;
|
596 | 563 | }
|
597 | 564 |
|
598 | 565 | glDirectDraw7::~glDirectDraw7()
|
— | — | @@ -869,8 +836,45 @@ |
870 | 837 | }
|
871 | 838 | HRESULT WINAPI glDirectDraw7::Initialize(GUID FAR *lpGUID)
|
872 | 839 | {
|
873 | | - FIXME("IDirectDraw::Initialize: stub\n");
|
874 | | - ERR(DDERR_DIRECTDRAWALREADYCREATED);
|
| 840 | + if(initialized) return DDERR_ALREADYINITIALIZED;
|
| 841 | + hDC = NULL;
|
| 842 | + hRC = NULL;
|
| 843 | + hRenderWnd = NULL;
|
| 844 | + primary = NULL;
|
| 845 | + fullscreen = false;
|
| 846 | + fpupreserve = false;
|
| 847 | + fpusetup = false;
|
| 848 | + threadsafe = false;
|
| 849 | + nowindowchanges = false;
|
| 850 | + timer = timeGetTime();
|
| 851 | + ZeroMemory(&oldmode,sizeof(DEVMODE));
|
| 852 | + surfaces = (glDirectDrawSurface7 **)malloc(1024*sizeof(glDirectDrawSurface7 *));
|
| 853 | + if(!surfaces) return DDERR_OUTOFMEMORY;
|
| 854 | + ZeroMemory(surfaces,1024*sizeof(glDirectDrawSurface7 *));
|
| 855 | + surfacecount = 0;
|
| 856 | + surfacecountmax = 1024;
|
| 857 | + clippers = (glDirectDrawClipper **)malloc(1024*sizeof(glDirectDrawClipper *));
|
| 858 | + if(!clippers) return DDERR_OUTOFMEMORY;
|
| 859 | + ZeroMemory(clippers,1024*sizeof(glDirectDrawClipper *));
|
| 860 | + clippercount = 0;
|
| 861 | + clippercountmax = 1024;
|
| 862 | + if(directdraw_created) error = DDERR_DIRECTDRAWALREADYCREATED;
|
| 863 | + bool useguid = false;
|
| 864 | + switch((INT_PTR)lpGUID)
|
| 865 | + {
|
| 866 | + case NULL:
|
| 867 | + break;
|
| 868 | + case DDCREATE_EMULATIONONLY:
|
| 869 | + DEBUG("DDRAW software emulation not supported, using OpenGL.\n");
|
| 870 | + break;
|
| 871 | + case DDCREATE_HARDWAREONLY:
|
| 872 | + DEBUG("DDCREATE_HARDWAREONLY unnecessarily called.\n");
|
| 873 | + break;
|
| 874 | + default:
|
| 875 | + useguid = true;
|
| 876 | + FIXME("Display GUIDs not yet supported, using primary.\n");
|
| 877 | + }
|
| 878 | + return 0;
|
875 | 879 | }
|
876 | 880 | HRESULT WINAPI glDirectDraw7::RestoreDisplayMode()
|
877 | 881 | {
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -39,7 +39,8 @@ |
40 | 40 | class glDirectDraw7 : public IDirectDraw7
|
41 | 41 | {
|
42 | 42 | public:
|
43 | | - glDirectDraw7(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter);
|
| 43 | + glDirectDraw7();
|
| 44 | + glDirectDraw7(GUID FAR* lpGUID, IUnknown FAR* pUnkOuter);
|
44 | 45 | virtual ~glDirectDraw7();
|
45 | 46 |
|
46 | 47 | // ddraw 1+ api
|
— | — | @@ -115,6 +116,7 @@ |
116 | 117 | int clippercount, clippercountmax;
|
117 | 118 | GLCAPS gl_caps;
|
118 | 119 | DEVMODE oldmode;
|
| 120 | + bool initialized;
|
119 | 121 | };
|
120 | 122 |
|
121 | 123 | class glDirectDraw1 : public IDirectDraw
|