Index: ddraw/glRenderer.cpp |
— | — | @@ -790,6 +790,8 @@ |
791 | 791 | SetSwap(1);
|
792 | 792 | SetSwap(0);
|
793 | 793 | glViewport(0,0,width,height);
|
| 794 | + DepthWrite(true);
|
| 795 | + DepthTest(false);
|
794 | 796 | glDisable(GL_DEPTH_TEST);
|
795 | 797 | SetDepthComp(GL_LESS);
|
796 | 798 | const GLubyte *glver = glGetString(GL_VERSION);
|
— | — | @@ -844,6 +846,7 @@ |
845 | 847 | DDSURFACEDESC2 ddsd;
|
846 | 848 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
847 | 849 | dest->GetSurfaceDesc(&ddsd);
|
| 850 | + DepthTest(false);
|
848 | 851 | if(!lpDestRect)
|
849 | 852 | {
|
850 | 853 | destrect.left = 0;
|
— | — | @@ -1047,6 +1050,7 @@ |
1048 | 1051 | if(memcmp(&r2,&r,sizeof(RECT)))
|
1049 | 1052 | SetWindowPos(RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
|
1050 | 1053 | }
|
| 1054 | + DepthTest(false);
|
1051 | 1055 | RECT *viewrect = &r2;
|
1052 | 1056 | SetSwap(swapinterval);
|
1053 | 1057 | LONG sizes[6];
|
— | — | @@ -1128,6 +1132,7 @@ |
1129 | 1133 | glUniform1i(texloc,0);
|
1130 | 1134 | }
|
1131 | 1135 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
|
| 1136 | + glDepthRange(viewport[4],viewport[5]);
|
1132 | 1137 | GLuint prog = GetProgram();
|
1133 | 1138 | GLint viewloc = glGetUniformLocation(prog,"view");
|
1134 | 1139 | glUniform4f(viewloc,view[0],view[1],view[2],view[3]);
|
— | — | @@ -1205,7 +1210,7 @@ |
1206 | 1211 | SetEvent(busy);
|
1207 | 1212 | glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
1208 | 1213 | GLfloat ambient[] = {0.0,0.0,0.0,0.0};
|
1209 | | - if(zbuffer) glEnable(GL_DEPTH_TEST);
|
| 1214 | + if(zbuffer) DepthTest(true);
|
1210 | 1215 | SetDepthComp(GL_LEQUAL);
|
1211 | 1216 | glDisable(GL_DITHER);
|
1212 | 1217 | }
|
— | — | @@ -1309,6 +1314,8 @@ |
1310 | 1315 | __int64 shader = device->SelectShader(vertices);
|
1311 | 1316 | SetShader(shader,device->texstages,texformats,0);
|
1312 | 1317 | device->SetDepthComp();
|
| 1318 | + if(device->renderstate[D3DRENDERSTATE_ZENABLE]) DepthTest(true);
|
| 1319 | + else DepthTest(false);
|
1313 | 1320 | _GENSHADER prog = genshaders[current_genshader].shader;
|
1314 | 1321 | glEnableVertexAttribArray(prog.attribs[0]);
|
1315 | 1322 | 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 | +bool depthwrite = true;
|
| 23 | +bool depthtest = false;
|
22 | 24 | GLuint depthcomp = 0;
|
23 | 25 | GLuint alphacomp = 0;
|
24 | 26 | GLuint fbcolor = 0;
|
— | — | @@ -161,6 +163,24 @@ |
162 | 164 | }
|
163 | 165 | }
|
164 | 166 |
|
| 167 | +void DepthWrite(bool enabled)
|
| 168 | +{
|
| 169 | + if(enabled != depthwrite)
|
| 170 | + {
|
| 171 | + depthwrite = enabled;
|
| 172 | + if(depthwrite) glDepthMask(GL_TRUE);
|
| 173 | + else glDepthMask(GL_FALSE);
|
| 174 | + }
|
| 175 | +}
|
| 176 | +void DepthTest(bool enabled)
|
| 177 | +{
|
| 178 | + if(enabled != depthtest)
|
| 179 | + {
|
| 180 | + depthtest = enabled;
|
| 181 | + if(depthtest) glEnable(
|
| 182 | + else glDepthMask(GL_FALSE);
|
| 183 | + }
|
| 184 | +}
|
165 | 185 | void SetDepthComp(GLenum comp)
|
166 | 186 | {
|
167 | 187 | if(comp != depthcomp)
|
Index: ddraw/glutil.h |
— | — | @@ -29,5 +29,7 @@ |
30 | 30 | void SetActiveTexture(int level);
|
31 | 31 | GLenum SetFBO(GLint color, GLint z, bool stencil);
|
32 | 32 | void SetDepthComp(GLenum comp);
|
| 33 | +void DepthWrite(bool enabled);
|
| 34 | +void DepthTest(bool enabled);
|
33 | 35 |
|
34 | 36 | #endif //_GLUTIL_H |
\ No newline at end of file |