DXGL r687 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r686‎ | r687 | r688 >
Date:00:32, 20 September 2016
Author:admin
Status:new
Tags:
Comment:
Rename SetViewport to SetD3DViewport in renderer.
Disable D3D C++ interface in ddraw.dll
Further planning work on new renderer.
Modified paths:
  • /ddraw/common.h (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DLight.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/struct_command.h (modified) (history)

Diff [purge]

Index: ddraw/common.h
@@ -25,7 +25,6 @@
2626 #include <MMSystem.h>
2727 #include "include/winedef.h"
2828 #include "include/ddraw.h"
29 -#define D3D_OVERLOADS
3029 #include "include/d3d.h"
3130 #include "GL/gl.h"
3231 #include "include/GL/glext.h"
Index: ddraw/glDirect3DDevice.cpp
@@ -1711,7 +1711,7 @@
17121712 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
17131713 memcpy(&viewport,lpViewport,sizeof(D3DVIEWPORT7));
17141714 transform_dirty = true;
1715 - glRenderer_SetViewport(renderer, lpViewport);
 1715+ glRenderer_SetD3DViewport(renderer, lpViewport);
17161716 TRACE_EXIT(23,D3D_OK);
17171717 return D3D_OK;
17181718 }
Index: ddraw/glDirect3DLight.cpp
@@ -30,6 +30,7 @@
3131
3232 glDirect3DLight::glDirect3DLight()
3333 {
 34+ D3DVECTOR dir = { 0,0,1.0 };
3435 TRACE_ENTER(1,14,this);
3536 refcount=1;
3637 viewport = NULL;
@@ -37,7 +38,7 @@
3839 ZeroMemory(&light,sizeof(D3DLIGHT7));
3940 light.dltType = D3DLIGHT_DIRECTIONAL;
4041 light.dcvDiffuse.r = light.dcvDiffuse.g = light.dcvDiffuse.b = 1.0f;
41 - light.dvDirection = D3DVECTOR(0,0,1.0);
 42+ light.dvDirection = dir;
4243 TRACE_EXIT(-1,0);
4344 }
4445 glDirect3DLight::glDirect3DLight(D3DLIGHT7 *light_in)
Index: ddraw/glRenderer.cpp
@@ -296,7 +296,7 @@
297297 case OP_SETLIGHT: // Sets one of the Direct3D fixed-function light states.
298298 error = DDERR_CURRENTLYNOTAVAIL;
299299 break;
300 - case OP_SETVIEWPORT: // Sets the Direct3D viewport. May be
 300+ case OP_SETD3DVIEWPORT: // Sets the Direct3D viewport. May be
301301 error = DDERR_CURRENTLYNOTAVAIL;
302302 break;
303303 case OP_SETTEXTURECOLORKEY: // Sets a color key or colorkey range on a texture object.
@@ -1093,17 +1093,17 @@
10941094 }
10951095
10961096 /**
1097 - * Sets the viewport for the renderer.
 1097+ * Sets the Direct3D viewport for the renderer.
10981098 * @param This
10991099 * Pointer to glRenderer object
11001100 * @param lpViewport
11011101 * New viewport parameters for renderer.
11021102 */
1103 -void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
 1103+void glRenderer_SetD3DViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
