DXGL r583 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r582‎ | r583 | r584 >
Date:01:45, 14 January 2015
Author:admin
Status:new
Tags:
Comment:
Add "Always" depth compare capability.
Remove 1/2 pixel offset from transformed vertices.
Fix Debug Trace build.
Fix Direct3D5 specific initialization.
Add Direct3D2 specific initialization.
Modified paths:
  • /ddraw/ShaderGen3D.cpp (modified) (history)
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen3D.cpp
@@ -345,8 +345,8 @@
346346 gl_Position = vec4(pos.x,-pos.y,pos.z,pos.w);\n";
347347 static const char op_normalize[] = "N = normalize(gl_NormalMatrix*nxyz);\n";
348348 static const char op_normalpassthru[] = "N = gl_NormalMatrix*nxyz;\n";
349 -static const char op_tlvertex[] = "gl_Position = vec4(((((xyz.x-xoffset)+.5)/(width/2.0))-1.0)/rhw,\
350 -((((xyz.y-yoffset)+.5)/(height/2.0))-1.0)/rhw,xyz.z/rhw,1.0/rhw);\n";
 349+static const char op_tlvertex[] = "gl_Position = vec4(((xyz.x-xoffset)/(width/2.0)-1.0)/rhw,\
 350+((xyz.y-yoffset)/(height/2.0)-1.0)/rhw,xyz.z/rhw,1.0/rhw);\n";
351351 static const char op_resetcolor[] = "diffuse = specular = vec4(0.0);\n\
352352 ambient = ambientcolor / 255.0;\n";
353353 static const char op_dirlight[] = "DirLight(lightX);\n";
Index: ddraw/ddraw.vcxproj
@@ -143,7 +143,7 @@
144144 <SubSystem>Windows</SubSystem>
145145 <GenerateDebugInformation>true</GenerateDebugInformation>
146146 <ModuleDefinitionFile>ddraw.def</ModuleDefinitionFile>
147 - <AdditionalDependencies>$(OutDir)libMinHook.x86.lib;$(OutDir)..\Debug\cfgmgr.lib;glu32.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
 147+ <AdditionalDependencies>$(OutDir)..\Debug\libMinHook.x86.lib;$(OutDir)..\Debug\cfgmgr.lib;glu32.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
148148 </Link>
149149 <PreBuildEvent>
150150 <Command>"$(OutDir)..\Debug\buildtool.exe" makeheader $(SolutionDir)common</Command>
Index: ddraw/glDirect3D.cpp
@@ -71,7 +71,7 @@
7272 D3DPMISCCAPS_CULLCCW | D3DPMISCCAPS_CULLCW | D3DPMISCCAPS_CULLNONE, // dwMiscCaps
7373 D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_FOGTABLE |
7474 D3DPRASTERCAPS_FOGVERTEX | D3DPRASTERCAPS_WFOG, //dwRasterCaps
75 - D3DPCMPCAPS_LESSEQUAL, //dwZCmpCaps
 75+ D3DPCMPCAPS_ALWAYS | D3DPCMPCAPS_LESSEQUAL, //dwZCmpCaps
7676 D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR | D3DPBLENDCAPS_INVSRCCOLOR |
7777 D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA | D3DPBLENDCAPS_DESTALPHA |
7878 D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR | D3DPBLENDCAPS_INVDESTCOLOR |
Index: ddraw/glDirect3DDevice.cpp
@@ -275,6 +275,7 @@
276276 {
277277 TRACE_ENTER(4,14,this,24,&rclsid,14,glD3D7,14,glDDS7);
278278 this->version = version;
 279+ dx2init = dx5init = FALSE;
279280 d3ddesc = d3ddesc_default;
280281 d3ddesc3 = d3ddesc3_default;
281282 int zbuffer = 0;
@@ -467,6 +468,11 @@
468469 {
469470 *ppvObj = glD3DDev2;
470471 glD3DDev2->AddRef();
 472+ if (!dx5init)
 473+ {
 474+ InitDX5();
 475+ dx5init = TRUE;
 476+ }
471477 TRACE_VAR("*ppvObj", 14, *ppvObj);
472478 TRACE_EXIT(23, D3D_OK);
473479 return D3D_OK;
@@ -475,6 +481,16 @@
476482 {
477483 *ppvObj = glD3DDev1;
478484 glD3DDev1->AddRef();
 485+ if (!dx5init)
 486+ {
 487+ InitDX5();
 488+ dx5init = TRUE;
 489+ }
 490+ if (!dx2init)
 491+ {
 492+ InitDX2();
 493+ dx5init = TRUE;
 494+ }
479495 TRACE_VAR("*ppvObj", 14, *ppvObj);
480496 TRACE_EXIT(23, D3D_OK);
481497 return D3D_OK;
@@ -2161,6 +2177,13 @@
21622178 return DDERR_GENERIC;
21632179 }
21642180
 2181+void glDirect3DDevice7::InitDX2()
 2182+{
 2183+ TRACE_ENTER(1, 14, this);
 2184+ SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);
 2185+ TRACE_EXIT(0, 0);
 2186+}
 2187+
21652188 void glDirect3DDevice7::InitDX5()
21662189 {
21672190 TRACE_ENTER(1,14,this);
@@ -3251,7 +3274,6 @@
32523275 {
32533276 TRACE_ENTER(2,14,this,14,glD3DDev7);
32543277 this->glD3DDev7 = glD3DDev7;
3255 - glD3DDev7->InitDX5();
32563278 TRACE_EXIT(-1,0);
32573279 }
32583280
@@ -3586,7 +3608,6 @@
35873609 {
35883610 TRACE_ENTER(2,14,this,14,glD3DDev7);
35893611 this->glD3DDev7 = glD3DDev7;
3590 - glD3DDev7->InitDX5();
35913612 TRACE_EXIT(-1,0);
35923613 }
35933614
Index: ddraw/glDirect3DDevice.h
@@ -167,6 +167,7 @@
168168 INT TransformOnly(D3DTLVERTEX **output, DWORD *outsize, D3DLVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents);
169169 INT CopyVertices(D3DTLVERTEX **output, DWORD *outsize, D3DTLVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents);
170170 void UpdateTransform();
 171+ void InitDX2();
171172 void InitDX5();
172173 __int64 SelectShader(GLVERTEX *VertexType);
173174 void SetScale(D3DVALUE x, D3DVALUE y){scalex = x; scaley = y;}
@@ -236,6 +237,8 @@
237238 glRenderer *renderer;
238239 IUnknown *creator;
239240 int version;
 241+ BOOL dx5init;
 242+ BOOL dx2init;
240243 };
241244
242245 class glDirect3DDevice3 : public IDirect3DDevice3
Index: ddraw/glDirectDrawSurface.cpp
@@ -533,6 +533,8 @@
534534 }
535535 *ppvObj = device1->glD3DDev1;
536536 device1->glD3DDev1->AddRef();
 537+ device1->InitDX5();
 538+ device1->InitDX2();
537539 tmpd3d->Release();
538540 TRACE_VAR("*ppvObj",14,*ppvObj);
539541 TRACE_EXIT(23,DD_OK);