DXGL r496 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r495‎ | r496 | r497 >
Date:14:40, 23 August 2014
Author:admin
Status:new
Tags:
Comment:
Convert glDirect3DViewport3, 2, and 1 to structs and C linkage.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirect3DLight.h (modified) (history)
  • /ddraw/glDirect3DViewport.cpp (modified) (history)
  • /ddraw/glDirect3DViewport.h (modified) (history)
  • /ddraw/glDirectDrawPalette.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -371,10 +371,10 @@
372372 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
373373 if(!lplpD3DViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
374374 if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
375 - *lplpD3DViewport = new glDirect3DViewport3();
 375+ HRESULT ret = glDirect3DViewport3_Create(lplpD3DViewport);
376376 TRACE_VAR("*lplpD3DViewport",14,*lplpD3DViewport);
377 - TRACE_EXIT(23,D3D_OK);
378 - return D3D_OK;
 377+ TRACE_EXIT(23,ret);
 378+ return ret;
379379 }
380380 HRESULT WINAPI glDirect3D7::EnumDevices(LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg)
381381 {
Index: ddraw/glDirect3DDevice.cpp
@@ -390,9 +390,9 @@
391391 {
392392 if(viewports[i])
393393 {
394 - viewports[i]->SetDevice(NULL);
395 - viewports[i]->SetCurrent(false);
396 - viewports[i]->Release();
 394+ glDirect3DViewport3_SetDevice(viewports[i], NULL);
 395+ glDirect3DViewport3_SetCurrent(viewports[i], false);
 396+ glDirect3DViewport3_Release(viewports[i]);
397397 }
398398 }
399399 for(int i = 0; i < texturecount; i++)
@@ -1915,10 +1915,10 @@
19161916 if(!lpDirect3DViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19171917 for(int i = 0; i < maxviewports; i++)
19181918 {
1919 - if(viewports[i] == lpDirect3DViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 1919+ if(viewports[i] == (glDirect3DViewport3*)lpDirect3DViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19201920 }
19211921 viewports[viewportcount] = (glDirect3DViewport3*)lpDirect3DViewport;
1922 - viewports[viewportcount]->AddRef();
 1922+ glDirect3DViewport3_AddRef(viewports[viewportcount]);
19231923 viewportcount++;
19241924 if(viewportcount >= maxviewports)
19251925 {
@@ -1928,13 +1928,13 @@
19291929 if(!newviewport)
19301930 {
19311931 viewports--;
1932 - viewports[viewportcount]->Release();
 1932+ glDirect3DViewport3_Release(viewports[viewportcount]);
19331933 viewports[viewportcount] = NULL;
19341934 maxviewports -= 32;
19351935 TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
19361936 }
19371937 }
1938 - viewports[viewportcount-1]->SetDevice(this);
 1938+ glDirect3DViewport3_SetDevice(viewports[viewportcount-1],this);
19391939 TRACE_EXIT(23,D3D_OK);
19401940 return D3D_OK;
19411941 }
@@ -1946,11 +1946,11 @@
19471947 if(!lpDirect3DViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19481948 for(int i = 0; i < maxviewports; i++)
19491949 {
1950 - if(viewports[i] == lpDirect3DViewport)
 1950+ if(viewports[i] == (glDirect3DViewport3*)lpDirect3DViewport)
19511951 {
1952 - viewports[i]->SetCurrent(false);
1953 - viewports[i]->SetDevice(NULL);
1954 - viewports[i]->Release();
 1952+ glDirect3DViewport3_SetCurrent(viewports[i],false);
 1953+ glDirect3DViewport3_SetDevice(viewports[i],NULL);
 1954+ glDirect3DViewport3_Release(viewports[i]);
19551955 if(currentviewport == viewports[i]) currentviewport = NULL;
19561956 viewports[i] = NULL;
19571957 TRACE_EXIT(23,D3D_OK);
@@ -1978,8 +1978,8 @@
19791979 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
19801980 if(!lplpd3dViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19811981 if(!currentviewport) TRACE_RET(HRESULT,23,D3DERR_NOCURRENTVIEWPORT);
1982 - *lplpd3dViewport = currentviewport;
1983 - currentviewport->AddRef();
 1982+ *lplpd3dViewport = (LPDIRECT3DVIEWPORT3)currentviewport;
 1983+ glDirect3DViewport3_AddRef(currentviewport);
19841984 TRACE_VAR("*lplpd3dViewport",14,*lplpd3dViewport);
19851985 TRACE_EXIT(23,D3D_OK);
19861986 return D3D_OK;
@@ -1990,12 +1990,12 @@
19911991 TRACE_ENTER(2,14,this,14,lpd3dViewport);
19921992 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
19931993 if(!lpd3dViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
1994 - if(currentviewport == lpd3dViewport) TRACE_RET(HRESULT,23,D3D_OK);
 1994+ if(currentviewport == (glDirect3DViewport3*)lpd3dViewport) TRACE_RET(HRESULT,23,D3D_OK);
19951995 for(int i = 0; i < maxviewports; i++)
19961996 {
1997 - if(lpd3dViewport == viewports[i])
 1997+ if(lpd3dViewport == (LPDIRECT3DVIEWPORT3)viewports[i])
19981998 {
1999 - viewports[i]->SetCurrent(true);
 1999+ glDirect3DViewport3_SetCurrent(viewports[i],true);
20002000 currentviewport = (glDirect3DViewport3*)lpd3dViewport;
20012001 TRACE_EXIT(23,D3D_OK);
20022002 return D3D_OK;
@@ -3331,8 +3331,8 @@
33323332 if(!lpDirect3DViewport2) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
33333333 glDirect3DViewport3 *glD3DV3;
33343334 lpDirect3DViewport2->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
3335 - HRESULT ret = glD3DDev7->AddViewport(glD3DV3);
3336 - glD3DV3->Release();
 3335+ HRESULT ret = glD3DDev7->AddViewport((LPDIRECT3DVIEWPORT3)glD3DV3);
 3336+ glDirect3DViewport3_Release(glD3DV3);
33373337 TRACE_EXIT(23,ret);
33383338 return ret;
33393339 }
@@ -3381,10 +3381,11 @@
33823382 {
33833383 TRACE_ENTER(2,14,this,14,lpDirect3DViewport2);
33843384 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 3385+ if (!lpDirect3DViewport2) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
33853386 glDirect3DViewport3 *glD3DV3;
33863387 lpDirect3DViewport2->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
3387 - HRESULT ret = glD3DDev7->DeleteViewport(glD3DV3);
3388 - glD3DV3->Release();
 3388+ HRESULT ret = glD3DDev7->DeleteViewport((LPDIRECT3DVIEWPORT3)glD3DV3);
 3389+ glDirect3DViewport3_Release(glD3DV3);
33893390 TRACE_EXIT(23,ret);
33903391 return ret;
33913392 }
@@ -3470,8 +3471,8 @@
34713472 glDirect3DViewport3 *glD3DV3;
34723473 HRESULT ret = glD3DDev7->GetCurrentViewport((LPDIRECT3DVIEWPORT3*)&glD3DV3);
34733474 if(!glD3DV3) TRACE_RET(HRESULT,23,ret);
3474 - glD3DV3->QueryInterface(IID_IDirect3DViewport2,(void**)lplpd3dViewport2);
3475 - glD3DV3->Release();
 3475+ glDirect3DViewport3_QueryInterface(glD3DV3,IID_IDirect3DViewport2,(void**)lplpd3dViewport2);
 3476+ glDirect3DViewport3_Release(glD3DV3);
34763477 TRACE_VAR("*lplpd3dViewport2",14,*lplpd3dViewport2);
34773478 TRACE_EXIT(23,ret);
34783479 return ret;
@@ -3572,8 +3573,8 @@
35733574 if(!lpd3dViewport2) TRACE_RET(HRESULT,23,glD3DDev7->SetCurrentViewport(NULL));
35743575 glDirect3DViewport3 *glD3DV3;
35753576 lpd3dViewport2->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
3576 - HRESULT ret = glD3DDev7->SetCurrentViewport(glD3DV3);
3577 - glD3DV3->Release();
 3577+ HRESULT ret = glD3DDev7->SetCurrentViewport((LPDIRECT3DVIEWPORT3)glD3DV3);
 3578+ glDirect3DViewport3_Release(glD3DV3);
35783579 TRACE_EXIT(23,ret);
35793580 return ret;
35803581 }
@@ -3681,8 +3682,8 @@
36823683 if(!lpDirect3DViewport) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
36833684 glDirect3DViewport3 *glD3DV3;
36843685 lpDirect3DViewport->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
3685 - HRESULT ret = glD3DDev7->AddViewport(glD3DV3);
3686 - glD3DV3->Release();
 3686+ HRESULT ret = glD3DDev7->AddViewport((LPDIRECT3DVIEWPORT3)glD3DV3);
 3687+ glDirect3DViewport3_Release(glD3DV3);
36873688 TRACE_EXIT(23,ret);
36883689 return ret;
36893690 }
@@ -3715,10 +3716,11 @@
37163717 {
37173718 TRACE_ENTER(2,14,this,14,lpDirect3DViewport);
37183719 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 3720+ if (!lpDirect3DViewport) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
37193721 glDirect3DViewport3 *glD3DV3;
37203722 lpDirect3DViewport->QueryInterface(IID_IDirect3DViewport3,(void**)&glD3DV3);
3721 - HRESULT ret = glD3DDev7->DeleteViewport(glD3DV3);
3722 - glD3DV3->Release();
 3723+ HRESULT ret = glD3DDev7->DeleteViewport((LPDIRECT3DVIEWPORT3)glD3DV3);
 3724+ glDirect3DViewport3_Release(glD3DV3);
37233725 TRACE_EXIT(23,ret);
37243726 return ret;
37253727 }
Index: ddraw/glDirect3DDevice.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2013 William Feely
 3+// Copyright (C) 2011-2014 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -63,7 +63,7 @@
6464 class glDirect3DLight;
6565 class glDirectDrawSurface7;
6666 class glDirect3DMaterial3;
67 -class glDirect3DViewport3;
 67+struct glDirect3DViewport3;
6868 class glDirect3DDevice3;
6969 class glDirect3DDevice2;
7070 class glDirect3DDevice1;
Index: ddraw/glDirect3DLight.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012 William Feely
 3+// Copyright (C) 2012-2014 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -19,7 +19,7 @@
2020 #ifndef __GLDIRECT3DLIGHT_H
2121 #define __GLDIRECT3DLIGHT_H
2222
23 -class glDirect3DViewport3;
 23+struct glDirect3DViewport3;
2424 class glDirect3DLight : public IDirect3DLight
2525 {
2626 public:
Index: ddraw/glDirect3DViewport.cpp
@@ -27,6 +27,8 @@
2828 #include "glDirect3DMaterial.h"
2929 #include "glDirect3DViewport.h"
3030
 31+extern "C" {
 32+
3133 inline D3DCOLOR d3dcvtod3dcolor(D3DCOLORVALUE value)
3234 {
3335 int r = (int)(value.r * 255);
@@ -36,44 +38,39 @@
3739 return b|(g<<8)|(r<<16)|(a<<24);
3840 }
3941
40 -glDirect3DViewport3::glDirect3DViewport3()
 42+HRESULT glDirect3DViewport3_Create(LPDIRECT3DVIEWPORT3 *viewport)
4143 {
42 - TRACE_ENTER(1,14,this);
43 - background = 0;
44 - ZeroMemory(&viewport,sizeof(D3DVIEWPORT2));
45 - viewport.dwSize = sizeof(D3DVIEWPORT2);
46 - maxX = maxY = scaleX = scaleY = 0;
47 - device = NULL;
48 - backZ = NULL;
 44+ glDirect3DViewport3 *newvp;
 45+ TRACE_ENTER(1, 14, viewport);
 46+ if (!viewport) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 47+ newvp = (glDirect3DViewport3*)malloc(sizeof(glDirect3DViewport3));
 48+ if (!newvp) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 49+ *viewport = (LPDIRECT3DVIEWPORT3)newvp;
 50+ newvp->background = 0;
 51+ ZeroMemory(&newvp->viewport,sizeof(D3DVIEWPORT2));
 52+ newvp->viewport.dwSize = sizeof(D3DVIEWPORT2);
 53+ newvp->maxX = newvp->maxY = newvp->scaleX = newvp->scaleY = 0;
 54+ newvp->device = NULL;
 55+ newvp->backZ = NULL;
4956 for(int i = 0; i < 8; i++)
50 - lights[i] = NULL;
51 - refcount = 1;
52 - current = false;
53 - glD3DV2 = NULL;
54 - glD3DV1 = NULL;
55 - TRACE_EXIT(-1,0);
 57+ newvp->lights[i] = NULL;
 58+ newvp->refcount = 1;
 59+ newvp->current = false;
 60+ newvp->glD3DV2 = NULL;
 61+ newvp->glD3DV1 = NULL;
 62+ TRACE_EXIT(23, DD_OK);
 63+ return DD_OK;
5664 }
5765
58 -glDirect3DViewport3::~glDirect3DViewport3()
 66+HRESULT WINAPI glDirect3DViewport3_QueryInterface(glDirect3DViewport3 *This, REFIID riid, void** ppvObj)
5967 {
60 - TRACE_ENTER(1,14,this);
61 - if(device) device->Release();
62 - if(backZ) backZ->Release();
63 - for(int i = 0; i < 8; i++)
64 - {
65 - if(lights[i]) lights[i]->Release();
66 - }
67 - TRACE_EXIT(-1,0);
68 -}
69 -
70 -HRESULT WINAPI glDirect3DViewport3::QueryInterface(REFIID riid, void** ppvObj)
71 -{
72 - TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
73 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 68+ HRESULT ret;
 69+ TRACE_ENTER(3,14,This,24,&riid,14,ppvObj);
 70+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
7471 if(riid == IID_IUnknown)
7572 {
76 - this->AddRef();
77 - *ppvObj = this;
 73+ glDirect3DViewport3_AddRef(This);
 74+ *ppvObj = This;
7875 TRACE_VAR("*ppvObj",14,*ppvObj);
7976 TRACE_EXIT(23,D3D_OK);
8077 return D3D_OK;
@@ -80,8 +77,8 @@
8178 }
8279 if(riid == IID_IDirect3DViewport3)
8380 {
84 - this->AddRef();
85 - *ppvObj = this;
 81+ glDirect3DViewport3_AddRef(This);
 82+ *ppvObj = This;
8683 TRACE_VAR("*ppvObj",14,*ppvObj);
8784 TRACE_EXIT(23,D3D_OK);
8885 return D3D_OK;
@@ -88,10 +85,10 @@
8986 }
9087 if(riid == IID_IDirect3DViewport2)
9188 {
92 - if(glD3DV2)
 89+ if(This->glD3DV2)
9390 {
94 - *ppvObj = glD3DV2;
95 - glD3DV2->AddRef();
 91+ *ppvObj = This->glD3DV2;
 92+ glDirect3DViewport2_AddRef(This->glD3DV2);
9693 TRACE_VAR("*ppvObj",14,*ppvObj);
9794 TRACE_EXIT(23,D3D_OK);
9895 return D3D_OK;
@@ -98,9 +95,10 @@
9996 }
10097 else
10198 {
102 - this->AddRef();
103 - *ppvObj = new glDirect3DViewport2(this);
104 - glD3DV2 = (glDirect3DViewport2*)*ppvObj;
 99+ ret = glDirect3DViewport2_Create(This, (LPDIRECT3DVIEWPORT2*)*ppvObj);
 100+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 101+ glDirect3DViewport3_AddRef(This);
 102+ This->glD3DV2 = (glDirect3DViewport2*)*ppvObj;
105103 TRACE_VAR("*ppvObj",14,*ppvObj);
106104 TRACE_EXIT(23,D3D_OK);
107105 return D3D_OK;
@@ -108,10 +106,10 @@
109107 }
110108 if(riid == IID_IDirect3DViewport)
111109 {
112 - if(glD3DV1)
 110+ if(This->glD3DV1)
113111 {
114 - *ppvObj = glD3DV1;
115 - glD3DV1->AddRef();
 112+ *ppvObj = This->glD3DV1;
 113+ glDirect3DViewport1_AddRef(This->glD3DV1);
116114 TRACE_VAR("*ppvObj",14,*ppvObj);
117115 TRACE_EXIT(23,D3D_OK);
118116 return D3D_OK;
@@ -118,9 +116,10 @@
119117 }
120118 else
121119 {
122 - this->AddRef();
123 - *ppvObj = new glDirect3DViewport1(this);
124 - glD3DV1 = (glDirect3DViewport1*)*ppvObj;
 120+ ret = glDirect3DViewport1_Create(This, (LPDIRECT3DVIEWPORT*)*ppvObj);
 121+ if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
 122+ glDirect3DViewport3_AddRef(This);
 123+ This->glD3DV1 = (glDirect3DViewport1*)*ppvObj;
125124 TRACE_VAR("*ppvObj",14,*ppvObj);
126125 TRACE_EXIT(23,D3D_OK);
127126 return D3D_OK;
@@ -130,42 +129,51 @@
131130 return E_NOINTERFACE;
132131 }
133132
134 -ULONG WINAPI glDirect3DViewport3::AddRef()
 133+ULONG WINAPI glDirect3DViewport3_AddRef(glDirect3DViewport3 *This)
135134 {
136 - TRACE_ENTER(1,14,this);
137 - if(!this) TRACE_RET(ULONG,8,0);
138 - refcount++;
139 - TRACE_EXIT(8,refcount);
140 - return refcount;
 135+ TRACE_ENTER(1,14,This);
 136+ if(!This) TRACE_RET(ULONG,8,0);
 137+ This->refcount++;
 138+ TRACE_EXIT(8,This->refcount);
 139+ return This->refcount;
141140 }
142141
143 -ULONG WINAPI glDirect3DViewport3::Release()
 142+ULONG WINAPI glDirect3DViewport3_Release(glDirect3DViewport3 *This)
144143 {
145 - TRACE_ENTER(1,14,this);
146 - if(!this) TRACE_RET(ULONG,8,0);
 144+ TRACE_ENTER(1,14,This);
 145+ if(!This) TRACE_RET(ULONG,8,0);
147146 ULONG ret;
148 - refcount--;
149 - ret = refcount;
150 - if(refcount == 0) delete this;
151 - TRACE_EXIT(8,refcount);
 147+ This->refcount--;
 148+ ret = This->refcount;
 149+ if (This->refcount == 0)
 150+ {
 151+ if (This->device) This->device->Release();
 152+ if (This->backZ) This->backZ->Release();
 153+ for (int i = 0; i < 8; i++)
 154+ {
 155+ if (This->lights[i]) This->lights[i]->Release();
 156+ }
 157+ free(This);
 158+ }
 159+ TRACE_EXIT(8,ret);
152160 return ret;
153161 }
154162
155 -HRESULT WINAPI glDirect3DViewport3::AddLight(LPDIRECT3DLIGHT lpDirect3DLight)
 163+HRESULT WINAPI glDirect3DViewport3_AddLight(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight)
156164 {
157 - TRACE_ENTER(2,14,this,14,lpDirect3DLight);
158 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 165+ TRACE_ENTER(2,14,This,14,lpDirect3DLight);
 166+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
159167 if(((glDirect3DLight*)lpDirect3DLight)->viewport) TRACE_RET(HRESULT,23,D3DERR_LIGHTHASVIEWPORT);
160168 for(int i = 0; i < 8; i++)
161169 {
162 - if(!lights[i])
 170+ if(!This->lights[i])
163171 {
164 - if(lights[i] == lpDirect3DLight) return D3D_OK;
165 - lights[i] = (glDirect3DLight*)lpDirect3DLight;
166 - lights[i]->AddRef();
167 - lights[i]->viewport = this;
168 - if(device) lights[i]->SetDevice(device,i);
169 - lights[i]->Sync();
 172+ if(This->lights[i] == lpDirect3DLight) return D3D_OK;
 173+ This->lights[i] = (glDirect3DLight*)lpDirect3DLight;
 174+ This->lights[i]->AddRef();
 175+ This->lights[i]->viewport = This;
 176+ if(This->device) This->lights[i]->SetDevice(This->device,i);
 177+ This->lights[i]->Sync();
170178 TRACE_EXIT(23,D3D_OK);
171179 return D3D_OK;
172180 }
@@ -174,36 +182,36 @@
175183 return D3DERR_LIGHT_SET_FAILED;
176184 }
177185
178 -HRESULT WINAPI glDirect3DViewport3::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
 186+HRESULT WINAPI glDirect3DViewport3_Clear(glDirect3DViewport3 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
179187 {
180 - TRACE_ENTER(4,14,this,8,dwCount,14,lpRects,9,dwFlags);
181 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
182 - if(!device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
 188+ TRACE_ENTER(4,14,This,8,dwCount,14,lpRects,9,dwFlags);
 189+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 190+ if(!This->device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
183191 D3DCOLORVALUE bgcolor = {0.0,0.0,0.0,0.0};
184 - if(device->materials[background]) bgcolor = device->materials[background]->material.diffuse;
185 - TRACE_RET(HRESULT,23,device->Clear(dwCount,lpRects,dwFlags,d3dcvtod3dcolor(bgcolor),0.0,0));
 192+ if(This->device->materials[This->background]) bgcolor = This->device->materials[This->background]->material.diffuse;
 193+ TRACE_RET(HRESULT,23,This->device->Clear(dwCount,lpRects,dwFlags,d3dcvtod3dcolor(bgcolor),0.0,0));
186194 }
187195
188 -HRESULT WINAPI glDirect3DViewport3::Clear2(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
 196+HRESULT WINAPI glDirect3DViewport3_Clear2(glDirect3DViewport3 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
189197 {
190 - TRACE_ENTER(7,14,this,8,dwCount,14,lpRects,9,dwFlags,9,dwColor,19,&dvZ,9,dwStencil);
191 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
192 - if(!device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
193 - TRACE_RET(HRESULT,23,device->Clear(dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
 198+ TRACE_ENTER(7,14,This,8,dwCount,14,lpRects,9,dwFlags,9,dwColor,19,&dvZ,9,dwStencil);
 199+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 200+ if(!This->device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
 201+ TRACE_RET(HRESULT,23,This->device->Clear(dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
194202 }
195203
196 -HRESULT WINAPI glDirect3DViewport3::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
 204+HRESULT WINAPI glDirect3DViewport3_DeleteLight(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight)
197205 {
198 - TRACE_ENTER(2,14,this,14,lpDirect3DLight);
199 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 206+ TRACE_ENTER(2,14,This,14,lpDirect3DLight);
 207+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
200208 if(!lpDirect3DLight) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
201209 for(int i = 0; i < 8; i++)
202210 {
203 - if(lights[i] == lpDirect3DLight)
 211+ if(This->lights[i] == lpDirect3DLight)
204212 {
205 - lights[i]->Release();
206 - lights[i]->SetDevice(NULL,0);
207 - lights[i] = NULL;
 213+ This->lights[i]->Release();
 214+ This->lights[i]->SetDevice(NULL,0);
 215+ This->lights[i] = NULL;
208216 TRACE_EXIT(23,D3D_OK);
209217 return D3D_OK;
210218 }
@@ -212,501 +220,515 @@
213221 return D3DERR_LIGHTNOTINTHISVIEWPORT;
214222 }
215223
216 -HRESULT WINAPI glDirect3DViewport3::GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
 224+HRESULT WINAPI glDirect3DViewport3_GetBackground(glDirect3DViewport3 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
217225 {
218 - TRACE_ENTER(3,14,this,14,lphMat,14,lpValid);
219 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 226+ TRACE_ENTER(3,14,This,14,lphMat,14,lpValid);
 227+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
220228 if(!lphMat) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
221229 if(lpValid)
222230 {
223 - if(background) *lpValid = TRUE;
 231+ if(This->background) *lpValid = TRUE;
224232 else *lpValid = FALSE;
225233 TRACE_VAR("*lpValid",22,*lpValid);
226234 }
227 - *lphMat = background;
 235+ *lphMat = This->background;
228236 TRACE_VAR("*lphMat",9,*lphMat);
229237 TRACE_EXIT(23,D3D_OK);
230238 return D3D_OK;
231239 }
232240
233 -HRESULT WINAPI glDirect3DViewport3::GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
 241+HRESULT WINAPI glDirect3DViewport3_GetBackgroundDepth(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
234242 {
235 - TRACE_ENTER(3,14,this,14,lplpDDSurface,14,lpValid);
236 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 243+ TRACE_ENTER(3,14,This,14,lplpDDSurface,14,lpValid);
 244+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
237245 if(!lplpDDSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
238246 if(lpValid)
239247 {
240 - if(backZ) *lpValid = TRUE;
 248+ if(This->backZ) *lpValid = TRUE;
241249 else *lpValid = FALSE;
242250 TRACE_VAR("*lpValid",22,*lpValid);
243251 }
244 - if(backZ) backZ->QueryInterface(IID_IDirectDrawSurface,(void**)lplpDDSurface);
 252+ if(This->backZ) This->backZ->QueryInterface(IID_IDirectDrawSurface,(void**)lplpDDSurface);
245253 else *lplpDDSurface = NULL;
246254 TRACE_VAR("*lplpDDSurface",14,*lplpDDSurface);
247255 TRACE_EXIT(23,D3D_OK);
248256 return D3D_OK;
249257 }
250 -HRESULT WINAPI glDirect3DViewport3::GetBackgroundDepth2(LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid)
 258+HRESULT WINAPI glDirect3DViewport3_GetBackgroundDepth2(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid)
251259 {
252 - TRACE_ENTER(3,14,this,14,lplpDDS,14,lpValid);
253 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 260+ TRACE_ENTER(3,14,This,14,lplpDDS,14,lpValid);
 261+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
254262 if(!lplpDDS) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
255263 if(lpValid)
256264 {
257 - if(backZ) *lpValid = TRUE;
 265+ if(This->backZ) *lpValid = TRUE;
258266 else *lpValid = FALSE;
259267 TRACE_VAR("*lpValid",22,*lpValid);
260268 }
261 - if(backZ) backZ->QueryInterface(IID_IDirectDrawSurface4,(void**)lplpDDS);
 269+ if(This->backZ) This->backZ->QueryInterface(IID_IDirectDrawSurface4,(void**)lplpDDS);
262270 else *lplpDDS = NULL;
263271 TRACE_VAR("*lplpDDS",14,*lplpDDS);
264272 TRACE_EXIT(23,D3D_OK);
265273 return D3D_OK;
266274 }
267 -HRESULT WINAPI glDirect3DViewport3::GetViewport(LPD3DVIEWPORT lpData)
 275+HRESULT WINAPI glDirect3DViewport3_GetViewport(glDirect3DViewport3 *This, LPD3DVIEWPORT lpData)
268276 {
269 - TRACE_ENTER(2,14,this,14,lpData);
270 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 277+ TRACE_ENTER(2,14,This,14,lpData);
 278+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
271279 if(!lpData) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
272 - memcpy(lpData,&viewport,sizeof(D3DVIEWPORT2));
273 - lpData->dvScaleX = scaleX;
274 - lpData->dvScaleY = scaleY;
275 - lpData->dvMaxX = maxX;
276 - lpData->dvMaxY = maxY;
 280+ memcpy(lpData,&This->viewport,sizeof(D3DVIEWPORT2));
 281+ lpData->dvScaleX = This->scaleX;
 282+ lpData->dvScaleY = This->scaleY;
 283+ lpData->dvMaxX = This->maxX;
 284+ lpData->dvMaxY = This->maxY;
277285 TRACE_EXIT(23,D3D_OK);
278286 return D3D_OK;
279287 }
280 -HRESULT WINAPI glDirect3DViewport3::GetViewport2(LPD3DVIEWPORT2 lpData)
 288+HRESULT WINAPI glDirect3DViewport3_GetViewport2(glDirect3DViewport3 *This, LPD3DVIEWPORT2 lpData)
281289 {
282 - TRACE_ENTER(2,14,this,14,lpData);
283 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 290+ TRACE_ENTER(2,14,This,14,lpData);
 291+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
284292 if(!lpData) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
285 - memcpy(lpData,&viewport,sizeof(D3DVIEWPORT2));
 293+ memcpy(lpData,&This->viewport,sizeof(D3DVIEWPORT2));
286294 TRACE_EXIT(23,D3D_OK);
287295 return D3D_OK;
288296 }
289 -HRESULT WINAPI glDirect3DViewport3::Initialize(LPDIRECT3D lpDirect3D)
 297+HRESULT WINAPI glDirect3DViewport3_Initialize(glDirect3DViewport3 *This, LPDIRECT3D lpDirect3D)
290298 {
291 - TRACE_ENTER(2,14,this,14,lpDirect3D);
292 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 299+ TRACE_ENTER(2,14,This,14,lpDirect3D);
 300+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
293301 TRACE_EXIT(23,DDERR_ALREADYINITIALIZED);
294302 return DDERR_ALREADYINITIALIZED;
295303 }
296 -HRESULT WINAPI glDirect3DViewport3::LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData)
 304+HRESULT WINAPI glDirect3DViewport3_LightElements(glDirect3DViewport3 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData)
297305 {
298 - TRACE_ENTER(3,14,this,8,dwElementCount,14,lpData);
299 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 306+ TRACE_ENTER(3,14,This,8,dwElementCount,14,lpData);
 307+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
300308 TRACE_EXIT(23,DDERR_UNSUPPORTED);
301309 return DDERR_UNSUPPORTED;
302310 }
303 -HRESULT WINAPI glDirect3DViewport3::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
 311+HRESULT WINAPI glDirect3DViewport3_NextLight(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
304312 {
305 - TRACE_ENTER(4,14,this,14,lpDirect3DLight,14,lplpDirect3DLight,9,dwFlags);
306 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 313+ TRACE_ENTER(4,14,This,14,lpDirect3DLight,14,lplpDirect3DLight,9,dwFlags);
 314+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
307315 if(!lplpDirect3DLight) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
308316 FIXME("glDirect3DViewport3::NextLight: stub");
309317 TRACE_EXIT(23,DDERR_GENERIC);
310318 return DDERR_GENERIC;
311319 }
312 -HRESULT WINAPI glDirect3DViewport3::SetBackground(D3DMATERIALHANDLE hMat)
 320+HRESULT WINAPI glDirect3DViewport3_SetBackground(glDirect3DViewport3 *This, D3DMATERIALHANDLE hMat)
313321 {
314 - TRACE_ENTER(2,14,this,9,hMat);
315 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
316 - if(!device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
317 - if(hMat > device->materialcount) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
318 - background = hMat;
 322+ TRACE_ENTER(2,14,This,9,hMat);
 323+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 324+ if(!This->device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
 325+ if(hMat > This->device->materialcount) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 326+ This->background = hMat;
319327 TRACE_EXIT(23,D3D_OK);
320328 return D3D_OK;
321329 }
322 -HRESULT WINAPI glDirect3DViewport3::SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface)
 330+HRESULT WINAPI glDirect3DViewport3_SetBackgroundDepth(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE lpDDSurface)
323331 {
324 - TRACE_ENTER(2,14,this,14,lpDDSurface);
325 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
326 - if(!backZ && !lpDDSurface) TRACE_RET(HRESULT,23,D3D_OK);
327 - if(((glDirectDrawSurface1*)lpDDSurface)->GetDDS7() == backZ) TRACE_RET(HRESULT,23,D3D_OK);
328 - if(backZ)backZ->Release();
329 - if(lpDDSurface) lpDDSurface->QueryInterface(IID_IDirectDrawSurface7,(void**)&backZ);
330 - else backZ = NULL;
331 - TRACE_EXIT(23,D3D_OK);
332 - return D3D_OK;
 332+ HRESULT ret = D3D_OK;
 333+ TRACE_ENTER(2, 14, This, 14, lpDDSurface);
 334+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 335+ if(!This->backZ && !lpDDSurface) TRACE_RET(HRESULT,23,D3D_OK);
 336+ if(((glDirectDrawSurface1*)lpDDSurface)->GetDDS7() == This->backZ) TRACE_RET(HRESULT,23,D3D_OK);
 337+ if(This->backZ)This->backZ->Release();
 338+ if(lpDDSurface) ret = lpDDSurface->QueryInterface(IID_IDirectDrawSurface7,(void**)&This->backZ);
 339+ else This->backZ = NULL;
 340+ TRACE_EXIT(23,ret);
 341+ return ret;
333342 }
334 -HRESULT WINAPI glDirect3DViewport3::SetBackgroundDepth2(LPDIRECTDRAWSURFACE4 lpDDS)
 343+HRESULT WINAPI glDirect3DViewport3_SetBackgroundDepth2(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE4 lpDDS)
335344 {
336 - TRACE_ENTER(2,14,this,14,lpDDS);
337 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
338 - if(!backZ && !lpDDS) TRACE_RET(HRESULT,23,D3D_OK);
339 - if(((glDirectDrawSurface4*)lpDDS)->GetDDS7() == backZ) TRACE_RET(HRESULT,23,D3D_OK);
340 - if(backZ)backZ->Release();
341 - if(lpDDS) lpDDS->QueryInterface(IID_IDirectDrawSurface7,(void**)&backZ);
342 - else backZ = NULL;
343 - TRACE_EXIT(23,D3D_OK);
344 - return D3D_OK;
 345+ HRESULT ret = D3D_OK;
 346+ TRACE_ENTER(2,14,This,14,lpDDS);
 347+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 348+ if(!This->backZ && !lpDDS) TRACE_RET(HRESULT,23,D3D_OK);
 349+ if(((glDirectDrawSurface4*)lpDDS)->GetDDS7() == This->backZ) TRACE_RET(HRESULT,23,D3D_OK);
 350+ if(This->backZ)This->backZ->Release();
 351+ if(lpDDS) ret = lpDDS->QueryInterface(IID_IDirectDrawSurface7,(void**)&This->backZ);
 352+ else This->backZ = NULL;
 353+ TRACE_EXIT(23,ret);
 354+ return ret;
345355 }
346356
347 -HRESULT WINAPI glDirect3DViewport3::SetViewport(LPD3DVIEWPORT lpData)
 357+HRESULT WINAPI glDirect3DViewport3_SetViewport(glDirect3DViewport3 *This, LPD3DVIEWPORT lpData)
348358 {
349 - TRACE_ENTER(2,14,this,14,lpData);
350 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
351 - if(!device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
 359+ TRACE_ENTER(2,14,This,14,lpData);
 360+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 361+ if(!This->device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
352362 if(!lpData) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
353363 D3DVIEWPORT2 vp;
354364 memcpy(&vp,lpData,sizeof(D3DVIEWPORT));
355 - vp.dvClipHeight = viewport.dvClipHeight;
356 - vp.dvClipWidth = viewport.dvClipWidth;
357 - vp.dvClipX = viewport.dvClipX;
358 - vp.dvClipY = viewport.dvClipY;
 365+ vp.dvClipHeight = This->viewport.dvClipHeight;
 366+ vp.dvClipWidth = This->viewport.dvClipWidth;
 367+ vp.dvClipX = This->viewport.dvClipX;
 368+ vp.dvClipY = This->viewport.dvClipY;
359369 if((vp.dvMinZ == 0) && (vp.dvMaxZ == 0)) vp.dvMaxZ = 1.0f;
360 - viewport = vp;
361 - maxX = lpData->dvMaxX;
362 - maxY = lpData->dvMaxY;
363 - scaleX = lpData->dvScaleX;
364 - scaleY = lpData->dvScaleY;
365 - if(current && device) Sync();
 370+ This->viewport = vp;
 371+ This->maxX = lpData->dvMaxX;
 372+ This->maxY = lpData->dvMaxY;
 373+ This->scaleX = lpData->dvScaleX;
 374+ This->scaleY = lpData->dvScaleY;
 375+ if(This->current && This->device) glDirect3DViewport3_Sync(This);
366376 TRACE_EXIT(23,D3D_OK);
367377 return D3D_OK;
368378 }
369 -HRESULT WINAPI glDirect3DViewport3::SetViewport2(LPD3DVIEWPORT2 lpData)
 379+HRESULT WINAPI glDirect3DViewport3_SetViewport2(glDirect3DViewport3 *This, LPD3DVIEWPORT2 lpData)
370380 {
371 - TRACE_ENTER(2,14,this,14,lpData);
372 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
373 - if(!device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
 381+ TRACE_ENTER(2,14,This,14,lpData);
 382+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 383+ if(!This->device) TRACE_RET(HRESULT,23,D3DERR_VIEWPORTHASNODEVICE);
374384 if(!lpData) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
375 - viewport = *lpData;
376 - if(current && device) Sync();
 385+ This->viewport = *lpData;
 386+ if(This->current && This->device) glDirect3DViewport3_Sync(This);
377387 TRACE_EXIT(23,D3D_OK);
378388 return D3D_OK;
379389 }
380 -HRESULT WINAPI glDirect3DViewport3::TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
 390+HRESULT WINAPI glDirect3DViewport3_TransformVertices(glDirect3DViewport3 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
381391 {
382 - TRACE_ENTER(5,14,this,8,dwVertexCount,14,lpData,9,dwFlags,14,lpOffscreen);
383 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 392+ TRACE_ENTER(5,14,This,8,dwVertexCount,14,lpData,9,dwFlags,14,lpOffscreen);
 393+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
384394 FIXME("glDirect3DViewport3::TransformVertices: stub");
385395 TRACE_EXIT(23,DDERR_GENERIC);
386396 return DDERR_GENERIC;
387397 }
388398
389 -void glDirect3DViewport3::SetCurrent(bool current)
 399+void glDirect3DViewport3_SetCurrent(glDirect3DViewport3 *This, bool current)
390400 {
391 - TRACE_ENTER(2,14,this,21,current);
392 - if(this->current && current)
 401+ TRACE_ENTER(2,14,This,21,current);
 402+ if(This->current && current)
393403 {
394404 TRACE_EXIT(0,0);
395405 return;
396406 }
397 - this->current = current;
398 - if(current && device)
 407+ This->current = current;
 408+ if(current && This->device)
399409 {
400 - Sync();
401 - SyncLights();
 410+ glDirect3DViewport3_Sync(This);
 411+ glDirect3DViewport3_SyncLights(This);
402412 }
403413 TRACE_EXIT(0,0);
404414 }
405415
406 -void glDirect3DViewport3::Sync()
 416+void glDirect3DViewport3_SetDevice(glDirect3DViewport3 *This, glDirect3DDevice7 *device)
407417 {
408 - TRACE_ENTER(1,14,this);
 418+ This->device = device;
 419+}
 420+
 421+void glDirect3DViewport3_Sync(glDirect3DViewport3 *This)
 422+{
 423+ TRACE_ENTER(1,14,This);
409424 D3DVIEWPORT7 vp7;
410 - vp7.dwX = viewport.dwX;
411 - vp7.dwY = viewport.dwY;
412 - vp7.dwHeight = viewport.dwHeight;
413 - vp7.dwWidth = viewport.dwWidth;
414 - vp7.dvMinZ = viewport.dvMinZ;
415 - vp7.dvMaxZ = viewport.dvMaxZ;
416 - device->SetViewport(&vp7);
417 - device->SetScale(scaleX,scaleY);
 425+ vp7.dwX = This->viewport.dwX;
 426+ vp7.dwY = This->viewport.dwY;
 427+ vp7.dwHeight = This->viewport.dwHeight;
 428+ vp7.dwWidth = This->viewport.dwWidth;
 429+ vp7.dvMinZ = This->viewport.dvMinZ;
 430+ vp7.dvMaxZ = This->viewport.dvMaxZ;
 431+ This->device->SetViewport(&vp7);
 432+ This->device->SetScale(This->scaleX,This->scaleY);
418433 TRACE_EXIT(0,0);
419434 }
420435
421 -void glDirect3DViewport3::SyncLights()
 436+void glDirect3DViewport3_SyncLights(glDirect3DViewport3 *This)
422437 {
423 - TRACE_ENTER(1,14,this);
 438+ TRACE_ENTER(1,14,This);
424439 D3DLIGHT7 light;
425440 for(int i = 0; i < 8; i++)
426441 {
427 - if(lights[i])
 442+ if(This->lights[i])
428443 {
429 - lights[i]->SetDevice(device,i);
430 - lights[i]->GetLight7(&light);
431 - device->SetLight(i,&light);
432 - device->LightEnable(i,TRUE);
 444+ This->lights[i]->SetDevice(This->device,i);
 445+ This->lights[i]->GetLight7(&light);
 446+ This->device->SetLight(i,&light);
 447+ This->device->LightEnable(i,TRUE);
433448 }
434 - else device->LightEnable(i,FALSE);
 449+ else This->device->LightEnable(i,FALSE);
435450 }
436451 TRACE_EXIT(0,0);
437452 }
438453
439454
440 -glDirect3DViewport2::glDirect3DViewport2(glDirect3DViewport3 *glD3DV3)
 455+HRESULT glDirect3DViewport2_Create(glDirect3DViewport3 *glD3DV3, LPDIRECT3DVIEWPORT2 *viewport)
441456 {
442 - TRACE_ENTER(2,14,this,14,glD3DV3);
443 - this->glD3DV3 = glD3DV3;
444 - refcount = 1;
445 - TRACE_EXIT(-1,0);
 457+ glDirect3DViewport2 *newvp;
 458+ TRACE_ENTER(2, 14, glD3DV3, 14, viewport);
 459+ if (!viewport) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 460+ newvp = (glDirect3DViewport2*)malloc(sizeof(glDirect3DViewport2));
 461+ if (!newvp) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 462+ *viewport = (LPDIRECT3DVIEWPORT2)newvp;
 463+ newvp->glD3DV3 = glD3DV3;
 464+ newvp->refcount = 1;
 465+ TRACE_EXIT(23, DD_OK);
 466+ return DD_OK;
446467 }
447468
448 -glDirect3DViewport2::~glDirect3DViewport2()
 469+ULONG WINAPI glDirect3DViewport2_AddRef(glDirect3DViewport2 *This)
449470 {
450 - TRACE_ENTER(1,14,this);
451 - glD3DV3->glD3DV2 = NULL;
452 - glD3DV3->Release();
453 - TRACE_EXIT(-1,0);
 471+ TRACE_ENTER(1,14,This);
 472+ if(!This) TRACE_RET(ULONG,8,0);
 473+ This->refcount++;
 474+ TRACE_EXIT(8,This->refcount);
 475+ return This->refcount;
454476 }
455477
456 -ULONG WINAPI glDirect3DViewport2::AddRef()
 478+ULONG WINAPI glDirect3DViewport2_Release(glDirect3DViewport2 *This)
457479 {
458 - TRACE_ENTER(1,14,this);
459 - if(!this) TRACE_RET(ULONG,8,0);
460 - refcount++;
461 - TRACE_EXIT(8,refcount);
462 - return refcount;
463 -}
464 -
465 -ULONG WINAPI glDirect3DViewport2::Release()
466 -{
467 - TRACE_ENTER(1,14,this);
468 - if(!this) TRACE_RET(ULONG,8,0);
 480+ TRACE_ENTER(1,14,This);
 481+ if(!This) TRACE_RET(ULONG,8,0);
469482 ULONG ret;
470 - refcount--;
471 - ret = refcount;
472 - if(refcount == 0) delete this;
473 - TRACE_ENTER(8,ret);
 483+ This->refcount--;
 484+ ret = This->refcount;
 485+ if (This->refcount == 0)
 486+ {
 487+ This->glD3DV3->glD3DV2 = NULL;
 488+ glDirect3DViewport3_Release(This->glD3DV3);
 489+ free(This);
 490+ }
 491+ TRACE_EXIT(8,ret);
474492 return ret;
475493 }
476494
477 -HRESULT WINAPI glDirect3DViewport2::QueryInterface(REFIID riid, void** ppvObj)
 495+HRESULT WINAPI glDirect3DViewport2_QueryInterface(glDirect3DViewport2 *This, REFIID riid, void** ppvObj)
478496 {
479 - TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
480 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 497+ TRACE_ENTER(3,14,This,24,&riid,14,ppvObj);
 498+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
481499 if(riid == IID_IUnknown)
482500 {
483 - this->AddRef();
484 - *ppvObj = this;
 501+ glDirect3DViewport2_AddRef(This);
 502+ *ppvObj = This;
485503 TRACE_VAR("*ppvObj",14,*ppvObj);
486504 TRACE_EXIT(23,D3D_OK);
487505 return D3D_OK;
488506 }
489 - TRACE_RET(HRESULT,23,glD3DV3->QueryInterface(riid,ppvObj));
 507+ TRACE_RET(HRESULT,23,glDirect3DViewport3_QueryInterface(This->glD3DV3,riid,ppvObj));
490508 }
491509
492 -HRESULT WINAPI glDirect3DViewport2::AddLight(LPDIRECT3DLIGHT lpLight)
 510+HRESULT WINAPI glDirect3DViewport2_AddLight(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpLight)
493511 {
494 - TRACE_ENTER(2,14,this,14,lpLight);
495 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
496 - TRACE_RET(HRESULT,23,glD3DV3->AddLight(lpLight));
 512+ TRACE_ENTER(2,14,This,14,lpLight);
 513+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 514+ TRACE_RET(HRESULT,23,glDirect3DViewport3_AddLight(This->glD3DV3,lpLight));
497515 }
498 -HRESULT WINAPI glDirect3DViewport2::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
 516+HRESULT WINAPI glDirect3DViewport2_Clear(glDirect3DViewport2 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
499517 {
500 - TRACE_ENTER(4,14,this,9,dwCount,14,lpRects,9,dwFlags);
501 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
502 - TRACE_RET(HRESULT,23,glD3DV3->Clear(dwCount,lpRects,dwFlags));
 518+ TRACE_ENTER(4,14,This,9,dwCount,14,lpRects,9,dwFlags);
 519+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 520+ TRACE_RET(HRESULT,23,glDirect3DViewport3_Clear(This->glD3DV3,dwCount,lpRects,dwFlags));
503521 }
504 -HRESULT WINAPI glDirect3DViewport2::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
 522+HRESULT WINAPI glDirect3DViewport2_DeleteLight(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpDirect3DLight)
505523 {
506 - TRACE_ENTER(2,14,this,14,lpDirect3DLight);
507 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
508 - TRACE_RET(HRESULT,23,glD3DV3->DeleteLight(lpDirect3DLight));
 524+ TRACE_ENTER(2,14,This,14,lpDirect3DLight);
 525+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 526+ TRACE_RET(HRESULT,23,glDirect3DViewport3_DeleteLight(This->glD3DV3,lpDirect3DLight));
509527 }
510 -HRESULT WINAPI glDirect3DViewport2::GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
 528+HRESULT WINAPI glDirect3DViewport2_GetBackground(glDirect3DViewport2 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
511529 {
512 - TRACE_ENTER(3,14,this,14,lphMat,14,lpValid);
513 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
514 - TRACE_RET(HRESULT,23,glD3DV3->GetBackground(lphMat,lpValid));
 530+ TRACE_ENTER(3,14,This,14,lphMat,14,lpValid);
 531+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 532+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetBackground(This->glD3DV3,lphMat,lpValid));
515533 }
516 -HRESULT WINAPI glDirect3DViewport2::GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
 534+HRESULT WINAPI glDirect3DViewport2_GetBackgroundDepth(glDirect3DViewport2 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
517535 {
518 - TRACE_ENTER(3,14,this,14,lplpDDSurface,14,lpValid);
519 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
520 - TRACE_RET(HRESULT,23,glD3DV3->GetBackgroundDepth(lplpDDSurface,lpValid));
 536+ TRACE_ENTER(3,14,This,14,lplpDDSurface,14,lpValid);
 537+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 538+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetBackgroundDepth(This->glD3DV3,lplpDDSurface,lpValid));
521539 }
522 -HRESULT WINAPI glDirect3DViewport2::GetViewport(LPD3DVIEWPORT lpData)
 540+HRESULT WINAPI glDirect3DViewport2_GetViewport(glDirect3DViewport2 *This, LPD3DVIEWPORT lpData)
523541 {
524 - TRACE_ENTER(2,14,this,14,lpData);
525 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
526 - TRACE_RET(HRESULT,23,glD3DV3->GetViewport(lpData));
 542+ TRACE_ENTER(2,14,This,14,lpData);
 543+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 544+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetViewport(This->glD3DV3,lpData));
527545 }
528 -HRESULT WINAPI glDirect3DViewport2::GetViewport2(LPD3DVIEWPORT2 lpData)
 546+HRESULT WINAPI glDirect3DViewport2_GetViewport2(glDirect3DViewport2 *This, LPD3DVIEWPORT2 lpData)
529547 {
530 - TRACE_ENTER(2,14,this,14,lpData);
531 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
532 - TRACE_RET(HRESULT,23,glD3DV3->GetViewport2(lpData));
 548+ TRACE_ENTER(2,14,This,14,lpData);
 549+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 550+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetViewport2(This->glD3DV3,lpData));
533551 }
534 -HRESULT WINAPI glDirect3DViewport2::Initialize(LPDIRECT3D lpDirect3D)
 552+HRESULT WINAPI glDirect3DViewport2_Initialize(glDirect3DViewport2 *This, LPDIRECT3D lpDirect3D)
535553 {
536 - TRACE_ENTER(2,14,this,14,lpDirect3D);
537 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
538 - TRACE_RET(HRESULT,23,glD3DV3->Initialize(lpDirect3D));
 554+ TRACE_ENTER(2,14,This,14,lpDirect3D);
 555+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 556+ TRACE_RET(HRESULT,23,glDirect3DViewport3_Initialize(This->glD3DV3,lpDirect3D));
539557 }
540 -HRESULT WINAPI glDirect3DViewport2::LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData)
 558+HRESULT WINAPI glDirect3DViewport2_LightElements(glDirect3DViewport2 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData)
541559 {
542 - TRACE_ENTER(3,14,this,8,dwElementCount,14,lpData);
543 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
544 - TRACE_RET(HRESULT,23,glD3DV3->LightElements(dwElementCount,lpData));
 560+ TRACE_ENTER(3,14,This,8,dwElementCount,14,lpData);
 561+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 562+ TRACE_RET(HRESULT,23,glDirect3DViewport3_LightElements(This->glD3DV3,dwElementCount,lpData));
545563 }
546 -HRESULT WINAPI glDirect3DViewport2::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
 564+HRESULT WINAPI glDirect3DViewport2_NextLight(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
547565 {
548 - TRACE_ENTER(4,14,this,14,lpDirect3DLight,14,lplpDirect3DLight,9,dwFlags);
549 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
550 - TRACE_RET(HRESULT,23,glD3DV3->NextLight(lpDirect3DLight,lplpDirect3DLight,dwFlags));
 566+ TRACE_ENTER(4,14,This,14,lpDirect3DLight,14,lplpDirect3DLight,9,dwFlags);
 567+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 568+ TRACE_RET(HRESULT,23,glDirect3DViewport3_NextLight(This->glD3DV3,lpDirect3DLight,lplpDirect3DLight,dwFlags));
551569 }
552 -HRESULT WINAPI glDirect3DViewport2::SetBackground(D3DMATERIALHANDLE hMat)
 570+HRESULT WINAPI glDirect3DViewport2_SetBackground(glDirect3DViewport2 *This, D3DMATERIALHANDLE hMat)
553571 {
554 - TRACE_ENTER(2,14,this,9,hMat);
555 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
556 - TRACE_RET(HRESULT,23,glD3DV3->SetBackground(hMat));
 572+ TRACE_ENTER(2,14,This,9,hMat);
 573+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 574+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetBackground(This->glD3DV3,hMat));
557575 }
558 -HRESULT WINAPI glDirect3DViewport2::SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface)
 576+HRESULT WINAPI glDirect3DViewport2_SetBackgroundDepth(glDirect3DViewport2 *This, LPDIRECTDRAWSURFACE lpDDSurface)
559577 {
560 - TRACE_ENTER(2,14,this,14,lpDDSurface);
561 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
562 - TRACE_RET(HRESULT,23,glD3DV3->SetBackgroundDepth(lpDDSurface));
 578+ TRACE_ENTER(2,14,This,14,lpDDSurface);
 579+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 580+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetBackgroundDepth(This->glD3DV3,lpDDSurface));
563581 }
564 -HRESULT WINAPI glDirect3DViewport2::SetViewport(LPD3DVIEWPORT lpData)
 582+HRESULT WINAPI glDirect3DViewport2_SetViewport(glDirect3DViewport2 *This, LPD3DVIEWPORT lpData)
565583 {
566 - TRACE_ENTER(2,14,this,14,lpData);
567 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
568 - TRACE_RET(HRESULT,23,glD3DV3->SetViewport(lpData));
 584+ TRACE_ENTER(2,14,This,14,lpData);
 585+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 586+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetViewport(This->glD3DV3,lpData));
569587 }
570 -HRESULT WINAPI glDirect3DViewport2::SetViewport2(LPD3DVIEWPORT2 lpData)
 588+HRESULT WINAPI glDirect3DViewport2_SetViewport2(glDirect3DViewport2 *This, LPD3DVIEWPORT2 lpData)
571589 {
572 - TRACE_ENTER(2,14,this,14,lpData);
573 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
574 - TRACE_RET(HRESULT,23,glD3DV3->SetViewport2(lpData));
 590+ TRACE_ENTER(2,14,This,14,lpData);
 591+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 592+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetViewport2(This->glD3DV3,lpData));
575593 }
576 -HRESULT WINAPI glDirect3DViewport2::TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
 594+HRESULT WINAPI glDirect3DViewport2_TransformVertices(glDirect3DViewport2 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
577595 {
578 - TRACE_ENTER(5,14,this,8,dwVertexCount,14,lpData,9,dwFlags,14,lpOffscreen);
579 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
580 - TRACE_RET(HRESULT,23,glD3DV3->TransformVertices(dwVertexCount,lpData,dwFlags,lpOffscreen));
 596+ TRACE_ENTER(5,14,This,8,dwVertexCount,14,lpData,9,dwFlags,14,lpOffscreen);
 597+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 598+ TRACE_RET(HRESULT,23,glDirect3DViewport3_TransformVertices(This->glD3DV3,dwVertexCount,lpData,dwFlags,lpOffscreen));
581599 }
582600
583601
584 -glDirect3DViewport1::glDirect3DViewport1(glDirect3DViewport3 *glD3DV3)
 602+HRESULT glDirect3DViewport1_Create(glDirect3DViewport3 *glD3DV3, LPDIRECT3DVIEWPORT *viewport)
585603 {
586 - TRACE_ENTER(2,14,this,14,glD3DV3);
587 - this->glD3DV3 = glD3DV3;
588 - refcount = 1;
589 - TRACE_EXIT(-1,0);
 604+ glDirect3DViewport1 *newvp;
 605+ TRACE_ENTER(2, 14, glD3DV3, 14, viewport);
 606+ if (!viewport) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 607+ newvp = (glDirect3DViewport1*)malloc(sizeof(glDirect3DViewport1));
 608+ if (!newvp) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 609+ *viewport = (LPDIRECT3DVIEWPORT)newvp;
 610+ newvp->glD3DV3 = glD3DV3;
 611+ newvp->refcount = 1;
 612+ TRACE_EXIT(23, DD_OK);
 613+ return DD_OK;
590614 }
591615
592 -glDirect3DViewport1::~glDirect3DViewport1()
 616+ULONG WINAPI glDirect3DViewport1_AddRef(glDirect3DViewport1 *This)
593617 {
594 - TRACE_ENTER(1,14,this);
595 - glD3DV3->glD3DV1 = NULL;
596 - glD3DV3->Release();
597 - TRACE_EXIT(-1,0);
 618+ TRACE_ENTER(1,14,This);
 619+ if(!This) TRACE_RET(ULONG,8,0);
 620+ This->refcount++;
 621+ TRACE_EXIT(8,This->refcount);
 622+ return This->refcount;
598623 }
599624
600 -ULONG WINAPI glDirect3DViewport1::AddRef()
 625+ULONG WINAPI glDirect3DViewport1_Release(glDirect3DViewport1 *This)
601626 {
602 - TRACE_ENTER(1,14,this);
603 - if(!this) TRACE_RET(ULONG,8,0);
604 - refcount++;
605 - TRACE_EXIT(8,refcount);
606 - return refcount;
607 -}
608 -
609 -ULONG WINAPI glDirect3DViewport1::Release()
610 -{
611 - TRACE_ENTER(1,14,this);
612 - if(!this) TRACE_RET(ULONG,8,0);
 627+ TRACE_ENTER(1,14,This);
 628+ if(!This) TRACE_RET(ULONG,8,0);
613629 ULONG ret;
614 - refcount--;
615 - ret = refcount;
616 - if(refcount == 0) delete this;
617 - TRACE_EXIT(8,ret);
 630+ This->refcount--;
 631+ ret = This->refcount;
 632+ if (This->refcount == 0)
 633+ {
 634+ This->glD3DV3->glD3DV1 = NULL;
 635+ glDirect3DViewport3_Release(This->glD3DV3);
 636+ free(This);
 637+ }
 638+ TRACE_EXIT(8, ret);
618639 return ret;
619640 }
620641
621 -HRESULT WINAPI glDirect3DViewport1::QueryInterface(REFIID riid, void** ppvObj)
 642+HRESULT WINAPI glDirect3DViewport1_QueryInterface(glDirect3DViewport1 *This, REFIID riid, void** ppvObj)
622643 {
623 - TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
624 - TRACE_EXIT(-1,0);
 644+ TRACE_ENTER(3,14,This,24,&riid,14,ppvObj);
625645 if(riid == IID_IUnknown)
626646 {
627 - this->AddRef();
628 - *ppvObj = this;
 647+ glDirect3DViewport1_AddRef(This);
 648+ *ppvObj = This;
629649 TRACE_VAR("*ppvObj",14,*ppvObj);
630650 TRACE_EXIT(23,D3D_OK);
631651 return D3D_OK;
632652 }
633 - TRACE_RET(HRESULT,23,glD3DV3->QueryInterface(riid,ppvObj));
 653+ TRACE_RET(HRESULT,23,glDirect3DViewport3_QueryInterface(This->glD3DV3,riid,ppvObj));
634654 }
635655
636 -HRESULT WINAPI glDirect3DViewport1::AddLight(LPDIRECT3DLIGHT lpLight)
 656+HRESULT WINAPI glDirect3DViewport1_AddLight(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpLight)
637657 {
638 - TRACE_ENTER(2,14,this,14,lpLight);
639 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
640 - TRACE_RET(HRESULT,23,glD3DV3->AddLight(lpLight));
 658+ TRACE_ENTER(2,14,This,14,lpLight);
 659+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 660+ TRACE_RET(HRESULT,23,glDirect3DViewport3_AddLight(This->glD3DV3,lpLight));
641661 }
642 -HRESULT WINAPI glDirect3DViewport1::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
 662+HRESULT WINAPI glDirect3DViewport1_Clear(glDirect3DViewport1 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
643663 {
644 - TRACE_ENTER(4,14,this,8,dwCount,14,lpRects,9,dwFlags);
645 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
646 - TRACE_RET(HRESULT,23,glD3DV3->Clear(dwCount,lpRects,dwFlags));
 664+ TRACE_ENTER(4,14,This,8,dwCount,14,lpRects,9,dwFlags);
 665+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 666+ TRACE_RET(HRESULT,23,glDirect3DViewport3_Clear(This->glD3DV3,dwCount,lpRects,dwFlags));
647667 }
648 -HRESULT WINAPI glDirect3DViewport1::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
 668+HRESULT WINAPI glDirect3DViewport1_DeleteLight(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpDirect3DLight)
649669 {
650 - TRACE_ENTER(2,14,this,14,lpDirect3DLight);
651 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
652 - TRACE_RET(HRESULT,23,glD3DV3->DeleteLight(lpDirect3DLight));
 670+ TRACE_ENTER(2,14,This,14,lpDirect3DLight);
 671+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 672+ TRACE_RET(HRESULT,23,glDirect3DViewport3_DeleteLight(This->glD3DV3,lpDirect3DLight));
653673 }
654 -HRESULT WINAPI glDirect3DViewport1::GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
 674+HRESULT WINAPI glDirect3DViewport1_GetBackground(glDirect3DViewport1 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
655675 {
656 - TRACE_ENTER(3,14,this,14,lphMat,14,lpValid);
657 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
658 - TRACE_RET(HRESULT,23,glD3DV3->GetBackground(lphMat,lpValid));
 676+ TRACE_ENTER(3,14,This,14,lphMat,14,lpValid);
 677+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 678+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetBackground(This->glD3DV3,lphMat,lpValid));
659679 }
660 -HRESULT WINAPI glDirect3DViewport1::GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
 680+HRESULT WINAPI glDirect3DViewport1_GetBackgroundDepth(glDirect3DViewport1 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
661681 {
662 - TRACE_ENTER(3,14,this,14,lplpDDSurface,14,lpValid);
663 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
664 - TRACE_RET(HRESULT,23,glD3DV3->GetBackgroundDepth(lplpDDSurface,lpValid));
 682+ TRACE_ENTER(3,14,This,14,lplpDDSurface,14,lpValid);
 683+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 684+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetBackgroundDepth(This->glD3DV3,lplpDDSurface,lpValid));
665685 }
666 -HRESULT WINAPI glDirect3DViewport1::GetViewport(LPD3DVIEWPORT lpData)
 686+HRESULT WINAPI glDirect3DViewport1_GetViewport(glDirect3DViewport1 *This, LPD3DVIEWPORT lpData)
667687 {
668 - TRACE_ENTER(2,14,this,14,lpData);
669 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
670 - TRACE_RET(HRESULT,23,glD3DV3->GetViewport(lpData));
 688+ TRACE_ENTER(2,14,This,14,lpData);
 689+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 690+ TRACE_RET(HRESULT,23,glDirect3DViewport3_GetViewport(This->glD3DV3,lpData));
671691 }
672 -HRESULT WINAPI glDirect3DViewport1::Initialize(LPDIRECT3D lpDirect3D)
 692+HRESULT WINAPI glDirect3DViewport1_Initialize(glDirect3DViewport1 *This, LPDIRECT3D lpDirect3D)
673693 {
674 - TRACE_ENTER(2,14,this,14,lpDirect3D);
675 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
676 - TRACE_RET(HRESULT,23,glD3DV3->Initialize(lpDirect3D));
 694+ TRACE_ENTER(2,14,This,14,lpDirect3D);
 695+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 696+ TRACE_RET(HRESULT,23,glDirect3DViewport3_Initialize(This->glD3DV3,lpDirect3D));
677697 }
678 -HRESULT WINAPI glDirect3DViewport1::LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData)
 698+HRESULT WINAPI glDirect3DViewport1_LightElements(glDirect3DViewport1 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData)
679699 {
680 - TRACE_ENTER(3,14,this,8,dwElementCount,14,lpData);
681 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
682 - return glD3DV3->LightElements(dwElementCount,lpData);
 700+ TRACE_ENTER(3,14,This,8,dwElementCount,14,lpData);
 701+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 702+ return glDirect3DViewport3_LightElements(This->glD3DV3,dwElementCount,lpData);
683703 }
684 -HRESULT WINAPI glDirect3DViewport1::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
 704+HRESULT WINAPI glDirect3DViewport1_NextLight(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
685705 {
686 - TRACE_ENTER(4,14,this,14,lpDirect3DLight,14,lplpDirect3DLight,9,dwFlags);
687 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
688 - TRACE_RET(HRESULT,23,glD3DV3->NextLight(lpDirect3DLight,lplpDirect3DLight,dwFlags));
 706+ TRACE_ENTER(4,14,This,14,lpDirect3DLight,14,lplpDirect3DLight,9,dwFlags);
 707+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 708+ TRACE_RET(HRESULT,23,glDirect3DViewport3_NextLight(This->glD3DV3,lpDirect3DLight,lplpDirect3DLight,dwFlags));
689709 }
690 -HRESULT WINAPI glDirect3DViewport1::SetBackground(D3DMATERIALHANDLE hMat)
 710+HRESULT WINAPI glDirect3DViewport1_SetBackground(glDirect3DViewport1 *This, D3DMATERIALHANDLE hMat)
691711 {
692 - TRACE_ENTER(2,14,this,9,hMat);
693 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
694 - TRACE_RET(HRESULT,23,glD3DV3->SetBackground(hMat));
 712+ TRACE_ENTER(2,14,This,9,hMat);
 713+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 714+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetBackground(This->glD3DV3,hMat));
695715 }
696 -HRESULT WINAPI glDirect3DViewport1::SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface)
 716+HRESULT WINAPI glDirect3DViewport1_SetBackgroundDepth(glDirect3DViewport1 *This, LPDIRECTDRAWSURFACE lpDDSurface)
697717 {
698 - TRACE_ENTER(2,14,this,14,lpDDSurface);
699 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
700 - TRACE_RET(HRESULT,23,glD3DV3->SetBackgroundDepth(lpDDSurface));
 718+ TRACE_ENTER(2,14,This,14,lpDDSurface);
 719+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 720+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetBackgroundDepth(This->glD3DV3,lpDDSurface));
701721 }
702 -HRESULT WINAPI glDirect3DViewport1::SetViewport(LPD3DVIEWPORT lpData)
 722+HRESULT WINAPI glDirect3DViewport1_SetViewport(glDirect3DViewport1 *This, LPD3DVIEWPORT lpData)
703723 {
704 - TRACE_ENTER(2,14,this,14,lpData);
705 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
706 - TRACE_RET(HRESULT,23,glD3DV3->SetViewport(lpData));
 724+ TRACE_ENTER(2,14,This,14,lpData);
 725+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 726+ TRACE_RET(HRESULT,23,glDirect3DViewport3_SetViewport(This->glD3DV3,lpData));
707727 }
708 -HRESULT WINAPI glDirect3DViewport1::TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
 728+HRESULT WINAPI glDirect3DViewport1_TransformVertices(glDirect3DViewport1 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
709729 {
710 - TRACE_ENTER(5,14,this,8,dwVertexCount,14,lpData,9,dwFlags,14,lpOffscreen);
711 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
712 - TRACE_RET(HRESULT,23,glD3DV3->TransformVertices(dwVertexCount,lpData,dwFlags,lpOffscreen));
 730+ TRACE_ENTER(5,14,This,8,dwVertexCount,14,lpData,9,dwFlags,14,lpOffscreen);
 731+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 732+ TRACE_RET(HRESULT,23,glDirect3DViewport3_TransformVertices(This->glD3DV3,dwVertexCount,lpData,dwFlags,lpOffscreen));
713733 }
 734+
 735+}
\ No newline at end of file
Index: ddraw/glDirect3DViewport.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2013 William Feely
 3+// Copyright (C) 2011-2014 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -19,44 +19,27 @@
2020 #ifndef __GLDIRECT3DVIEWPORT_H
2121 #define __GLDIRECT3DVIEWPORT_H
2222
 23+#ifdef __cplusplus
2324 class glDirect3DLight;
2425 class glDirect3DDevice7;
2526 class glDirectDrawSurface7;
26 -class glDirect3DViewport1;
27 -class glDirect3DViewport2;
28 -class glDirect3DViewport3 : public IDirect3DViewport3
 27+extern "C" {
 28+#else
 29+typedef int glDirect3DLight;
 30+typedef int glDirect3DDevice7;
 31+typedef int glDirectDrawSurface7;
 32+#endif
 33+
 34+struct glDirect3DViewport1;
 35+struct glDirect3DViewport2;
 36+
 37+struct glDirect3DViewport3Vtbl;
 38+
 39+typedef struct glDirect3DViewport3
2940 {
30 -public:
31 - glDirect3DViewport3();
32 - virtual ~glDirect3DViewport3();
33 - HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
34 - ULONG WINAPI AddRef();
35 - ULONG WINAPI Release();
36 - HRESULT WINAPI AddLight(LPDIRECT3DLIGHT lpDirect3DLight);
37 - HRESULT WINAPI Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
38 - HRESULT WINAPI Clear2(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
39 - HRESULT WINAPI DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight);
40 - HRESULT WINAPI GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
41 - HRESULT WINAPI GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
42 - HRESULT WINAPI GetBackgroundDepth2(LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid);
43 - HRESULT WINAPI GetViewport(LPD3DVIEWPORT lpData);
44 - HRESULT WINAPI GetViewport2(LPD3DVIEWPORT2 lpData);
45 - HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
46 - HRESULT WINAPI LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData);
47 - HRESULT WINAPI NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
48 - HRESULT WINAPI SetBackground(D3DMATERIALHANDLE hMat);
49 - HRESULT WINAPI SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface);
50 - HRESULT WINAPI SetBackgroundDepth2(LPDIRECTDRAWSURFACE4 lpDDS);
51 - HRESULT WINAPI SetViewport(LPD3DVIEWPORT lpData);
52 - HRESULT WINAPI SetViewport2(LPD3DVIEWPORT2 lpData);
53 - HRESULT WINAPI TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
54 - void SetCurrent(bool current);
55 - void SetDevice(glDirect3DDevice7 *device){this->device = device;};
56 - void Sync();
57 - void SyncLights();
 41+ glDirect3DViewport3Vtbl *lpVtbl;
5842 glDirect3DViewport2 *glD3DV2;
5943 glDirect3DViewport1 *glD3DV1;
60 -private:
6144 ULONG refcount;
6245 glDirect3DLight *lights[8];
6346 glDirect3DDevice7 *device;
@@ -70,58 +53,163 @@
7154 bool current;
7255 };
7356
74 -class glDirect3DViewport2 : public IDirect3DViewport2
 57+typedef struct glDirect3DViewportVtbl
7558 {
76 -public:
77 - glDirect3DViewport2(glDirect3DViewport3 *glD3DV3);
78 - virtual ~glDirect3DViewport2();
79 - HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
80 - ULONG WINAPI AddRef();
81 - ULONG WINAPI Release();
82 - HRESULT WINAPI AddLight(LPDIRECT3DLIGHT lpLight);
83 - HRESULT WINAPI Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
84 - HRESULT WINAPI DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight);
85 - HRESULT WINAPI GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
86 - HRESULT WINAPI GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
87 - HRESULT WINAPI GetViewport(LPD3DVIEWPORT lpData);
88 - HRESULT WINAPI GetViewport2(LPD3DVIEWPORT2 lpData);
89 - HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
90 - HRESULT WINAPI LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData);
91 - HRESULT WINAPI NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
92 - HRESULT WINAPI SetBackground(D3DMATERIALHANDLE hMat);
93 - HRESULT WINAPI SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface);
94 - HRESULT WINAPI SetViewport(LPD3DVIEWPORT lpData);
95 - HRESULT WINAPI SetViewport2(LPD3DVIEWPORT2 lpData);
96 - HRESULT WINAPI TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
97 -private:
 59+ HRESULT(WINAPI *QueryInterface)(glDirect3DViewport3 *This, REFIID riid, void** ppvObj);
 60+ ULONG(WINAPI *AddRef)(glDirect3DViewport3 *This);
 61+ ULONG(WINAPI *Release)(glDirect3DViewport3 *This);
 62+ HRESULT(WINAPI *Initialize)(glDirect3DViewport3 *This, LPDIRECT3D lpDirect3D);
 63+ HRESULT(WINAPI *GetViewport)(glDirect3DViewport3 *This, LPD3DVIEWPORT lpData);
 64+ HRESULT(WINAPI *SetViewport)(glDirect3DViewport3 *This, LPD3DVIEWPORT lpData);
 65+ HRESULT(WINAPI *TransformVertices)(glDirect3DViewport3 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
 66+ HRESULT(WINAPI *LightElements)(glDirect3DViewport3 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData);
 67+ HRESULT(WINAPI *SetBackground)(glDirect3DViewport3 *This, D3DMATERIALHANDLE hMat);
 68+ HRESULT(WINAPI *GetBackground)(glDirect3DViewport3 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
 69+ HRESULT(WINAPI *SetBackgroundDepth)(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE lpDDSurface);
 70+ HRESULT(WINAPI *GetBackgroundDepth)(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
 71+ HRESULT(WINAPI *Clear)(glDirect3DViewport3 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
 72+ HRESULT(WINAPI *AddLight)(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 73+ HRESULT(WINAPI *DeleteLight)(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 74+ HRESULT(WINAPI *NextLight)(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
 75+ HRESULT(WINAPI *GetViewport2)(glDirect3DViewport3 *This, LPD3DVIEWPORT2 lpData);
 76+ HRESULT(WINAPI *SetViewport2)(glDirect3DViewport3 *This, LPD3DVIEWPORT2 lpData);
 77+ HRESULT(WINAPI *SetBackgroundDepth2)(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE4 lpDDS);
 78+ HRESULT(WINAPI *GetBackgroundDepth2)(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid);
 79+ HRESULT(WINAPI *Clear2)(glDirect3DViewport3 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
 80+};
 81+
 82+HRESULT glDirect3DViewport3_Create(LPDIRECT3DVIEWPORT3 *viewport);
 83+void glDirect3DViewport3_SetCurrent(glDirect3DViewport3 *This, bool current);
 84+void glDirect3DViewport3_SetDevice(glDirect3DViewport3 *This, glDirect3DDevice7 *device);
 85+void glDirect3DViewport3_Sync(glDirect3DViewport3 *This);
 86+void glDirect3DViewport3_SyncLights(glDirect3DViewport3 *This);
 87+
 88+HRESULT WINAPI glDirect3DViewport3_QueryInterface(glDirect3DViewport3 *This, REFIID riid, void** ppvObj);
 89+ULONG WINAPI glDirect3DViewport3_AddRef(glDirect3DViewport3 *This);
 90+ULONG WINAPI glDirect3DViewport3_Release(glDirect3DViewport3 *This);
 91+HRESULT WINAPI glDirect3DViewport3_Initialize(glDirect3DViewport3 *This, LPDIRECT3D lpDirect3D);
 92+HRESULT WINAPI glDirect3DViewport3_GetViewport(glDirect3DViewport3 *This, LPD3DVIEWPORT lpData);
 93+HRESULT WINAPI glDirect3DViewport3_SetViewport(glDirect3DViewport3 *This, LPD3DVIEWPORT lpData);
 94+HRESULT WINAPI glDirect3DViewport3_TransformVertices(glDirect3DViewport3 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
 95+HRESULT WINAPI glDirect3DViewport3_LightElements(glDirect3DViewport3 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData);
 96+HRESULT WINAPI glDirect3DViewport3_SetBackground(glDirect3DViewport3 *This, D3DMATERIALHANDLE hMat);
 97+HRESULT WINAPI glDirect3DViewport3_GetBackground(glDirect3DViewport3 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
 98+HRESULT WINAPI glDirect3DViewport3_SetBackgroundDepth(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE lpDDSurface);
 99+HRESULT WINAPI glDirect3DViewport3_GetBackgroundDepth(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
 100+HRESULT WINAPI glDirect3DViewport3_Clear(glDirect3DViewport3 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
 101+HRESULT WINAPI glDirect3DViewport3_AddLight(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 102+HRESULT WINAPI glDirect3DViewport3_DeleteLight(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 103+HRESULT WINAPI glDirect3DViewport3_NextLight(glDirect3DViewport3 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
 104+HRESULT WINAPI glDirect3DViewport3_GetViewport2(glDirect3DViewport3 *This, LPD3DVIEWPORT2 lpData);
 105+HRESULT WINAPI glDirect3DViewport3_SetViewport2(glDirect3DViewport3 *This, LPD3DVIEWPORT2 lpData);
 106+HRESULT WINAPI glDirect3DViewport3_SetBackgroundDepth2(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE4 lpDDS);
 107+HRESULT WINAPI glDirect3DViewport3_GetBackgroundDepth2(glDirect3DViewport3 *This, LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid);
 108+HRESULT WINAPI glDirect3DViewport3_Clear2(glDirect3DViewport3 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
 109+
 110+
 111+struct glDirect3DViewport2Vtbl;
 112+
 113+typedef struct glDirect3DViewport2
 114+{
 115+ glDirect3DViewport2Vtbl *lpVtbl;
98116 glDirect3DViewport3 *glD3DV3;
99117 int refcount;
100118 };
101119
102 -class glDirect3DViewport1 : public IDirect3DViewport
 120+typedef struct glDirect3DViewport2Vtbl
103121 {
104 -public:
105 - glDirect3DViewport1(glDirect3DViewport3 *glD3DV3);
106 - virtual ~glDirect3DViewport1();
107 - HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
108 - ULONG WINAPI AddRef();
109 - ULONG WINAPI Release();
110 - HRESULT WINAPI AddLight(LPDIRECT3DLIGHT lpLight);
111 - HRESULT WINAPI Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
112 - HRESULT WINAPI DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight);
113 - HRESULT WINAPI GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
114 - HRESULT WINAPI GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
115 - HRESULT WINAPI GetViewport(LPD3DVIEWPORT lpData);
116 - HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
117 - HRESULT WINAPI LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData);
118 - HRESULT WINAPI NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
119 - HRESULT WINAPI SetBackground(D3DMATERIALHANDLE hMat);
120 - HRESULT WINAPI SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface);
121 - HRESULT WINAPI SetViewport(LPD3DVIEWPORT lpData);
122 - HRESULT WINAPI TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
123 -private:
 122+ HRESULT(WINAPI *QueryInterface)(glDirect3DViewport2 *This, REFIID riid, void** ppvObj);
 123+ ULONG(WINAPI *AddRef)(glDirect3DViewport2 *This);
 124+ ULONG(WINAPI *Release)(glDirect3DViewport2 *This);
 125+ HRESULT(WINAPI *Initialize)(glDirect3DViewport2 *This, LPDIRECT3D lpDirect3D);
 126+ HRESULT(WINAPI *GetViewport)(glDirect3DViewport2 *This, LPD3DVIEWPORT lpData);
 127+ HRESULT(WINAPI *SetViewport)(glDirect3DViewport2 *This, LPD3DVIEWPORT lpData);
 128+ HRESULT(WINAPI *TransformVertices)(glDirect3DViewport2 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
 129+ HRESULT(WINAPI *LightElements)(glDirect3DViewport2 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData);
 130+ HRESULT(WINAPI *SetBackground)(glDirect3DViewport2 *This, D3DMATERIALHANDLE hMat);
 131+ HRESULT(WINAPI *GetBackground)(glDirect3DViewport2 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
 132+ HRESULT(WINAPI *SetBackgroundDepth)(glDirect3DViewport2 *This, LPDIRECTDRAWSURFACE lpDDSurface);
 133+ HRESULT(WINAPI *GetBackgroundDepth)(glDirect3DViewport2 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
 134+ HRESULT(WINAPI *Clear)(glDirect3DViewport2 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
 135+ HRESULT(WINAPI *AddLight)(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpLight);
 136+ HRESULT(WINAPI *DeleteLight)(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 137+ HRESULT(WINAPI *NextLight)(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
 138+ HRESULT(WINAPI *GetViewport2)(glDirect3DViewport2 *This, LPD3DVIEWPORT2 lpData);
 139+ HRESULT(WINAPI *SetViewport2)(glDirect3DViewport2 *This, LPD3DVIEWPORT2 lpData);
 140+};
 141+
 142+HRESULT glDirect3DViewport2_Create(glDirect3DViewport3 *glD3DV3, LPDIRECT3DVIEWPORT2 *viewport);
 143+
 144+HRESULT WINAPI glDirect3DViewport2_QueryInterface(glDirect3DViewport2 *This, REFIID riid, void** ppvObj);
 145+ULONG WINAPI glDirect3DViewport2_AddRef(glDirect3DViewport2 *This);
 146+ULONG WINAPI glDirect3DViewport2_Release(glDirect3DViewport2 *This);
 147+HRESULT WINAPI glDirect3DViewport2_AddLight(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpLight);
 148+HRESULT WINAPI glDirect3DViewport2_Clear(glDirect3DViewport2 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
 149+HRESULT WINAPI glDirect3DViewport2_DeleteLight(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 150+HRESULT WINAPI glDirect3DViewport2_GetBackground(glDirect3DViewport2 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
 151+HRESULT WINAPI glDirect3DViewport2_GetBackgroundDepth(glDirect3DViewport2 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
 152+HRESULT WINAPI glDirect3DViewport2_GetViewport(glDirect3DViewport2 *This, LPD3DVIEWPORT lpData);
 153+HRESULT WINAPI glDirect3DViewport2_GetViewport2(glDirect3DViewport2 *This, LPD3DVIEWPORT2 lpData);
 154+HRESULT WINAPI glDirect3DViewport2_Initialize(glDirect3DViewport2 *This, LPDIRECT3D lpDirect3D);
 155+HRESULT WINAPI glDirect3DViewport2_LightElements(glDirect3DViewport2 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData);
 156+HRESULT WINAPI glDirect3DViewport2_NextLight(glDirect3DViewport2 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
 157+HRESULT WINAPI glDirect3DViewport2_SetBackground(glDirect3DViewport2 *This, D3DMATERIALHANDLE hMat);
 158+HRESULT WINAPI glDirect3DViewport2_SetBackgroundDepth(glDirect3DViewport2 *This, LPDIRECTDRAWSURFACE lpDDSurface);
 159+HRESULT WINAPI glDirect3DViewport2_SetViewport(glDirect3DViewport2 *This, LPD3DVIEWPORT lpData);
 160+HRESULT WINAPI glDirect3DViewport2_SetViewport2(glDirect3DViewport2 *This, LPD3DVIEWPORT2 lpData);
 161+HRESULT WINAPI glDirect3DViewport2_TransformVertices(glDirect3DViewport2 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
 162+
 163+
 164+struct glDirect3DViewport1Vtbl;
 165+
 166+typedef struct glDirect3DViewport1
 167+{
 168+ glDirect3DViewport1Vtbl *lpVtbl;
124169 glDirect3DViewport3 *glD3DV3;
125170 int refcount;
126171 };
127172
 173+typedef struct glDirect3DViewport1Vtbl
 174+{
 175+ HRESULT(WINAPI *QueryInterface)(glDirect3DViewport1 *This, REFIID riid, void** ppvObj);
 176+ ULONG(WINAPI *AddRef)(glDirect3DViewport1 *This);
 177+ ULONG(WINAPI *Release)(glDirect3DViewport1 *This);
 178+ HRESULT(WINAPI *Initialize)(glDirect3DViewport1 *This, LPDIRECT3D lpDirect3D);
 179+ HRESULT(WINAPI *GetViewport)(glDirect3DViewport1 *This, LPD3DVIEWPORT lpData);
 180+ HRESULT(WINAPI *SetViewport)(glDirect3DViewport1 *This, LPD3DVIEWPORT lpData);
 181+ HRESULT(WINAPI *TransformVertices)(glDirect3DViewport1 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
 182+ HRESULT(WINAPI *LightElements)(glDirect3DViewport1 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData);
 183+ HRESULT(WINAPI *SetBackground)(glDirect3DViewport1 *This, D3DMATERIALHANDLE hMat);
 184+ HRESULT(WINAPI *GetBackground)(glDirect3DViewport1 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
 185+ HRESULT(WINAPI *SetBackgroundDepth)(glDirect3DViewport1 *This, LPDIRECTDRAWSURFACE lpDDSurface);
 186+ HRESULT(WINAPI *GetBackgroundDepth)(glDirect3DViewport1 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
 187+ HRESULT(WINAPI *Clear)(glDirect3DViewport1 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
 188+ HRESULT(WINAPI *AddLight)(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpLight);
 189+ HRESULT(WINAPI *DeleteLight)(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 190+ HRESULT(WINAPI *NextLight)(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
 191+};
 192+
 193+HRESULT glDirect3DViewport1_Create(glDirect3DViewport3 *glD3DV3, LPDIRECT3DVIEWPORT *viewport);
 194+
 195+HRESULT WINAPI glDirect3DViewport1_QueryInterface(glDirect3DViewport1 *This, REFIID riid, void** ppvObj);
 196+ULONG WINAPI glDirect3DViewport1_AddRef(glDirect3DViewport1 *This);
 197+ULONG WINAPI glDirect3DViewport1_Release(glDirect3DViewport1 *This);
 198+HRESULT WINAPI glDirect3DViewport1_AddLight(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpLight);
 199+HRESULT WINAPI glDirect3DViewport1_Clear(glDirect3DViewport1 *This, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
 200+HRESULT WINAPI glDirect3DViewport1_DeleteLight(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpDirect3DLight);
 201+HRESULT WINAPI glDirect3DViewport1_GetBackground(glDirect3DViewport1 *This, LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
 202+HRESULT WINAPI glDirect3DViewport1_GetBackgroundDepth(glDirect3DViewport1 *This, LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
 203+HRESULT WINAPI glDirect3DViewport1_GetViewport(glDirect3DViewport1 *This, LPD3DVIEWPORT lpData);
 204+HRESULT WINAPI glDirect3DViewport1_Initialize(glDirect3DViewport1 *This, LPDIRECT3D lpDirect3D);
 205+HRESULT WINAPI glDirect3DViewport1_LightElements(glDirect3DViewport1 *This, DWORD dwElementCount, LPD3DLIGHTDATA lpData);
 206+HRESULT WINAPI glDirect3DViewport1_NextLight(glDirect3DViewport1 *This, LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
 207+HRESULT WINAPI glDirect3DViewport1_SetBackground(glDirect3DViewport1 *This, D3DMATERIALHANDLE hMat);
 208+HRESULT WINAPI glDirect3DViewport1_SetBackgroundDepth(glDirect3DViewport1 *This, LPDIRECTDRAWSURFACE lpDDSurface);
 209+HRESULT WINAPI glDirect3DViewport1_SetViewport(glDirect3DViewport1 *This, LPD3DVIEWPORT lpData);
 210+HRESULT WINAPI glDirect3DViewport1_TransformVertices(glDirect3DViewport1 *This, DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
 211+
 212+#ifdef __cplusplus
 213+}
 214+#endif
 215+
128216 #endif //__GLDIRECT3DVIEWPORT_H
\ No newline at end of file
Index: ddraw/glDirectDrawPalette.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011 William Feely
 3+// Copyright (C) 2011-2014 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public