11041104 {
11051105 EnterCriticalSection(&This->cs);
11061106 This->inputs[0] = lpViewport;
1107 - This->opcode = OP_SETVIEWPORT;
 1107+ This->opcode = OP_SETD3DVIEWPORT;
11081108 SetEvent(This->start);
11091109 WaitForSingleObject(This->busy, INFINITE);
11101110 LeaveCriticalSection(&This->cs);
@@ -1186,7 +1186,11 @@
11871187 void glRenderer_EndCommand(glRenderer *This, BOOL wait, BOOL in_cs)
11881188 {
11891189 if (!in_cs) EnterCriticalSection(&This->cs);
1190 - if (!This->state.cmd->write_ptr_cmd) return; // Don't flip buffers if the front one is empty.
 1190+ if (!This->state.cmd->write_ptr_cmd)
 1191+ {
 1192+ if (!in_cs) LeaveCriticalSection(&This->cs);
 1193+ return; // Don't flip buffers if the front one is empty.
 1194+ }
11911195 This->opcode = OP_ENDCOMMAND;
11921196 This->inputs[0] = (void*)wait;
11931197 SetEvent(This->start);
@@ -1326,8 +1330,8 @@
13271331 case OP_REMOVELIGHT:
13281332 glRenderer__RemoveLight(This, (DWORD)This->inputs[0]);
13291333 break;
1330 - case OP_SETVIEWPORT:
1331 - glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
 1334+ case OP_SETD3DVIEWPORT:
 1335+ glRenderer__SetD3DViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
13321336 break;
13331337 case OP_SETTEXTURECOLORKEY:
13341338 glRenderer__SetTextureColorKey(This, (glTexture*)This->inputs[0], (DWORD)This->inputs[1],
@@ -3271,7 +3275,7 @@
32723276 }
32733277 }
32743278
3275 -void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
 3279+void glRenderer__SetD3DViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
32763280 {
32773281 memcpy(&This->viewport, lpViewport, sizeof(D3DVIEWPORT7));
32783282 SetEvent(This->busy);
Index: ddraw/glRenderer.h
@@ -86,7 +86,7 @@
8787 #define OP_SETMATERIAL 19
8888 #define OP_SETLIGHT 20
8989 #define OP_REMOVELIGHT 21
90 -#define OP_SETVIEWPORT 22
 90+#define OP_SETD3DVIEWPORT 22
9191 #define OP_DXGLBREAK 23
9292 #define OP_SETTEXTURECOLORKEY 24
9393 #define OP_MAKETEXTUREPRIMARY 25
@@ -174,7 +174,7 @@
175175 void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
176176 void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light);
177177 void glRenderer_RemoveLight(glRenderer *This, DWORD index);
178 -void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
 178+void glRenderer_SetD3DViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
179179 void glRenderer_SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
180180 void glRenderer_MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary);
181181 void glRenderer_DXGLBreak(glRenderer *This);
@@ -216,7 +216,7 @@
217217 void glRenderer__SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
218218 void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light);
219219 void glRenderer__RemoveLight(glRenderer *This, DWORD index);
220 -void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
 220+void glRenderer__SetD3DViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
221221 void glRenderer__SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
222222 void glRenderer__MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary);
223223 void glRenderer__SetDepthComp(glRenderer *This);
Index: ddraw/struct_command.h
@@ -117,8 +117,11 @@
118118 DWORD opcode;
119119 DWORD size;
120120 DWORD count;
121 - D3DRENDERSTATETYPE dwRendStateType;
122 - DWORD dwRenderState;
 121+ struct
 122+ {
 123+ D3DRENDERSTATETYPE dwRendStateType;
 124+ DWORD dwRenderState;
 125+ } state[1];
123126 // For count over 1, use additional pairs to store state changes.
124127 } SetRenderStateCmd;
125128 typedef struct SetTextureCmd
@@ -126,8 +129,11 @@
127130 DWORD opcode;
128131 DWORD size;
129132 DWORD count;
130 - DWORD stage;
131 - glTexture *texture;
 133+ struct
 134+ {
 135+ DWORD stage;
 136+ glTexture *texture;
 137+ } texstage[1];
132138 // For count over 1, use additional pairs to store texture changes.
133139 } SetTextureCmd;
134140 typedef struct SetTextureStageStateCmd
@@ -136,8 +142,11 @@
137143 DWORD size;
138144 DWORD count;
139145 DWORD dwStage;
140 - D3DTEXTURESTAGESTATETYPE dwState;
141 - DWORD dwValue;
 146+ struct
 147+ {
 148+ D3DTEXTURESTAGESTATETYPE dwState;
 149+ DWORD dwValue;
 150+ } state[1];
