DXGL r177 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r176‎ | r177 | r178 >
Date:18:59, 23 June 2012
Author:admin
Status:new
Tags:
Comment:
Add Z compare function
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glutil.cpp (modified) (history)
  • /ddraw/glutil.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -1237,4 +1237,36 @@
12381238 }
12391239
12401240 normal_dirty = false;
 1241+}
 1242+
 1243+void glDirect3DDevice7::SetDepthComp()
 1244+{
 1245+ switch(renderstate[D3DRENDERSTATE_ZFUNC])
 1246+ {
 1247+ case D3DCMP_NEVER:
 1248+ ::SetDepthComp(GL_NEVER);
 1249+ break;
 1250+ case D3DCMP_LESS:
 1251+ ::SetDepthComp(GL_LESS);
 1252+ break;
 1253+ case D3DCMP_EQUAL:
 1254+ ::SetDepthComp(GL_EQUAL);
 1255+ break;
 1256+ case D3DCMP_LESSEQUAL:
 1257+ ::SetDepthComp(GL_LEQUAL);
 1258+ break;
 1259+ case D3DCMP_GREATER:
 1260+ ::SetDepthComp(GL_GREATER);
 1261+ break;
 1262+ case D3DCMP_NOTEQUAL:
 1263+ ::SetDepthComp(GL_NOTEQUAL);
 1264+ break;
 1265+ case D3DCMP_GREATEREQUAL:
 1266+ ::SetDepthComp(GL_GEQUAL);
 1267+ break;
 1268+ case D3DCMP_ALWAYS:
 1269+ default:
 1270+ ::SetDepthComp(GL_ALWAYS);
 1271+ break;
 1272+ }
12411273 }
\ No newline at end of file
Index: ddraw/glDirect3DDevice.h
@@ -121,6 +121,7 @@
122122 HRESULT WINAPI SetViewport(LPD3DVIEWPORT7 lpViewport);
123123 HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
124124 void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
 125+ void SetDepthComp();
125126 __int64 SelectShader(GLVERTEX *VertexType);
126127 void UpdateNormalMatrix();
127128 GLfloat matWorld[16];
Index: ddraw/glRenderer.cpp
@@ -791,6 +791,7 @@
792792 SetSwap(0);
793793 glViewport(0,0,width,height);
794794 glDisable(GL_DEPTH_TEST);
 795+ SetDepthComp(GL_LESS);
795796 const GLubyte *glver = glGetString(GL_VERSION);
796797 gl_caps.Version = (GLfloat)atof((char*)glver);
797798 if(gl_caps.Version >= 2)
@@ -1205,7 +1206,7 @@
12061207 glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
12071208 GLfloat ambient[] = {0.0,0.0,0.0,0.0};
12081209 if(zbuffer) glEnable(GL_DEPTH_TEST);
1209 - glDepthFunc(GL_LEQUAL);
 1210+ SetDepthComp(GL_LEQUAL);
12101211 glDisable(GL_DITHER);
12111212 }
12121213
@@ -1307,6 +1308,7 @@
13081309 }
13091310 __int64 shader = device->SelectShader(vertices);
13101311 SetShader(shader,device->texstages,texformats,0);
 1312+ device->SetDepthComp();
13111313 _GENSHADER prog = genshaders[current_genshader].shader;
13121314 glEnableVertexAttribArray(prog.attribs[0]);
13131315 glVertexAttribPointer(prog.attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
Index: ddraw/glutil.cpp
@@ -18,6 +18,8 @@
1919 #include "common.h"
2020 #include "glutil.h"
2121
 22+GLuint depthcomp = 0;
 23+GLuint alphacomp = 0;
2224 GLuint fbcolor = 0;
2325 GLuint fbz = 0;
2426 GLuint fbo = 0;
@@ -157,4 +159,13 @@
158160 else glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,wrapmode);
159161 SetActiveTexture(currtexture);
160162 }
 163+}
 164+
 165+void SetDepthComp(GLenum comp)
 166+{
 167+ if(comp != depthcomp)
 168+ {
 169+ depthcomp = comp;
 170+ glDepthFunc(comp);
 171+ }
161172 }
\ No newline at end of file
Index: ddraw/glutil.h
@@ -28,5 +28,6 @@
2929 void SetTexture(int level,GLuint texture);
3030 void SetActiveTexture(int level);
3131 GLenum SetFBO(GLint color, GLint z, bool stencil);
 32+void SetDepthComp(GLenum comp);
3233
3334 #endif //_GLUTIL_H
\ No newline at end of file