Index: ddraw/ddraw.vcxproj |
— | — | @@ -170,7 +170,9 @@ |
171 | 171 | <ClInclude Include="glDirect3D.h" />
|
172 | 172 | <ClInclude Include="glDirect3DDevice.h" />
|
173 | 173 | <ClInclude Include="glDirect3DLight.h" />
|
| 174 | + <ClInclude Include="glDirect3DMaterial.h" />
|
174 | 175 | <ClInclude Include="glDirect3DVertexBuffer.h" />
|
| 176 | + <ClInclude Include="glDirect3DViewport.h" />
|
175 | 177 | <ClInclude Include="glDirectDraw.h" />
|
176 | 178 | <ClInclude Include="glDirectDrawClipper.h" />
|
177 | 179 | <ClInclude Include="glDirectDrawPalette.h" />
|
— | — | @@ -217,7 +219,9 @@ |
218 | 220 | <ClCompile Include="glDirect3D.cpp" />
|
219 | 221 | <ClCompile Include="glDirect3DDevice.cpp" />
|
220 | 222 | <ClCompile Include="glDirect3DLight.cpp" />
|
| 223 | + <ClCompile Include="glDirect3DMaterial.cpp" />
|
221 | 224 | <ClCompile Include="glDirect3DVertexBuffer.cpp" />
|
| 225 | + <ClCompile Include="glDirect3DViewport.cpp" />
|
222 | 226 | <ClCompile Include="glDirectDraw.cpp" />
|
223 | 227 | <ClCompile Include="glDirectDrawClipper.cpp" />
|
224 | 228 | <ClCompile Include="glDirectDrawPalette.cpp" />
|
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -107,6 +107,12 @@ |
108 | 108 | <ClInclude Include="glDirect3DVertexBuffer.h">
|
109 | 109 | <Filter>Header Files</Filter>
|
110 | 110 | </ClInclude>
|
| 111 | + <ClInclude Include="glDirect3DViewport.h">
|
| 112 | + <Filter>Header Files</Filter>
|
| 113 | + </ClInclude>
|
| 114 | + <ClInclude Include="glDirect3DMaterial.h">
|
| 115 | + <Filter>Header Files</Filter>
|
| 116 | + </ClInclude>
|
111 | 117 | </ItemGroup>
|
112 | 118 | <ItemGroup>
|
113 | 119 | <ClCompile Include="ddraw.cpp">
|
— | — | @@ -172,6 +178,12 @@ |
173 | 179 | <ClCompile Include="glDirect3DVertexBuffer.cpp">
|
174 | 180 | <Filter>Source Files</Filter>
|
175 | 181 | </ClCompile>
|
| 182 | + <ClCompile Include="glDirect3DViewport.cpp">
|
| 183 | + <Filter>Source Files</Filter>
|
| 184 | + </ClCompile>
|
| 185 | + <ClCompile Include="glDirect3DMaterial.cpp">
|
| 186 | + <Filter>Source Files</Filter>
|
| 187 | + </ClCompile>
|
176 | 188 | </ItemGroup>
|
177 | 189 | <ItemGroup>
|
178 | 190 | <ResourceCompile Include="ddraw.rc">
|
Index: ddraw/glDirect3D.cpp |
— | — | @@ -209,7 +209,6 @@ |
210 | 210 | *ppvObj = new glDirect3D3(this);
|
211 | 211 | return D3D_OK;
|
212 | 212 | }
|
213 | | - FIXME("glDirect3D7::QueryInterface: stub");
|
214 | 213 | return E_NOINTERFACE;
|
215 | 214 | }
|
216 | 215 |
|
— | — | @@ -419,7 +418,6 @@ |
420 | 419 | glDirect3D3::glDirect3D3(glDirect3D7 *glD3D7)
|
421 | 420 | {
|
422 | 421 | this->glD3D7 = glD3D7;
|
423 | | - glD3D7->AddRef();
|
424 | 422 | refcount = 1;
|
425 | 423 | }
|
426 | 424 |
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | #include "glRenderer.h"
|
23 | 23 | #include "glDirectDraw.h"
|
24 | 24 | #include "glDirectDrawSurface.h"
|
| 25 | +#include "glDirect3DMaterial.h"
|
25 | 26 | #include "glDirect3DDevice.h"
|
26 | 27 | #include "glDirect3DLight.h"
|
27 | 28 | #include <string>
|
— | — | @@ -207,6 +208,10 @@ |
208 | 209 | glDirect3DDevice7::glDirect3DDevice7(glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7)
|
209 | 210 | {
|
210 | 211 | int zbuffer = 0;
|
| 212 | + maxmaterials = 32;
|
| 213 | + materials = (glDirect3DMaterial3**)malloc(32*sizeof(glDirect3DMaterial3*));
|
| 214 | + materialcount = 1;
|
| 215 | + materials[0] = NULL;
|
211 | 216 | vertices = normals = NULL;
|
212 | 217 | diffuse = specular = NULL;
|
213 | 218 | ZeroMemory(texcoords,8*sizeof(GLfloat*));
|
— | — | @@ -244,6 +249,15 @@ |
245 | 250 | delete lights;
|
246 | 251 | for(int i = 0; i < 8; i++)
|
247 | 252 | if(texstages[i].texture) texstages[i].texture->Release();
|
| 253 | + for(int i = 0; i < materialcount; i++)
|
| 254 | + {
|
| 255 | + if(materials[i])
|
| 256 | + {
|
| 257 | + materials[i]->unbind();
|
| 258 | + materials[i]->Release();
|
| 259 | + }
|
| 260 | + }
|
| 261 | + free(materials);
|
248 | 262 | glD3D7->Release();
|
249 | 263 | glDDS7->Release();
|
250 | 264 | }
|
— | — | @@ -270,6 +284,18 @@ |
271 | 285 | *ppvObj = this;
|
272 | 286 | return D3D_OK;
|
273 | 287 | }
|
| 288 | + if(riid == IID_IDirect3DDevice7)
|
| 289 | + {
|
| 290 | + this->AddRef();
|
| 291 | + *ppvObj = this;
|
| 292 | + return D3D_OK;
|
| 293 | + }
|
| 294 | + if(riid == IID_IDirect3DDevice3)
|
| 295 | + {
|
| 296 | + this->AddRef();
|
| 297 | + *ppvObj = new glDirect3DDevice3(this);
|
| 298 | + return D3D_OK;
|
| 299 | + }
|
274 | 300 | ERR(E_NOINTERFACE);
|
275 | 301 | }
|
276 | 302 |
|
— | — | @@ -1271,4 +1297,107 @@ |
1272 | 1298 | ::SetDepthComp(GL_ALWAYS);
|
1273 | 1299 | break;
|
1274 | 1300 | }
|
1275 | | -} |
\ No newline at end of file |
| 1301 | +}
|
| 1302 | +
|
| 1303 | +D3DMATERIALHANDLE glDirect3DDevice7::AddMaterial(glDirect3DMaterial3 *material)
|
| 1304 | +{
|
| 1305 | + materials[materialcount] = material;
|
| 1306 | + material->AddRef();
|
| 1307 | + materialcount++;
|
| 1308 | + if(materialcount >= maxmaterials)
|
| 1309 | + {
|
| 1310 | + maxmaterials += 32;
|
| 1311 | + materials = (glDirect3DMaterial3**)realloc(materials,maxmaterials*sizeof(glDirect3DMaterial3*));
|
| 1312 | + }
|
| 1313 | + return materialcount-1;
|
| 1314 | +}
|
| 1315 | +
|
| 1316 | +// IDirect3DDevice3 wrapper
|
| 1317 | +glDirect3DDevice3::glDirect3DDevice3(glDirect3DDevice7 *glD3DDev7)
|
| 1318 | +{
|
| 1319 | + this->glD3DDev7 = glD3DDev7;
|
| 1320 | + refcount = 1;
|
| 1321 | +}
|
| 1322 | +
|
| 1323 | +glDirect3DDevice3::~glDirect3DDevice3()
|
| 1324 | +{
|
| 1325 | + glD3DDev7->Release();
|
| 1326 | +}
|
| 1327 | +
|
| 1328 | +HRESULT WINAPI glDirect3DDevice3::QueryInterface(REFIID riid, void** ppvObj)
|
| 1329 | +{
|
| 1330 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 1331 | + if(riid == IID_IUnknown)
|
| 1332 | + {
|
| 1333 | + this->AddRef();
|
| 1334 | + *ppvObj = this;
|
| 1335 | + return DD_OK;
|
| 1336 | + }
|
| 1337 | + return glD3DDev7->QueryInterface(riid,ppvObj);
|
| 1338 | +}
|
| 1339 | +
|
| 1340 | +ULONG WINAPI glDirect3DDevice3::AddRef()
|
| 1341 | +{
|
| 1342 | + if(!this) return 0;
|
| 1343 | + refcount++;
|
| 1344 | + return refcount;
|
| 1345 | +}
|
| 1346 | +
|
| 1347 | +ULONG WINAPI glDirect3DDevice3::Release()
|
| 1348 | +{
|
| 1349 | + if(!this) return 0;
|
| 1350 | + ULONG ret;
|
| 1351 | + refcount--;
|
| 1352 | + ret = refcount;
|
| 1353 | + if(refcount == 0) delete this;
|
| 1354 | + return ret;
|
| 1355 | +}
|
| 1356 | +
|
| 1357 | +HRESULT WINAPI glDirect3DDevice3::AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
|
| 1358 | +{
|
| 1359 | +}
|
| 1360 | +
|
| 1361 | + HRESULT WINAPI Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags);
|
| 1362 | + HRESULT WINAPI BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
|
| 1363 | + HRESULT WINAPI BeginScene();
|
| 1364 | + HRESULT WINAPI ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
|
| 1365 | + HRESULT WINAPI DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
| 1366 | + HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
| 1367 | + LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 1368 | + HRESULT WINAPI DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
| 1369 | + LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVerticexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 1370 | + HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
|
| 1371 | + LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 1372 | + HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
|
| 1373 | + DWORD dwVertexCount, DWORD dwFlags);
|
| 1374 | + HRESULT WINAPI DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,
|
| 1375 | + LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, DWORD dwFlags);
|
| 1376 | + HRESULT WINAPI DrawPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
|
| 1377 | + DWORD dwStartVertex, DWORD dwNumVertices, DWORD dwFlags);
|
| 1378 | + HRESULT WINAPI End(DWORD dwFlags);
|
| 1379 | + HRESULT WINAPI EndScene();
|
| 1380 | + HRESULT WINAPI EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg);
|
| 1381 | + HRESULT WINAPI GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
|
| 1382 | + HRESULT WINAPI GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
| 1383 | + HRESULT WINAPI GetCurrentViewport(LPDIRECT3DVIEWPORT3 *lplpd3dViewport);
|
| 1384 | + HRESULT WINAPI GetDirect3D(LPDIRECT3D3 *lplpD3D);
|
| 1385 | + HRESULT WINAPI GetLightState(D3DLIGHTSTATETYPE dwLightStateType, LPDWORD lpdwLightState);
|
| 1386 | + HRESULT WINAPI GetRenderState(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState);
|
| 1387 | + HRESULT WINAPI GetRenderTarget(LPDIRECTDRAWSURFACE4 *lplpRenderTarget);
|
| 1388 | + HRESULT WINAPI GetStats(LPD3DSTATS lpD3DStats);
|
| 1389 | + HRESULT WINAPI GetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 * lplpTexture);
|
| 1390 | + HRESULT WINAPI GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, LPDWORD lpdwValue);
|
| 1391 | + HRESULT WINAPI GetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 1392 | + HRESULT WINAPI Index(WORD wVertexIndex);
|
| 1393 | + HRESULT WINAPI MultiplyTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 1394 | + HRESULT WINAPI NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport, LPDIRECT3DVIEWPORT3 *lplpAnotherViewport, DWORD dwFlags);
|
| 1395 | + HRESULT WINAPI SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
| 1396 | + HRESULT WINAPI SetCurrentViewport(LPDIRECT3DVIEWPORT3 lpd3dViewport);
|
| 1397 | + HRESULT WINAPI SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState);
|
| 1398 | + HRESULT WINAPI SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
| 1399 | + HRESULT WINAPI SetRenderTarget(LPDIRECTDRAWSURFACE4 lpNewRenderTarget, DWORD dwFlags);
|
| 1400 | + HRESULT WINAPI SetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 lpTexture);
|
| 1401 | + HRESULT WINAPI SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
| 1402 | + HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 1403 | + HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
|
| 1404 | + HRESULT WINAPI Vertex(LPVOID lpVertex);
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 |
|
58 | 58 | class glDirect3DLight;
|
59 | 59 | class glDirectDrawSurface7;
|
| 60 | +class glDirect3DMaterial3;
|
60 | 61 | class glDirect3DDevice7 : public IDirect3DDevice7
|
61 | 62 | {
|
62 | 63 | public:
|
— | — | @@ -122,6 +123,7 @@ |
123 | 124 | HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
|
124 | 125 | void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
|
125 | 126 | void SetDepthComp();
|
| 127 | + D3DMATERIALHANDLE AddMaterial(glDirect3DMaterial3* material);
|
126 | 128 | __int64 SelectShader(GLVERTEX *VertexType);
|
127 | 129 | void UpdateNormalMatrix();
|
128 | 130 | GLfloat matWorld[16];
|
— | — | @@ -137,6 +139,8 @@ |
138 | 140 | DWORD renderstate[153];
|
139 | 141 | TEXTURESTAGE texstages[8];
|
140 | 142 | glDirect3D7 *glD3D7;
|
| 143 | + glDirect3DMaterial3 **materials;
|
| 144 | + int materialcount;
|
141 | 145 |
|
142 | 146 | private:
|
143 | 147 | HRESULT fvftoglvertex(DWORD dwVertexTypeDesc,LPDWORD vertptr);
|
— | — | @@ -155,6 +159,66 @@ |
156 | 160 | GLfloat *texcoords[8];
|
157 | 161 | GLVERTEX vertdata[18];
|
158 | 162 | int texformats[8];
|
| 163 | + int maxmaterials;
|
159 | 164 | };
|
160 | 165 |
|
161 | | -#endif //__GLDIRECT3DDEVICE_H |
\ No newline at end of file |
| 166 | +#endif //__GLDIRECT3DDEVICE_H
|
| 167 | +
|
| 168 | +class glDirect3DDevice3 : public IDirect3DDevice3
|
| 169 | +{
|
| 170 | +public:
|
| 171 | + glDirect3DDevice3(glDirect3DDevice7 *glD3DDev7);
|
| 172 | + virtual ~glDirect3DDevice3();
|
| 173 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 174 | + ULONG WINAPI AddRef();
|
| 175 | + ULONG WINAPI Release();
|
| 176 | + HRESULT WINAPI AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
| 177 | + HRESULT WINAPI Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags);
|
| 178 | + HRESULT WINAPI BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
|
| 179 | + HRESULT WINAPI BeginScene();
|
| 180 | + HRESULT WINAPI ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
|
| 181 | + HRESULT WINAPI DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
| 182 | + HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
| 183 | + LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 184 | + HRESULT WINAPI DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
| 185 | + LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVerticexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 186 | + HRESULT WINAPI DrawIndexedPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
|
| 187 | + LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
|
| 188 | + HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
|
| 189 | + DWORD dwVertexCount, DWORD dwFlags);
|
| 190 | + HRESULT WINAPI DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,
|
| 191 | + LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, DWORD dwFlags);
|
| 192 | + HRESULT WINAPI DrawPrimitiveVB(D3DPRIMITIVETYPE d3dptPrimitiveType, LPDIRECT3DVERTEXBUFFER lpd3dVertexBuffer,
|
| 193 | + DWORD dwStartVertex, DWORD dwNumVertices, DWORD dwFlags);
|
| 194 | + HRESULT WINAPI End(DWORD dwFlags);
|
| 195 | + HRESULT WINAPI EndScene();
|
| 196 | + HRESULT WINAPI EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg);
|
| 197 | + HRESULT WINAPI GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
|
| 198 | + HRESULT WINAPI GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
| 199 | + HRESULT WINAPI GetCurrentViewport(LPDIRECT3DVIEWPORT3 *lplpd3dViewport);
|
| 200 | + HRESULT WINAPI GetDirect3D(LPDIRECT3D3 *lplpD3D);
|
| 201 | + HRESULT WINAPI GetLightState(D3DLIGHTSTATETYPE dwLightStateType, LPDWORD lpdwLightState);
|
| 202 | + HRESULT WINAPI GetRenderState(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState);
|
| 203 | + HRESULT WINAPI GetRenderTarget(LPDIRECTDRAWSURFACE4 *lplpRenderTarget);
|
| 204 | + HRESULT WINAPI GetStats(LPD3DSTATS lpD3DStats);
|
| 205 | + HRESULT WINAPI GetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 * lplpTexture);
|
| 206 | + HRESULT WINAPI GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, LPDWORD lpdwValue);
|
| 207 | + HRESULT WINAPI GetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 208 | + HRESULT WINAPI Index(WORD wVertexIndex);
|
| 209 | + HRESULT WINAPI MultiplyTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 210 | + HRESULT WINAPI NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport, LPDIRECT3DVIEWPORT3 *lplpAnotherViewport, DWORD dwFlags);
|
| 211 | + HRESULT WINAPI SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
| 212 | + HRESULT WINAPI SetCurrentViewport(LPDIRECT3DVIEWPORT3 lpd3dViewport);
|
| 213 | + HRESULT WINAPI SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState);
|
| 214 | + HRESULT WINAPI SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
| 215 | + HRESULT WINAPI SetRenderTarget(LPDIRECTDRAWSURFACE4 lpNewRenderTarget, DWORD dwFlags);
|
| 216 | + HRESULT WINAPI SetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 lpTexture);
|
| 217 | + HRESULT WINAPI SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
| 218 | + HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 219 | + HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
|
| 220 | + HRESULT WINAPI Vertex(LPVOID lpVertex);
|
| 221 | + glDirect3DDevice7 *GetGLD3DDev7(){return glD3DDev7;}
|
| 222 | +private:
|
| 223 | + glDirect3DDevice7 *glD3DDev7;
|
| 224 | + ULONG refcount;
|
| 225 | +}; |
\ No newline at end of file |
Index: ddraw/glDirect3DLight.cpp |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
19 | 19 | #include "common.h"
|
| 20 | +#include "glDirect3DViewport.h"
|
20 | 21 | #include "glDirect3DLight.h"
|
21 | 22 | #define _USE_MATH_DEFINES
|
22 | 23 | #include <math.h>
|
— | — | @@ -25,6 +26,7 @@ |
26 | 27 | glDirect3DLight::glDirect3DLight()
|
27 | 28 | {
|
28 | 29 | refcount=1;
|
| 30 | + viewport = NULL;
|
29 | 31 | ZeroMemory(&light,sizeof(D3DLIGHT7));
|
30 | 32 | light.dltType = D3DLIGHT_DIRECTIONAL;
|
31 | 33 | light.dcvAmbient.r = light.dcvAmbient.g = light.dcvAmbient.b = 1.0f;
|
Index: ddraw/glDirect3DLight.h |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | #ifndef __GLDIRECT3DLIGHT_H
|
21 | 21 | #define __GLDIRECT3DLIGHT_H
|
22 | 22 |
|
| 23 | +class glDirect3DViewport3;
|
23 | 24 | class glDirect3DLight : public IDirect3DLight
|
24 | 25 | {
|
25 | 26 | public:
|
— | — | @@ -25,7 +26,6 @@ |
26 | 27 | glDirect3DLight();
|
27 | 28 | glDirect3DLight(D3DLIGHT7 *light_in);
|
28 | 29 | virtual ~glDirect3DLight();
|
29 | | -
|
30 | 30 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
31 | 31 | ULONG WINAPI AddRef();
|
32 | 32 | ULONG WINAPI Release();
|
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | HRESULT WINAPI SetLight(LPD3DLIGHT lpLight);
|
37 | 37 | void SetLight7(LPD3DLIGHT7 lpLight7);
|
38 | 38 | D3DLIGHT7 light;
|
| 39 | + glDirect3DViewport3 *viewport;
|
39 | 40 | private:
|
40 | 41 | ULONG refcount;
|
41 | 42 | D3DLIGHT2 convert;
|
Index: ddraw/glDirect3DMaterial.cpp |
— | — | @@ -0,0 +1,108 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2012 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#include "common.h"
|
| 20 | +#include "glRenderer.h"
|
| 21 | +#include "glDirect3DDevice.h"
|
| 22 | +#include "glDirect3DMaterial.h"
|
| 23 | +
|
| 24 | +glDirect3DMaterial3::glDirect3DMaterial3()
|
| 25 | +{
|
| 26 | + device = NULL;
|
| 27 | + refcount = 1;
|
| 28 | + material.dwSize = sizeof(D3DMATERIAL);
|
| 29 | + const D3DCOLORVALUE defaultcolor = {1.0f,1.0f,1.0f,1.0f};
|
| 30 | + material.diffuse = material.ambient = material.specular =
|
| 31 | + material.emissive = defaultcolor;
|
| 32 | + material.power = 0.0f;
|
| 33 | + material.hTexture = 0;
|
| 34 | + material.dwRampSize = 0;
|
| 35 | + handle = 0;
|
| 36 | +}
|
| 37 | +
|
| 38 | +glDirect3DMaterial3::~glDirect3DMaterial3()
|
| 39 | +{
|
| 40 | + if(device) device->Release();
|
| 41 | +}
|
| 42 | +
|
| 43 | +HRESULT WINAPI glDirect3DMaterial3::QueryInterface(REFIID riid, void** ppvObj)
|
| 44 | +{
|
| 45 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 46 | + if(riid == IID_IUnknown)
|
| 47 | + {
|
| 48 | + this->AddRef();
|
| 49 | + *ppvObj = this;
|
| 50 | + return DD_OK;
|
| 51 | + }
|
| 52 | + return E_NOINTERFACE;
|
| 53 | +}
|
| 54 | +
|
| 55 | +ULONG WINAPI glDirect3DMaterial3::AddRef()
|
| 56 | +{
|
| 57 | + if(!this) return 0;
|
| 58 | + refcount++;
|
| 59 | + return refcount;
|
| 60 | +}
|
| 61 | +
|
| 62 | +ULONG WINAPI glDirect3DMaterial3::Release()
|
| 63 | +{
|
| 64 | + if(!this) return 0;
|
| 65 | + ULONG ret;
|
| 66 | + refcount--;
|
| 67 | + ret = refcount;
|
| 68 | + if(refcount == 0) delete this;
|
| 69 | + return ret;
|
| 70 | +}
|
| 71 | +
|
| 72 | +HRESULT WINAPI glDirect3DMaterial3::GetHandle(LPDIRECT3DDEVICE3 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle)
|
| 73 | +{
|
| 74 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 75 | + if(!lpDirect3DDevice) return DDERR_INVALIDOBJECT;
|
| 76 | + glDirect3DDevice3 *dev3 = (glDirect3DDevice3*)lpDirect3DDevice;
|
| 77 | + if(handle)
|
| 78 | + {
|
| 79 | + if(device != dev3->GetGLD3DDev7()) return DDERR_INVALIDOBJECT;
|
| 80 | + *lpHandle = handle;
|
| 81 | + return D3D_OK;
|
| 82 | + }
|
| 83 | + device = dev3->GetGLD3DDev7();
|
| 84 | + handle = device->AddMaterial(this);
|
| 85 | + *lpHandle = handle;
|
| 86 | + return D3D_OK;
|
| 87 | +}
|
| 88 | +
|
| 89 | +HRESULT WINAPI glDirect3DMaterial3::GetMaterial(LPD3DMATERIAL lpMat)
|
| 90 | +{
|
| 91 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 92 | + if(lpMat->dwSize < sizeof(D3DMATERIAL)) return DDERR_INVALIDPARAMS;
|
| 93 | + memcpy(lpMat,&material,sizeof(D3DMATERIAL));
|
| 94 | + return D3D_OK;
|
| 95 | +}
|
| 96 | +
|
| 97 | +HRESULT WINAPI glDirect3DMaterial3::SetMaterial(LPD3DMATERIAL lpMat)
|
| 98 | +{
|
| 99 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 100 | + if(lpMat->dwSize != sizeof(D3DMATERIAL)) return DDERR_INVALIDPARAMS;
|
| 101 | + memcpy(&material,lpMat,sizeof(D3DMATERIAL));
|
| 102 | + return D3D_OK;
|
| 103 | +}
|
| 104 | +
|
| 105 | +void glDirect3DMaterial3::unbind()
|
| 106 | +{
|
| 107 | + device = NULL;
|
| 108 | + handle = 0;
|
| 109 | +} |
\ No newline at end of file |
Index: ddraw/glDirect3DMaterial.h |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2012 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#pragma once
|
| 20 | +#ifndef __GLDIRECT3DMATERIAL_H
|
| 21 | +#define __GLDIRECT3DMATERIAL_H
|
| 22 | +
|
| 23 | +class glDirect3DMaterial3 : public IDirect3DMaterial3
|
| 24 | +{
|
| 25 | +public:
|
| 26 | + glDirect3DMaterial3();
|
| 27 | + virtual ~glDirect3DMaterial3();
|
| 28 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 29 | + ULONG WINAPI AddRef();
|
| 30 | + ULONG WINAPI Release();
|
| 31 | + HRESULT WINAPI GetHandle(LPDIRECT3DDEVICE3 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle);
|
| 32 | + HRESULT WINAPI GetMaterial(LPD3DMATERIAL lpMat);
|
| 33 | + HRESULT WINAPI SetMaterial(LPD3DMATERIAL lpMat);
|
| 34 | + void unbind();
|
| 35 | + D3DMATERIAL material;
|
| 36 | +private:
|
| 37 | + ULONG refcount;
|
| 38 | + glDirect3DDevice7 *device;
|
| 39 | + D3DMATERIALHANDLE handle;
|
| 40 | +};
|
| 41 | +
|
| 42 | +#endif //__GLDIRECT3DMATERIAL_H |
\ No newline at end of file |
Index: ddraw/glDirect3DViewport.cpp |
— | — | @@ -0,0 +1,260 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2011-2012 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#include "common.h"
|
| 20 | +#include "glRenderer.h"
|
| 21 | +#include "glDirectDraw.h"
|
| 22 | +#include "glDirectDrawSurface.h"
|
| 23 | +#include "glDirect3DLight.h"
|
| 24 | +#include "glDirect3DDevice.h"
|
| 25 | +#include "glDirect3DMaterial.h"
|
| 26 | +#include "glDirect3DViewport.h"
|
| 27 | +
|
| 28 | +inline D3DCOLOR d3dcvtod3dcolor(D3DCOLORVALUE value)
|
| 29 | +{
|
| 30 | + int r = (int)(value.r * 255);
|
| 31 | + int g = (int)(value.g * 255);
|
| 32 | + int b = (int)(value.b * 255);
|
| 33 | + int a = (int)(value.a * 255);
|
| 34 | + return b|(g<<8)|(r<<16)|(a<<24);
|
| 35 | +}
|
| 36 | +
|
| 37 | +glDirect3DViewport3::glDirect3DViewport3()
|
| 38 | +{
|
| 39 | + background = 0;
|
| 40 | + ZeroMemory(&viewport,sizeof(D3DVIEWPORT2));
|
| 41 | + viewport.dwSize = sizeof(D3DVIEWPORT2);
|
| 42 | + maxX = maxY = scaleX = scaleY = 0;
|
| 43 | + device = NULL;
|
| 44 | + backZ = NULL;
|
| 45 | + for(int i = 0; i < 8; i++)
|
| 46 | + lights[i] = NULL;
|
| 47 | + refcount = 1;
|
| 48 | +}
|
| 49 | +
|
| 50 | +glDirect3DViewport3::~glDirect3DViewport3()
|
| 51 | +{
|
| 52 | +}
|
| 53 | +
|
| 54 | +HRESULT WINAPI glDirect3DViewport3::QueryInterface(REFIID riid, void** ppvObj)
|
| 55 | +{
|
| 56 | + if(!this) return DDERR_INVALIDPARAMS;
|
| 57 | + if(riid == IID_IUnknown)
|
| 58 | + {
|
| 59 | + this->AddRef();
|
| 60 | + *ppvObj = this;
|
| 61 | + return DD_OK;
|
| 62 | + }
|
| 63 | + return E_NOINTERFACE;
|
| 64 | +}
|
| 65 | +
|
| 66 | +ULONG WINAPI glDirect3DViewport3::AddRef()
|
| 67 | +{
|
| 68 | + if(!this) return 0;
|
| 69 | + refcount++;
|
| 70 | + return refcount;
|
| 71 | +}
|
| 72 | +
|
| 73 | +ULONG WINAPI glDirect3DViewport3::Release()
|
| 74 | +{
|
| 75 | + if(!this) return 0;
|
| 76 | + ULONG ret;
|
| 77 | + refcount--;
|
| 78 | + ret = refcount;
|
| 79 | + if(refcount == 0) delete this;
|
| 80 | + return ret;
|
| 81 | +}
|
| 82 | +
|
| 83 | +HRESULT WINAPI glDirect3DViewport3::AddLight(LPDIRECT3DLIGHT lpDirect3DLight)
|
| 84 | +{
|
| 85 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 86 | + if(((glDirect3DLight*)lpDirect3DLight)->viewport) return D3DERR_LIGHTHASVIEWPORT;
|
| 87 | + for(int i = 0; i < 8; i++)
|
| 88 | + {
|
| 89 | + if(!lights[i])
|
| 90 | + {
|
| 91 | + lights[i] = (glDirect3DLight*)lpDirect3DLight;
|
| 92 | + lights[i]->AddRef();
|
| 93 | + lights[i]->viewport = this;
|
| 94 | + return D3D_OK;
|
| 95 | + }
|
| 96 | + }
|
| 97 | + return D3DERR_LIGHT_SET_FAILED;
|
| 98 | +}
|
| 99 | +
|
| 100 | +HRESULT WINAPI glDirect3DViewport3::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags)
|
| 101 | +{
|
| 102 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 103 | + if(!device) return D3DERR_VIEWPORTHASNODEVICE;
|
| 104 | + D3DCOLORVALUE bgcolor = {0.0,0.0,0.0,0.0};
|
| 105 | + if(device->materials[background]) bgcolor = device->materials[background]->material.diffuse;
|
| 106 | + return device->Clear(dwCount,lpRects,dwFlags,d3dcvtod3dcolor(bgcolor),0.0,0);
|
| 107 | +}
|
| 108 | +
|
| 109 | +HRESULT WINAPI glDirect3DViewport3::Clear2(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
| 110 | +{
|
| 111 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 112 | + if(!device) return D3DERR_VIEWPORTHASNODEVICE;
|
| 113 | + return device->Clear(dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil);
|
| 114 | +}
|
| 115 | +
|
| 116 | +HRESULT WINAPI glDirect3DViewport3::DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight)
|
| 117 | +{
|
| 118 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 119 | + if(!lpDirect3DLight) return DDERR_INVALIDPARAMS;
|
| 120 | + for(int i = 0; i < 8; i++)
|
| 121 | + {
|
| 122 | + if(lights[i] == lpDirect3DLight)
|
| 123 | + {
|
| 124 | + lights[i]->Release();
|
| 125 | + lights[i] = NULL;
|
| 126 | + return D3D_OK;
|
| 127 | + }
|
| 128 | + }
|
| 129 | + return D3DERR_LIGHTNOTINTHISVIEWPORT;
|
| 130 | +}
|
| 131 | +
|
| 132 | +HRESULT WINAPI glDirect3DViewport3::GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid)
|
| 133 | +{
|
| 134 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 135 | + if(!lphMat) return DDERR_INVALIDPARAMS;
|
| 136 | + if(lpValid)
|
| 137 | + {
|
| 138 | + if(background) *lpValid = TRUE;
|
| 139 | + else *lpValid = FALSE;
|
| 140 | + }
|
| 141 | + *lphMat = background;
|
| 142 | + return D3D_OK;
|
| 143 | +}
|
| 144 | +
|
| 145 | +HRESULT WINAPI glDirect3DViewport3::GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid)
|
| 146 | +{
|
| 147 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 148 | + if(!lplpDDSurface) return DDERR_INVALIDPARAMS;
|
| 149 | + if(lpValid)
|
| 150 | + {
|
| 151 | + if(backZ) *lpValid = TRUE;
|
| 152 | + else *lpValid = FALSE;
|
| 153 | + }
|
| 154 | + if(backZ) backZ->QueryInterface(IID_IDirectDrawSurface,(void**)lplpDDSurface);
|
| 155 | + else *lplpDDSurface = NULL;
|
| 156 | + return D3D_OK;
|
| 157 | +}
|
| 158 | +HRESULT WINAPI glDirect3DViewport3::GetBackgroundDepth2(LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid)
|
| 159 | +{
|
| 160 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 161 | + if(!lplpDDS) return DDERR_INVALIDPARAMS;
|
| 162 | + if(lpValid)
|
| 163 | + {
|
| 164 | + if(backZ) *lpValid = TRUE;
|
| 165 | + else *lpValid = FALSE;
|
| 166 | + }
|
| 167 | + if(backZ) backZ->QueryInterface(IID_IDirectDrawSurface4,(void**)lplpDDS);
|
| 168 | + else *lplpDDS = NULL;
|
| 169 | + return D3D_OK;
|
| 170 | +}
|
| 171 | +HRESULT WINAPI glDirect3DViewport3::GetViewport(LPD3DVIEWPORT lpData)
|
| 172 | +{
|
| 173 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 174 | + if(!lpData) return DDERR_INVALIDPARAMS;
|
| 175 | + memcpy(lpData,&viewport,sizeof(D3DVIEWPORT2));
|
| 176 | + lpData->dvScaleX = scaleX;
|
| 177 | + lpData->dvScaleY = scaleY;
|
| 178 | + lpData->dvMaxX = maxX;
|
| 179 | + lpData->dvMaxY = maxY;
|
| 180 | + return D3D_OK;
|
| 181 | +}
|
| 182 | +HRESULT WINAPI glDirect3DViewport3::GetViewport2(LPD3DVIEWPORT2 lpData)
|
| 183 | +{
|
| 184 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 185 | + if(!lpData) return DDERR_INVALIDPARAMS;
|
| 186 | + memcpy(lpData,&viewport,sizeof(D3DVIEWPORT2));
|
| 187 | + return D3D_OK;
|
| 188 | +}
|
| 189 | +HRESULT WINAPI glDirect3DViewport3::Initialize(LPDIRECT3D lpDirect3D)
|
| 190 | +{
|
| 191 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 192 | + return DDERR_ALREADYINITIALIZED;
|
| 193 | +}
|
| 194 | +HRESULT WINAPI glDirect3DViewport3::LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData)
|
| 195 | +{
|
| 196 | + return E_NOTIMPL;
|
| 197 | +}
|
| 198 | +HRESULT WINAPI glDirect3DViewport3::NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags)
|
| 199 | +{
|
| 200 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 201 | + if(!lplpDirect3DLight) return DDERR_INVALIDPARAMS;
|
| 202 | + FIXME("glDirect3DViewport3::NextLight: stub");
|
| 203 | + return DDERR_GENERIC;
|
| 204 | +}
|
| 205 | +HRESULT WINAPI glDirect3DViewport3::SetBackground(D3DMATERIALHANDLE hMat)
|
| 206 | +{
|
| 207 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 208 | + if(!device) return D3DERR_VIEWPORTHASNODEVICE;
|
| 209 | + if(hMat > device->materialcount) return DDERR_INVALIDPARAMS;
|
| 210 | + background = hMat;
|
| 211 | + return D3D_OK;
|
| 212 | +}
|
| 213 | +HRESULT WINAPI glDirect3DViewport3::SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface)
|
| 214 | +{
|
| 215 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 216 | + if(!backZ && !lpDDSurface) return D3D_OK;
|
| 217 | + if(((glDirectDrawSurface1*)lpDDSurface)->GetDDS7() == backZ) return D3D_OK;
|
| 218 | + if(backZ)backZ->Release();
|
| 219 | + if(lpDDSurface) lpDDSurface->QueryInterface(IID_IDirectDrawSurface7,(void**)&backZ);
|
| 220 | + else backZ = NULL;
|
| 221 | + return D3D_OK;
|
| 222 | +}
|
| 223 | +HRESULT WINAPI glDirect3DViewport3::SetBackgroundDepth2(LPDIRECTDRAWSURFACE4 lpDDS)
|
| 224 | +{
|
| 225 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 226 | + if(!backZ && !lpDDS) return D3D_OK;
|
| 227 | + if(((glDirectDrawSurface4*)lpDDS)->GetDDS7() == backZ) return D3D_OK;
|
| 228 | + if(backZ)backZ->Release();
|
| 229 | + if(lpDDS) lpDDS->QueryInterface(IID_IDirectDrawSurface7,(void**)&backZ);
|
| 230 | + else backZ = NULL;
|
| 231 | + return D3D_OK;
|
| 232 | +}
|
| 233 | +
|
| 234 | +HRESULT WINAPI glDirect3DViewport3::SetViewport(LPD3DVIEWPORT lpData)
|
| 235 | +{
|
| 236 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 237 | + if(!device) return D3DERR_VIEWPORTHASNODEVICE;
|
| 238 | + if(!lpData) return DDERR_INVALIDPARAMS;
|
| 239 | + D3DVIEWPORT2 vp;
|
| 240 | + memcpy(&vp,lpData,sizeof(D3DVIEWPORT));
|
| 241 | + vp.dvClipHeight = viewport.dvClipHeight;
|
| 242 | + vp.dvClipWidth = viewport.dvClipWidth;
|
| 243 | + vp.dvClipX = viewport.dvClipX;
|
| 244 | + vp.dvClipY = viewport.dvClipY;
|
| 245 | + viewport = vp;
|
| 246 | + return D3D_OK;
|
| 247 | +}
|
| 248 | +HRESULT WINAPI glDirect3DViewport3::SetViewport2(LPD3DVIEWPORT2 lpData)
|
| 249 | +{
|
| 250 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 251 | + if(!device) return D3DERR_VIEWPORTHASNODEVICE;
|
| 252 | + if(!lpData) return DDERR_INVALIDPARAMS;
|
| 253 | + viewport = *lpData;
|
| 254 | + return D3D_OK;
|
| 255 | +}
|
| 256 | +HRESULT WINAPI glDirect3DViewport3::TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen)
|
| 257 | +{
|
| 258 | + if(!this) return DDERR_INVALIDOBJECT;
|
| 259 | + FIXME("glDirect3DViewport3::TransformVertices: stub");
|
| 260 | + return DDERR_GENERIC;
|
| 261 | +} |
\ No newline at end of file |
Index: ddraw/glDirect3DViewport.h |
— | — | @@ -0,0 +1,64 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2011-2012 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#pragma once
|
| 20 | +#ifndef __GLDIRECT3DVIEWPORT_H
|
| 21 | +#define __GLDIRECT3DVIEWPORT_H
|
| 22 | +
|
| 23 | +class glDirect3DLight;
|
| 24 | +class glDirect3DDevice7;
|
| 25 | +class glDirectDrawSurface7;
|
| 26 | +class glDirect3DViewport3 : public IDirect3DViewport3
|
| 27 | +{
|
| 28 | +public:
|
| 29 | + glDirect3DViewport3();
|
| 30 | + virtual ~glDirect3DViewport3();
|
| 31 | + HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 32 | + ULONG WINAPI AddRef();
|
| 33 | + ULONG WINAPI Release();
|
| 34 | + HRESULT WINAPI AddLight(LPDIRECT3DLIGHT lpDirect3DLight);
|
| 35 | + HRESULT WINAPI Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags);
|
| 36 | + HRESULT WINAPI Clear2(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
| 37 | + HRESULT WINAPI DeleteLight(LPDIRECT3DLIGHT lpDirect3DLight);
|
| 38 | + HRESULT WINAPI GetBackground(LPD3DMATERIALHANDLE lphMat, LPBOOL lpValid);
|
| 39 | + HRESULT WINAPI GetBackgroundDepth(LPDIRECTDRAWSURFACE* lplpDDSurface, LPBOOL lpValid);
|
| 40 | + HRESULT WINAPI GetBackgroundDepth2(LPDIRECTDRAWSURFACE4* lplpDDS, LPBOOL lpValid);
|
| 41 | + HRESULT WINAPI GetViewport(LPD3DVIEWPORT lpData);
|
| 42 | + HRESULT WINAPI GetViewport2(LPD3DVIEWPORT2 lpData);
|
| 43 | + HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
|
| 44 | + HRESULT WINAPI LightElements(DWORD dwElementCount, LPD3DLIGHTDATA lpData);
|
| 45 | + HRESULT WINAPI NextLight(LPDIRECT3DLIGHT lpDirect3DLight, LPDIRECT3DLIGHT* lplpDirect3DLight, DWORD dwFlags);
|
| 46 | + HRESULT WINAPI SetBackground(D3DMATERIALHANDLE hMat);
|
| 47 | + HRESULT WINAPI SetBackgroundDepth(LPDIRECTDRAWSURFACE lpDDSurface);
|
| 48 | + HRESULT WINAPI SetBackgroundDepth2(LPDIRECTDRAWSURFACE4 lpDDS);
|
| 49 | + HRESULT WINAPI SetViewport(LPD3DVIEWPORT lpData);
|
| 50 | + HRESULT WINAPI SetViewport2(LPD3DVIEWPORT2 lpData);
|
| 51 | + HRESULT WINAPI TransformVertices(DWORD dwVertexCount, LPD3DTRANSFORMDATA lpData, DWORD dwFlags, LPDWORD lpOffscreen);
|
| 52 | +private:
|
| 53 | + ULONG refcount;
|
| 54 | + glDirect3DLight *lights[8];
|
| 55 | + glDirect3DDevice7 *device;
|
| 56 | + glDirectDrawSurface7 *backZ;
|
| 57 | + D3DMATERIALHANDLE background;
|
| 58 | + D3DVIEWPORT2 viewport;
|
| 59 | + D3DVALUE maxX;
|
| 60 | + D3DVALUE maxY;
|
| 61 | + D3DVALUE scaleX;
|
| 62 | + D3DVALUE scaleY;
|
| 63 | +};
|
| 64 | +
|
| 65 | +#endif //__GLDIRECT3DVIEWPORT_H |
\ No newline at end of file |