142151 // For count over 1, use additional sets to store texture state changes.
143152 } SetTextureStageStateCmd;
144153 typedef struct SetTransformCmd
@@ -144,8 +153,12 @@
145154 {
146155 DWORD opcode;
147156 DWORD size;
148 - D3DTRANSFORMSTATETYPE dtstTransformStateType;
149 - D3DMATRIX matrix;
 157+ DWORD count;
 158+ struct
 159+ {
 160+ D3DTRANSFORMSTATETYPE dtstTransformStateType;
 161+ D3DMATRIX matrix;
 162+ } transform[1];
150163 } SetTransformCmd;
151164 typedef struct SetMaterialCmd
152165 {
@@ -159,7 +172,7 @@
160173 DWORD size;
161174 DWORD count;
162175 DWORD index;
163 - D3DLIGHT7 light;
 176+ D3DLIGHT7 light[1];
164177 // For count over 1, use additional pairs to store lights
165178 } SetLightCmd;
166179 typedef struct RemoveLightCmd
@@ -167,7 +180,77 @@
168181 DWORD opcode;
169182 DWORD size;
170183 DWORD count;
171 - DWORD index;
 184+ DWORD index[1];
172185 // For count over 1, use additional indices
173186 } RemoveLightCmd;
 187+typedef struct SetD3DViewportCmd
 188+{
 189+ DWORD opcode;
 190+ DWORD size;
 191+ D3DVIEWPORT7 viewport;
 192+} SetD3DViewportCmd;
 193+typedef struct SetTextureColorKeyCmd
 194+{
 195+ DWORD opcode;
 196+ DWORD size;
 197+ glTexture *texture;
 198+ DWORD flags;
 199+ DDCOLORKEY colorkey;
 200+ GLint level;
 201+} SetTextureColorKeyCmd;
 202+typedef struct MakeTexturePrimaryCmd
 203+{
 204+ DWORD opcode;
 205+ DWORD size;
 206+ glTexture *texture;
 207+ glTexture *parent;
 208+ BOOL primary;
 209+} MakeTexturePrimaryCmd;
 210+typedef struct DXGLBreakCmd
 211+{
 212+ DWORD opcode;
 213+ DWORD size;
 214+} DXGLBreakCmd;
 215+typedef struct InitTextureStageCmd
 216+{
 217+ DWORD opcode;
 218+ DWORD size;
 219+ DWORD count;
 220+ DWORD stage[1];
 221+} InitTextureStageCmd;
 222+
 223+typedef struct MIN_STORAGE_Cmd
 224+{
 225+ BYTE data[256];
 226+} MIN_STORAGE_CMD;
 227+
 228+typedef union QueueCmd
 229+{
 230+ MakeTextureCmd MakeTexture;
 231+ UploadTextureCmd UploadTexture;
 232+ DownloadTextureCmd DownloadTexture;
 233+ DeleteTextureCmd DeleteTexture;
 234+ BltCmd Blt;
 235+ DrawScreenCmd DrawScreen;
 236+ InitD3DCmd InitD3D;
 237+ ClearCmd Clear;
 238+ FlushCmd Flush;
 239+ DrawPrimitivesCmd DrawPrimitives;
 240+ UpdateClipperCmd UpdateClipper;
 241+ DepthFillCmd DepthFill;
 242+ SetRenderStateCmd SetRenderState;
 243+ SetTextureCmd SetTexture;
 244+ SetTextureStageStateCmd SetTextureStageState;
 245+ SetTransformCmd SetTransform;
 246+ SetMaterialCmd SetMaterial;
 247+ SetLightCmd SetLight;
 248+ RemoveLightCmd RemoveLight;
 249+ SetD3DViewportCmd SetD3DViewport;
 250+ SetTextureColorKeyCmd SetTextureColorKey;
 251+ MakeTexturePrimaryCmd MakeTexturePrimary;
 252+ DXGLBreakCmd DXGLBreak;
 253+ InitTextureStageCmd InitTextureStage;
 254+ MIN_STORAGE_CMD MIN_STORAGE;
 255+} QueueCmd;
 256+
174257 #endif //__STRUCT_COMMAND_H
\ No newline at end of file