Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -1237,4 +1237,36 @@ |
1238 | 1238 | }
|
1239 | 1239 |
|
1240 | 1240 | 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 | + }
|
1241 | 1273 | } |
\ No newline at end of file |
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -121,6 +121,7 @@ |
122 | 122 | HRESULT WINAPI SetViewport(LPD3DVIEWPORT7 lpViewport);
|
123 | 123 | HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
|
124 | 124 | void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
|
| 125 | + void SetDepthComp();
|
125 | 126 | __int64 SelectShader(GLVERTEX *VertexType);
|
126 | 127 | void UpdateNormalMatrix();
|
127 | 128 | GLfloat matWorld[16];
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -791,6 +791,7 @@ |
792 | 792 | SetSwap(0);
|
793 | 793 | glViewport(0,0,width,height);
|
794 | 794 | glDisable(GL_DEPTH_TEST);
|
| 795 | + SetDepthComp(GL_LESS);
|
795 | 796 | const GLubyte *glver = glGetString(GL_VERSION);
|
796 | 797 | gl_caps.Version = (GLfloat)atof((char*)glver);
|
797 | 798 | if(gl_caps.Version >= 2)
|
— | — | @@ -1205,7 +1206,7 @@ |
1206 | 1207 | glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
1207 | 1208 | GLfloat ambient[] = {0.0,0.0,0.0,0.0};
|
1208 | 1209 | if(zbuffer) glEnable(GL_DEPTH_TEST);
|
1209 | | - glDepthFunc(GL_LEQUAL);
|
| 1210 | + SetDepthComp(GL_LEQUAL);
|
1210 | 1211 | glDisable(GL_DITHER);
|
1211 | 1212 | }
|
1212 | 1213 |
|
— | — | @@ -1307,6 +1308,7 @@ |
1308 | 1309 | }
|
1309 | 1310 | __int64 shader = device->SelectShader(vertices);
|
1310 | 1311 | SetShader(shader,device->texstages,texformats,0);
|
| 1312 | + device->SetDepthComp();
|
1311 | 1313 | _GENSHADER prog = genshaders[current_genshader].shader;
|
1312 | 1314 | glEnableVertexAttribArray(prog.attribs[0]);
|
1313 | 1315 | glVertexAttribPointer(prog.attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
Index: ddraw/glutil.cpp |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "glutil.h"
|
21 | 21 |
|
| 22 | +GLuint depthcomp = 0;
|
| 23 | +GLuint alphacomp = 0;
|
22 | 24 | GLuint fbcolor = 0;
|
23 | 25 | GLuint fbz = 0;
|
24 | 26 | GLuint fbo = 0;
|
— | — | @@ -157,4 +159,13 @@ |
158 | 160 | else glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,wrapmode);
|
159 | 161 | SetActiveTexture(currtexture);
|
160 | 162 | }
|
| 163 | +}
|
| 164 | +
|
| 165 | +void SetDepthComp(GLenum comp)
|
| 166 | +{
|
| 167 | + if(comp != depthcomp)
|
| 168 | + {
|
| 169 | + depthcomp = comp;
|
| 170 | + glDepthFunc(comp);
|
| 171 | + }
|
161 | 172 | } |
\ No newline at end of file |
Index: ddraw/glutil.h |
— | — | @@ -28,5 +28,6 @@ |
29 | 29 | void SetTexture(int level,GLuint texture);
|
30 | 30 | void SetActiveTexture(int level);
|
31 | 31 | GLenum SetFBO(GLint color, GLint z, bool stencil);
|
| 32 | +void SetDepthComp(GLenum comp);
|
32 | 33 |
|
33 | 34 | #endif //_GLUTIL_H |
\ No newline at end of file |