Reply 300 of 386, by kekko
well, I can't see anything clearly wrong. glide sets its depth function to LESS (equivalent of GL_LESS).
here's my opengl initialization routine
void ogl_init(voodoo_state *v) {
std::map<const Bit32u, GLuint>::iterator t;
// SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
if (SDL_SetVideoMode(v->fbi.width, v->fbi.height, 32, SDL_OPENGL) == 0)
E_Exit("opengl init error");
for (t=textures.begin(); t!=textures.end(); t++)
glDeleteTextures(1,&t->second);
if (!textures.empty()) textures.clear();
ogl_set_window(v);
}
and here's the window adjust routine. I added a call to it during "fbzmode" register write, in order to adjust the depth function
void ogl_set_window(voodoo_state *v) {
if (FBZMODE_ENABLE_DEPTHBUF(v->reg[fbzMode].u)) {
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
// glDepthFunc(GL_LEQUAL);
glDepthFunc(GL_NEVER+FBZMODE_DEPTH_FUNCTION(v->reg[fbzMode].u));
// printf("%d\n",FBZMODE_DEPTH_FUNCTION(v->reg[fbzMode].u));
}
else
glDisable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT,GL_FASTEST);
// glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
if (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u))
glOrtho( 0, v->fbi.width, 0, v->fbi.height, 0.0f, -1.0f );
else
glOrtho( 0, v->fbi.width, v->fbi.height, 0, 0.0f, -1.0f );
glViewport( 0, 0, v->fbi.width, v->fbi.height );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );
}
I also can't be sure that the calculation and the precision of the depth value is correct, even if I didn't change the code very much starting from the software renderer, which works perfectly of course.