Index: ddraw/ddraw.cpp |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | }
|
123 | 123 | HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
|
124 | 124 | {
|
125 | | - *lplpDDClipper = new glDirectDrawClipper(dwFlags,lplpDDClipper,pUnkOuter,NULL);
|
| 125 | + *lplpDDClipper = new glDirectDrawClipper(dwFlags,NULL);
|
126 | 126 | return DD_OK;
|
127 | 127 | }
|
128 | 128 | HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter)
|
— | — | @@ -235,7 +235,8 @@ |
236 | 236 | }
|
237 | 237 | HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
238 | 238 | {
|
239 | | - if(rclsid != CLSID_DirectDraw) return CLASS_E_CLASSNOTAVAILABLE;
|
| 239 | + if((rclsid != CLSID_DirectDraw) && (rclsid != CLSID_DirectDraw7) &&
|
| 240 | + (rclsid != CLSID_DirectDrawClipper)) return CLASS_E_CLASSNOTAVAILABLE;
|
240 | 241 | glClassFactory *factory = new glClassFactory;
|
241 | 242 | if(factory == NULL) return E_OUTOFMEMORY;
|
242 | 243 | HRESULT result = factory->QueryInterface(riid,ppv);
|
Index: ddraw/glClassFactory.cpp |
— | — | @@ -17,7 +17,11 @@ |
18 | 18 |
|
19 | 19 | #include "common.h"
|
20 | 20 | #include "glClassFactory.h"
|
| 21 | +#include "glDirectDraw.h"
|
| 22 | +#include "glDirectDrawClipper.h"
|
21 | 23 |
|
| 24 | +LONG locks;
|
| 25 | +
|
22 | 26 | ULONG WINAPI glClassFactory::AddRef()
|
23 | 27 | {
|
24 | 28 | refcount++;
|
— | — | @@ -34,17 +38,55 @@ |
35 | 39 |
|
36 | 40 | HRESULT WINAPI glClassFactory::QueryInterface(REFIID riid, void** ppvObj)
|
37 | 41 | {
|
38 | | - FIXME("glClassFactory::QueryInterface: stub");
|
39 | | - return E_FAIL;
|
| 42 | + if((riid == IID_IUnknown) || (riid == IID_IClassFactory))
|
| 43 | + {
|
| 44 | + *ppvObj = this;
|
| 45 | + }
|
| 46 | + else
|
| 47 | + {
|
| 48 | + *ppvObj = NULL;
|
| 49 | + return E_NOINTERFACE;
|
| 50 | + }
|
| 51 | + return S_OK;
|
40 | 52 | }
|
41 | 53 | HRESULT WINAPI glClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
|
42 | 54 | {
|
| 55 | + glDirectDraw7 *glDD7;
|
| 56 | + if(pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
|
| 57 | + if(riid == IID_IDirectDraw)
|
| 58 | + {
|
| 59 | + glDD7 = new glDirectDraw7;
|
| 60 | + *ppvObject = new glDirectDraw1(glDD7);
|
| 61 | + return S_OK;
|
| 62 | + }
|
| 63 | + if(riid == IID_IDirectDraw2)
|
| 64 | + {
|
| 65 | + glDD7 = new glDirectDraw7;
|
| 66 | + *ppvObject = new glDirectDraw2(glDD7);
|
| 67 | + return S_OK;
|
| 68 | + }
|
| 69 | + if(riid == IID_IDirectDraw4)
|
| 70 | + {
|
| 71 | + glDD7 = new glDirectDraw7;
|
| 72 | + *ppvObject = new glDirectDraw4(glDD7);
|
| 73 | + return S_OK;
|
| 74 | + }
|
| 75 | + if(riid == IID_IDirectDraw7)
|
| 76 | + {
|
| 77 | + *ppvObject = new glDirectDraw7();
|
| 78 | + return S_OK;
|
| 79 | + }
|
| 80 | + if(riid == IID_IDirectDrawClipper)
|
| 81 | + {
|
| 82 | + *ppvObject = new glDirectDrawClipper();
|
| 83 | + }
|
43 | 84 | FIXME("glClassFactory::CreateInterface: stub");
|
44 | | - return E_FAIL;
|
| 85 | + return E_NOINTERFACE;
|
45 | 86 | }
|
46 | 87 | HRESULT WINAPI glClassFactory::LockServer(BOOL fLock)
|
47 | 88 | {
|
48 | | - FIXME("glClassFactory::LockServer: stub");
|
49 | | - return E_FAIL;
|
| 89 | + if(fLock) InterlockedIncrement(&locks);
|
| 90 | + else InterlockedDecrement(&locks);
|
| 91 | + return S_OK;
|
50 | 92 | }
|
51 | 93 |
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -672,7 +672,7 @@ |
673 | 673 | ZeroMemory(&clippers[clippercountmax],1024*sizeof(glDirectDrawClipper *));
|
674 | 674 | clippercountmax += 1024;
|
675 | 675 | }
|
676 | | - clippers[clippercount-1] = new glDirectDrawClipper(dwFlags,lplpDDClipper,pUnkOuter,this);
|
| 676 | + clippers[clippercount-1] = new glDirectDrawClipper(dwFlags,this);
|
677 | 677 | *lplpDDClipper = clippers[clippercount-1];
|
678 | 678 | return DD_OK;
|
679 | 679 | }
|
— | — | @@ -874,7 +874,8 @@ |
875 | 875 | useguid = true;
|
876 | 876 | FIXME("Display GUIDs not yet supported, using primary.\n");
|
877 | 877 | }
|
878 | | - return 0;
|
| 878 | + initialized = true;
|
| 879 | + return DD_OK;
|
879 | 880 | }
|
880 | 881 | HRESULT WINAPI glDirectDraw7::RestoreDisplayMode()
|
881 | 882 | {
|
Index: ddraw/glDirectDrawClipper.cpp |
— | — | @@ -18,20 +18,30 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "glDirectDrawClipper.h"
|
21 | 21 |
|
22 | | -glDirectDrawClipper::glDirectDrawClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter, glDirectDraw7 *parent)
|
| 22 | +glDirectDrawClipper::glDirectDrawClipper()
|
23 | 23 | {
|
24 | | - glDD7 = parent;
|
25 | | - if(glDD7) hasparent = true;
|
26 | | - else hasparent = false;
|
27 | | - hWnd = NULL;
|
| 24 | + initialized = false;
|
28 | 25 | refcount = 1;
|
29 | 26 | }
|
| 27 | +
|
| 28 | +glDirectDrawClipper::glDirectDrawClipper(DWORD dwFlags, glDirectDraw7 *parent)
|
| 29 | +{
|
| 30 | + initialized = false;
|
| 31 | + refcount = 1;
|
| 32 | + Initialize((LPDIRECTDRAW)parent,dwFlags);
|
| 33 | +}
|
30 | 34 | glDirectDrawClipper::~glDirectDrawClipper()
|
31 | 35 | {
|
32 | 36 | }
|
33 | 37 | HRESULT WINAPI glDirectDrawClipper::QueryInterface(REFIID riid, LPVOID* obp)
|
34 | 38 | {
|
35 | | - ERR(E_NOINTERFACE);
|
| 39 | + if(riid == IID_IDirectDrawClipper)
|
| 40 | + {
|
| 41 | + *obp = this;
|
| 42 | + this->AddRef();
|
| 43 | + return S_OK;
|
| 44 | + }
|
| 45 | + return E_NOINTERFACE;
|
36 | 46 | }
|
37 | 47 | ULONG WINAPI glDirectDrawClipper::AddRef()
|
38 | 48 | {
|
— | — | @@ -54,13 +64,19 @@ |
55 | 65 | HRESULT WINAPI glDirectDrawClipper::GetHWnd(HWND FAR *lphWnd)
|
56 | 66 | {
|
57 | 67 | *lphWnd = hWnd;
|
58 | | - if(!hWnd) ERR(DDERR_INVALIDOBJECT);
|
| 68 | + if(!hWnd) return DDERR_INVALIDOBJECT;
|
59 | 69 | return DD_OK;
|
60 | 70 | }
|
61 | 71 | HRESULT WINAPI glDirectDrawClipper::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags)
|
62 | 72 | {
|
63 | | - FIXME("IDirectDrawClipper::Initialize: stub");
|
64 | | - ERR(DDERR_GENERIC);
|
| 73 | + if(initialized) return DDERR_ALREADYINITIALIZED;
|
| 74 | + glDD7 = (glDirectDraw7*)lpDD;
|
| 75 | + if(glDD7) hasparent = true;
|
| 76 | + else hasparent = false;
|
| 77 | + hWnd = NULL;
|
| 78 | + refcount = 1;
|
| 79 | + initialized = true;
|
| 80 | + return DD_OK;
|
65 | 81 | }
|
66 | 82 | HRESULT WINAPI glDirectDrawClipper::IsClipListChanged(BOOL FAR *lpbChanged)
|
67 | 83 | {
|
Index: ddraw/glDirectDrawClipper.h |
— | — | @@ -24,7 +24,8 @@ |
25 | 25 | class glDirectDrawClipper : public IDirectDrawClipper
|
26 | 26 | {
|
27 | 27 | public:
|
28 | | - glDirectDrawClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter, glDirectDraw7 *parent);
|
| 28 | + glDirectDrawClipper();
|
| 29 | + glDirectDrawClipper(DWORD dwFlags, glDirectDraw7 *parent);
|
29 | 30 | ~glDirectDrawClipper();
|
30 | 31 | // ddraw api
|
31 | 32 | HRESULT WINAPI QueryInterface(REFIID riid, LPVOID* obp);
|
— | — | @@ -40,6 +41,7 @@ |
41 | 42 | ULONG refcount;
|
42 | 43 | glDirectDraw7 *glDD7;
|
43 | 44 | bool hasparent;
|
| 45 | + bool initialized;
|
44 | 46 | HWND hWnd;
|
45 | 47 | };
|
46 | 48 | #endif //_GLDIRECTDRAWCLIPPER_H |
\ No newline at end of file |