Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -1284,7 +1284,7 @@ |
1285 | 1285 | {
|
1286 | 1286 | foundlight = true;
|
1287 | 1287 | gllights[i] = dwLightIndex;
|
1288 | | - glRenderer_SetLight(renderer, i, &lights[gllights[i]]->light, FALSE);
|
| 1288 | + glRenderer_SetLight(renderer, i, &lights[gllights[i]]->light);
|
1289 | 1289 | break;
|
1290 | 1290 | }
|
1291 | 1291 | }
|
— | — | @@ -1297,7 +1297,7 @@ |
1298 | 1298 | if(gllights[i] == dwLightIndex)
|
1299 | 1299 | {
|
1300 | 1300 | gllights[i] = -1;
|
1301 | | - glRenderer_SetLight(renderer, i, NULL, TRUE);
|
| 1301 | + glRenderer_RemoveLight(renderer, i);
|
1302 | 1302 | }
|
1303 | 1303 | }
|
1304 | 1304 | TRACE_EXIT(23,D3D_OK);
|
— | — | @@ -1363,7 +1363,7 @@ |
1364 | 1364 | lights[dwLightIndex]->SetLight7(lpLight);
|
1365 | 1365 | for (int i = 0; i < 8; i++)
|
1366 | 1366 | {
|
1367 | | - if (gllights[i] == dwLightIndex) glRenderer_SetLight(renderer, i, &lights[gllights[i]]->light, FALSE);
|
| 1367 | + if (gllights[i] == dwLightIndex) glRenderer_SetLight(renderer, i, &lights[gllights[i]]->light);
|
1368 | 1368 | }
|
1369 | 1369 | TRACE_EXIT(23,D3D_OK);
|
1370 | 1370 | return D3D_OK;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -979,7 +979,7 @@ |
980 | 980 | * @param This
|
981 | 981 | * Pointer to glRenderer object
|
982 | 982 | * @param dwStage
|
983 | | - * Texture stage to bind
|
| 983 | + * Texture stage to bind (8 through 11 are reserved for 2D drawing)
|
984 | 984 | * @param Texture
|
985 | 985 | * Texture to bind to the stage; NULL to unbind
|
986 | 986 | */
|
— | — | @@ -1062,16 +1062,13 @@ |
1063 | 1063 | * Index of light to set
|
1064 | 1064 | * @param light
|
1065 | 1065 | * Pointer to light to change, ignored if remove is TRUE
|
1066 | | - * @param remove
|
1067 | | - * TRUE to clear a light from the renderer.
|
1068 | 1066 | */
|
1069 | 1067 |
|
1070 | | -void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
| 1068 | +void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light)
|
1071 | 1069 | {
|
1072 | 1070 | EnterCriticalSection(&This->cs);
|
1073 | 1071 | This->inputs[0] = (void*)index;
|
1074 | 1072 | This->inputs[1] = light;
|
1075 | | - This->inputs[2] = (void*)remove;
|
1076 | 1073 | This->opcode = OP_SETLIGHT;
|
1077 | 1074 | SetEvent(This->start);
|
1078 | 1075 | WaitForSingleObject(This->busy, INFINITE);
|
— | — | @@ -1079,6 +1076,23 @@ |
1080 | 1077 | }
|
1081 | 1078 |
|
1082 | 1079 | /**
|
| 1080 | + * Removes a light from the renderer.
|
| 1081 | + * @param This
|
| 1082 | + * Pointer to glRenderer object
|
| 1083 | + * @param index
|
| 1084 | + * Index of light to remove
|
| 1085 | + */
|
| 1086 | +void glRenderer_RemoveLight(glRenderer *This, DWORD index)
|
| 1087 | +{
|
| 1088 | + EnterCriticalSection(&This->cs);
|
| 1089 | + This->inputs[0] = (void*)index;
|
| 1090 | + This->opcode = OP_REMOVELIGHT;
|
| 1091 | + SetEvent(This->start);
|
| 1092 | + WaitForSingleObject(This->busy, INFINITE);
|
| 1093 | + LeaveCriticalSection(&This->cs);
|
| 1094 | +}
|
| 1095 | +
|
| 1096 | +/**
|
1083 | 1097 | * Sets the viewport for the renderer.
|
1084 | 1098 | * @param This
|
1085 | 1099 | * Pointer to glRenderer object
|
— | — | @@ -1307,8 +1321,11 @@ |
1308 | 1322 | glRenderer__SetMaterial(This, (LPD3DMATERIAL7)This->inputs[0]);
|
1309 | 1323 | break;
|
1310 | 1324 | case OP_SETLIGHT:
|
1311 | | - glRenderer__SetLight(This, (DWORD)This->inputs[0], (LPD3DLIGHT7)This->inputs[1], (BOOL)This->inputs[2]);
|
| 1325 | + glRenderer__SetLight(This, (DWORD)This->inputs[0], (LPD3DLIGHT7)This->inputs[1]);
|
1312 | 1326 | break;
|
| 1327 | + case OP_REMOVELIGHT:
|
| 1328 | + glRenderer__RemoveLight(This, (DWORD)This->inputs[0]);
|
| 1329 | + break;
|
1313 | 1330 | case OP_SETVIEWPORT:
|
1314 | 1331 | glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
|
1315 | 1332 | break;
|
— | — | @@ -3207,12 +3224,11 @@ |
3208 | 3225 | SetEvent(This->busy);
|
3209 | 3226 | }
|
3210 | 3227 |
|
3211 | | -void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
| 3228 | +void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light)
|
3212 | 3229 | {
|
3213 | 3230 | int numlights = 0;
|
3214 | 3231 | int lightindex = 0;
|
3215 | | - if(!remove)memcpy(&This->lights[index], light, sizeof(D3DLIGHT7));
|
3216 | | - else ZeroMemory(&This->lights[index], sizeof(D3DLIGHT7));
|
| 3232 | + memcpy(&This->lights[index], light, sizeof(D3DLIGHT7));
|
3217 | 3233 | SetEvent(This->busy);
|
3218 | 3234 | for (int i = 0; i < 8; i++)
|
3219 | 3235 | if (This->lights[i].dltType) numlights++;
|
— | — | @@ -3232,6 +3248,29 @@ |
3233 | 3249 |
|
3234 | 3250 | }
|
3235 | 3251 |
|
| 3252 | +void glRenderer__RemoveLight(glRenderer *This, DWORD index)
|
| 3253 | +{
|
| 3254 | + int numlights = 0;
|
| 3255 | + int lightindex = 0;
|
| 3256 | + ZeroMemory(&This->lights[index], sizeof(D3DLIGHT7));
|
| 3257 | + SetEvent(This->busy);
|
| 3258 | + for (int i = 0; i < 8; i++)
|
| 3259 | + if (This->lights[i].dltType) numlights++;
|
| 3260 | + This->shaderstate3d.stateid &= 0xF807C03FFFE3FFFFi64;
|
| 3261 | + This->shaderstate3d.stateid |= ((__int64)numlights << 18);
|
| 3262 | + for (int i = 0; i < 8; i++)
|
| 3263 | + {
|
| 3264 | + if (This->lights[i].dltType != 1)
|
| 3265 | + {
|
| 3266 | + if (This->lights[i].dltType != D3DLIGHT_DIRECTIONAL)
|
| 3267 | + This->shaderstate3d.stateid |= (1i64 << (38 + lightindex));
|
| 3268 | + if (This->lights[i].dltType == D3DLIGHT_SPOT)
|
| 3269 | + This->shaderstate3d.stateid |= (1i64 << (51 + lightindex));
|
| 3270 | + lightindex++;
|
| 3271 | + }
|
| 3272 | + }
|
| 3273 | +}
|
| 3274 | +
|
3236 | 3275 | void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
|
3237 | 3276 | {
|
3238 | 3277 | memcpy(&This->viewport, lpViewport, sizeof(D3DVIEWPORT7));
|
Index: ddraw/glRenderer.h |
— | — | @@ -18,25 +18,6 @@ |
19 | 19 | #ifndef _GLRENDERER_H
|
20 | 20 | #define _GLRENDERER_H
|
21 | 21 |
|
22 | | -typedef struct
|
23 | | -{
|
24 | | - float Version;
|
25 | | - float ShaderVer;
|
26 | | - GLint TextureMax;
|
27 | | -} GLCAPS;
|
28 | | -
|
29 | | -typedef struct
|
30 | | -{
|
31 | | - void *data;
|
32 | | - int stride;
|
33 | | -} GLVERTEX;
|
34 | | -
|
35 | | -typedef struct
|
36 | | -{
|
37 | | - __int64 stateid;
|
38 | | - __int64 texstageid[8];
|
39 | | -} SHADERSTATE;
|
40 | | -
|
41 | 22 | #ifdef __cplusplus
|
42 | 23 | class glDirectDraw7;
|
43 | 24 | class glDirect3DDevice7;
|
— | — | @@ -104,12 +85,13 @@ |
105 | 86 | #define OP_SETTRANSFORM 18
|
106 | 87 | #define OP_SETMATERIAL 19
|
107 | 88 | #define OP_SETLIGHT 20
|
108 | | -#define OP_SETVIEWPORT 21
|
109 | | -#define OP_DXGLBREAK 22
|
110 | | -#define OP_SETTEXTURECOLORKEY 23
|
111 | | -#define OP_MAKETEXTUREPRIMARY 24
|
112 | | -#define OP_ENDCOMMAND 25
|
113 | | -#define OP_INITTEXTURESTAGE 26
|
| 89 | +#define OP_REMOVELIGHT 21
|
| 90 | +#define OP_SETVIEWPORT 22
|
| 91 | +#define OP_DXGLBREAK 23
|
| 92 | +#define OP_SETTEXTURECOLORKEY 24
|
| 93 | +#define OP_MAKETEXTUREPRIMARY 25
|
| 94 | +#define OP_ENDCOMMAND 26
|
| 95 | +#define OP_INITTEXTURESTAGE 27
|
114 | 96 |
|
115 | 97 | extern const DWORD renderstate_default[153];
|
116 | 98 | extern const TEXTURESTAGE texstagedefault0;
|
— | — | @@ -190,7 +172,8 @@ |
191 | 173 | void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
192 | 174 | void glRenderer_SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
193 | 175 | void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
194 | | -void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
| 176 | +void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light);
|
| 177 | +void glRenderer_RemoveLight(glRenderer *This, DWORD index);
|
195 | 178 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
196 | 179 | void glRenderer_SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
|
197 | 180 | void glRenderer_MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary);
|
— | — | @@ -231,7 +214,8 @@ |
232 | 215 | void glRenderer__SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
233 | 216 | void glRenderer__SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
234 | 217 | void glRenderer__SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
235 | | -void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
| 218 | +void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light);
|
| 219 | +void glRenderer__RemoveLight(glRenderer *This, DWORD index);
|
236 | 220 | void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
237 | 221 | void glRenderer__SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
|
238 | 222 | void glRenderer__MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary);
|
Index: ddraw/struct.h |
— | — | @@ -465,4 +465,23 @@ |
466 | 466 | float muly;
|
467 | 467 | } RenderTarget;
|
468 | 468 |
|
| 469 | +typedef struct GLCAPS
|
| 470 | +{
|
| 471 | + float Version;
|
| 472 | + float ShaderVer;
|
| 473 | + GLint TextureMax;
|
| 474 | +} GLCAPS;
|
| 475 | +
|
| 476 | +typedef struct GLVERTEX
|
| 477 | +{
|
| 478 | + void *data;
|
| 479 | + int stride;
|
| 480 | +} GLVERTEX;
|
| 481 | +
|
| 482 | +typedef struct SHADERSTATE
|
| 483 | +{
|
| 484 | + __int64 stateid;
|
| 485 | + __int64 texstageid[8];
|
| 486 | +} SHADERSTATE;
|
| 487 | +
|
469 | 488 | #endif //__STRUCT_H |
\ No newline at end of file |
Index: ddraw/struct_command.h |
— | — | @@ -86,6 +86,88 @@ |
87 | 87 | {
|
88 | 88 | DWORD opcode;
|
89 | 89 | DWORD size;
|
90 | | - // Add params
|
| 90 | + RenderTarget *target;
|
| 91 | + GLenum mode;
|
| 92 | + GLVERTEX *vertices;
|
| 93 | + int *texformats;
|
| 94 | + DWORD count;
|
| 95 | + LPWORD indices;
|
91 | 96 | } DrawPrimitivesCmd;
|
| 97 | +typedef struct UpdateClipperCmd
|
| 98 | +{
|
| 99 | + DWORD opcode;
|
| 100 | + DWORD size;
|
| 101 | + glTexture *stencil;
|
| 102 | + GLushort *indices;
|
| 103 | + BltVertex *vertices;
|
| 104 | + GLsizei count;
|
| 105 | + GLsizei width;
|
| 106 | + GLsizei height;
|
| 107 | +} UpdateClipperCmd;
|
| 108 | +typedef struct DepthFillCmd
|
| 109 | +{
|
| 110 | + DWORD opcode;
|
| 111 | + DWORD size;
|
| 112 | + BltCommand cmd;
|
| 113 | + glTexture *parent;
|
| 114 | + GLint parentlevel;
|
| 115 | +} DepthFillCmd;
|
| 116 | +typedef struct SetRenderStateCmd
|
| 117 | +{
|
| 118 | + DWORD opcode;
|
| 119 | + DWORD size;
|
| 120 | + DWORD count;
|
| 121 | + D3DRENDERSTATETYPE dwRendStateType;
|
| 122 | + DWORD dwRenderState;
|
| 123 | + // For count over 1, use additional pairs to store state changes.
|
| 124 | +} SetRenderStateCmd;
|
| 125 | +typedef struct SetTextureCmd
|
| 126 | +{
|
| 127 | + DWORD opcode;
|
| 128 | + DWORD size;
|
| 129 | + DWORD count;
|
| 130 | + DWORD stage;
|
| 131 | + glTexture *texture;
|
| 132 | + // For count over 1, use additional pairs to store texture changes.
|
| 133 | +} SetTextureCmd;
|
| 134 | +typedef struct SetTextureStageStateCmd
|
| 135 | +{
|
| 136 | + DWORD opcode;
|
| 137 | + DWORD size;
|
| 138 | + DWORD count;
|
| 139 | + DWORD dwStage;
|
| 140 | + D3DTEXTURESTAGESTATETYPE dwState;
|
| 141 | + DWORD dwValue;
|
| 142 | + // For count over 1, use additional sets to store texture state changes.
|
| 143 | +} SetTextureStageStateCmd;
|
| 144 | +typedef struct SetTransformCmd
|
| 145 | +{
|
| 146 | + DWORD opcode;
|
| 147 | + DWORD size;
|
| 148 | + D3DTRANSFORMSTATETYPE dtstTransformStateType;
|
| 149 | + D3DMATRIX matrix;
|
| 150 | +} SetTransformCmd;
|
| 151 | +typedef struct SetMaterialCmd
|
| 152 | +{
|
| 153 | + DWORD opcode;
|
| 154 | + DWORD size;
|
| 155 | + D3DMATERIAL7 material;
|
| 156 | +} SetMaterialCmd;
|
| 157 | +typedef struct SetLightCmd
|
| 158 | +{
|
| 159 | + DWORD opcode;
|
| 160 | + DWORD size;
|
| 161 | + DWORD count;
|
| 162 | + DWORD index;
|
| 163 | + D3DLIGHT7 light;
|
| 164 | + // For count over 1, use additional pairs to store lights
|
| 165 | +} SetLightCmd;
|
| 166 | +typedef struct RemoveLightCmd
|
| 167 | +{
|
| 168 | + DWORD opcode;
|
| 169 | + DWORD size;
|
| 170 | + DWORD count;
|
| 171 | + DWORD index;
|
| 172 | + // For count over 1, use additional indices
|
| 173 | +} RemoveLightCmd;
|
92 | 174 | #endif //__STRUCT_COMMAND_H |
\ No newline at end of file |