Index: ddraw/glDirect3DMaterial.cpp |
— | — | @@ -37,8 +37,8 @@ |
38 | 38 | material.hTexture = 0;
|
39 | 39 | material.dwRampSize = 0;
|
40 | 40 | handle = 0;
|
41 | | - glD3DM2 = NULL;
|
42 | | - glD3DM1 = NULL;
|
| 41 | + glD3DM2 = new glDirect3DMaterial2(this);
|
| 42 | + glD3DM1 = new glDirect3DMaterial1(this);
|
43 | 43 | TRACE_EXIT(-1,0);
|
44 | 44 | }
|
45 | 45 |
|
— | — | @@ -46,6 +46,8 @@ |
47 | 47 | {
|
48 | 48 | TRACE_ENTER(1,14,this);
|
49 | 49 | if(device) device->Release();
|
| 50 | + delete glD3DM2;
|
| 51 | + delete glD3DM1;
|
50 | 52 | TRACE_EXIT(-1,0);
|
51 | 53 | }
|
52 | 54 |
|
— | — | @@ -71,45 +73,21 @@ |
72 | 74 | }
|
73 | 75 | if(riid == IID_IDirect3DMaterial2)
|
74 | 76 | {
|
75 | | - if(glD3DM2)
|
76 | | - {
|
77 | | - *ppvObj = glD3DM2;
|
78 | | - glD3DM2->AddRef();
|
79 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
80 | | - TRACE_EXIT(23,D3D_OK);
|
81 | | - return D3D_OK;
|
82 | | - }
|
83 | | - else
|
84 | | - {
|
85 | | - this->AddRef();
|
86 | | - *ppvObj = new glDirect3DMaterial2(this);
|
87 | | - glD3DM2 = (glDirect3DMaterial2*)*ppvObj;
|
88 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
89 | | - TRACE_EXIT(23,D3D_OK);
|
90 | | - return D3D_OK;
|
91 | | - }
|
| 77 | + this - AddRef();
|
| 78 | + *ppvObj = glD3DM2;
|
| 79 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 80 | + TRACE_EXIT(23,D3D_OK);
|
| 81 | + return D3D_OK;
|
92 | 82 | }
|
93 | 83 | if(riid == IID_IDirect3DMaterial)
|
94 | 84 | {
|
95 | | - if(glD3DM1)
|
96 | | - {
|
97 | | - *ppvObj = glD3DM1;
|
98 | | - glD3DM1->AddRef();
|
99 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
100 | | - TRACE_EXIT(23,D3D_OK);
|
101 | | - return D3D_OK;
|
102 | | - }
|
103 | | - else
|
104 | | - {
|
105 | | - this->AddRef();
|
106 | | - *ppvObj = new glDirect3DMaterial1(this);
|
107 | | - glD3DM1 = (glDirect3DMaterial1*)*ppvObj;
|
108 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
109 | | - TRACE_EXIT(23,D3D_OK);
|
110 | | - return D3D_OK;
|
111 | | - }
|
| 85 | + this - AddRef();
|
| 86 | + *ppvObj = glD3DM1;
|
| 87 | + TRACE_VAR("*ppvObj", 14, *ppvObj);
|
| 88 | + TRACE_EXIT(23, D3D_OK);
|
| 89 | + return D3D_OK;
|
112 | 90 | }
|
113 | | - TRACE_EXIT(23,E_NOINTERFACE);
|
| 91 | + TRACE_EXIT(23, E_NOINTERFACE);
|
114 | 92 | return E_NOINTERFACE;
|
115 | 93 | }
|
116 | 94 |
|
— | — | @@ -215,26 +193,15 @@ |
216 | 194 | glDirect3DMaterial2::glDirect3DMaterial2(glDirect3DMaterial3 *glD3DM3)
|
217 | 195 | {
|
218 | 196 | TRACE_ENTER(2,14,this,14,glD3DM3);
|
219 | | - refcount = 1;
|
220 | 197 | this->glD3DM3 = glD3DM3;
|
221 | 198 | TRACE_EXIT(-1,0);
|
222 | 199 | }
|
223 | 200 |
|
224 | | -glDirect3DMaterial2::~glDirect3DMaterial2()
|
225 | | -{
|
226 | | - TRACE_ENTER(1,14,this);
|
227 | | - glD3DM3->glD3DM2 = NULL;
|
228 | | - glD3DM3->Release();
|
229 | | - TRACE_EXIT(-1,0);
|
230 | | -}
|
231 | | -
|
232 | 201 | ULONG WINAPI glDirect3DMaterial2::AddRef()
|
233 | 202 | {
|
234 | 203 | TRACE_ENTER(1,14,this);
|
235 | 204 | if(!this) TRACE_RET(ULONG,8,0);
|
236 | | - refcount++;
|
237 | | - TRACE_EXIT(8,refcount);
|
238 | | - return refcount;
|
| 205 | + TRACE_RET(ULONG, 8, glD3DM3->AddRef());
|
239 | 206 | }
|
240 | 207 |
|
241 | 208 | ULONG WINAPI glDirect3DMaterial2::Release()
|
— | — | @@ -241,12 +208,7 @@ |
242 | 209 | {
|
243 | 210 | TRACE_ENTER(1,14,this);
|
244 | 211 | if(!this) TRACE_RET(ULONG,8,0);
|
245 | | - ULONG ret;
|
246 | | - refcount--;
|
247 | | - ret = refcount;
|
248 | | - if(refcount == 0) delete this;
|
249 | | - TRACE_EXIT(8,ret);
|
250 | | - return ret;
|
| 212 | + TRACE_RET(ULONG, 8, glD3DM3->Release());
|
251 | 213 | }
|
252 | 214 |
|
253 | 215 | HRESULT WINAPI glDirect3DMaterial2::QueryInterface(REFIID riid, void** ppvObj)
|
— | — | @@ -294,26 +256,15 @@ |
295 | 257 | glDirect3DMaterial1::glDirect3DMaterial1(glDirect3DMaterial3 *glD3DM3)
|
296 | 258 | {
|
297 | 259 | TRACE_ENTER(2,14,this,14,glD3DM3);
|
298 | | - refcount = 1;
|
299 | 260 | this->glD3DM3 = glD3DM3;
|
300 | 261 | TRACE_EXIT(-1,0);
|
301 | 262 | }
|
302 | 263 |
|
303 | | -glDirect3DMaterial1::~glDirect3DMaterial1()
|
304 | | -{
|
305 | | - TRACE_ENTER(1,14,this);
|
306 | | - glD3DM3->glD3DM1 = NULL;
|
307 | | - glD3DM3->Release();
|
308 | | - TRACE_EXIT(-1,0);
|
309 | | -}
|
310 | | -
|
311 | 264 | ULONG WINAPI glDirect3DMaterial1::AddRef()
|
312 | 265 | {
|
313 | 266 | TRACE_ENTER(1,14,this);
|
314 | 267 | if(!this) TRACE_RET(ULONG,8,0);
|
315 | | - refcount++;
|
316 | | - TRACE_EXIT(8,refcount);
|
317 | | - return refcount;
|
| 268 | + TRACE_RET(ULONG, 8, glD3DM3->AddRef());
|
318 | 269 | }
|
319 | 270 |
|
320 | 271 | ULONG WINAPI glDirect3DMaterial1::Release()
|
— | — | @@ -320,12 +271,7 @@ |
321 | 272 | {
|
322 | 273 | TRACE_ENTER(1,14,this);
|
323 | 274 | if(!this) TRACE_RET(ULONG,8,0);
|
324 | | - ULONG ret;
|
325 | | - refcount--;
|
326 | | - ret = refcount;
|
327 | | - if(refcount == 0) delete this;
|
328 | | - TRACE_EXIT(8,ret);
|
329 | | - return ret;
|
| 275 | + TRACE_RET(ULONG, 8, glD3DM3->Release());
|
330 | 276 | }
|
331 | 277 |
|
332 | 278 | HRESULT WINAPI glDirect3DMaterial1::QueryInterface(REFIID riid, void** ppvObj)
|
Index: ddraw/glDirect3DMaterial.h |
— | — | @@ -49,7 +49,6 @@ |
50 | 50 | {
|
51 | 51 | public:
|
52 | 52 | glDirect3DMaterial2(glDirect3DMaterial3 *glD3DM3);
|
53 | | - virtual ~glDirect3DMaterial2();
|
54 | 53 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
55 | 54 | ULONG WINAPI AddRef();
|
56 | 55 | ULONG WINAPI Release();
|
— | — | @@ -57,7 +56,6 @@ |
58 | 57 | HRESULT WINAPI GetMaterial(LPD3DMATERIAL lpMat);
|
59 | 58 | HRESULT WINAPI SetMaterial(LPD3DMATERIAL lpMat);
|
60 | 59 | private:
|
61 | | - ULONG refcount;
|
62 | 60 | glDirect3DMaterial3 *glD3DM3;
|
63 | 61 | };
|
64 | 62 |
|
— | — | @@ -65,7 +63,6 @@ |
66 | 64 | {
|
67 | 65 | public:
|
68 | 66 | glDirect3DMaterial1(glDirect3DMaterial3 *glD3DM3);
|
69 | | - virtual ~glDirect3DMaterial1();
|
70 | 67 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
71 | 68 | ULONG WINAPI AddRef();
|
72 | 69 | ULONG WINAPI Release();
|
— | — | @@ -76,7 +73,6 @@ |
77 | 74 | HRESULT WINAPI SetMaterial(LPD3DMATERIAL lpMat);
|
78 | 75 | HRESULT WINAPI Unreserve();
|
79 | 76 | private:
|
80 | | - ULONG refcount;
|
81 | 77 | glDirect3DMaterial3 *glD3DM3;
|
82 | 78 | };
|
83 | 79 |
|