1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Add g_bN64DepthCompare parameter

If it is true, N64 depth compare algorithm is used instead of OpenGL depth buffer.
This commit is contained in:
Sergey Lipskiy 2013-12-15 23:46:08 +07:00
parent 344df93374
commit b0f17ef953
4 changed files with 22 additions and 13 deletions

View File

@ -12,6 +12,8 @@ const GLuint ZlutImageUnit = 0;
const GLuint TlutImageUnit = 1;
const GLuint depthImageUnit = 2;
bool g_bN64DepthCompare = true;
void DepthBuffer_Init()
{
depthBuffer.current = NULL;

View File

@ -26,6 +26,8 @@ extern const GLuint ZlutImageUnit;
extern const GLuint TlutImageUnit;
extern const GLuint depthImageUnit;
extern bool g_bN64DepthCompare;
void DepthBuffer_Init();
void DepthBuffer_Destroy();
void DepthBuffer_SetBuffer( u32 address );

View File

@ -401,9 +401,12 @@ GLSLCombiner::GLSLCombiner(Combiner *_color, Combiner *_alpha) {
strcat(fragment_shader, " gl_FragColor = vec4(color2, alpha2); \n");
strcat(fragment_shader, " if (!alpha_test(gl_FragColor.a)) discard; \n");
if (OGL.bImageTexture)
// strcat(fragment_shader, " bool bDC = depth_compare(); \n");
if (OGL.bImageTexture) {
if (g_bN64DepthCompare)
strcat(fragment_shader, " if (!depth_compare()) discard; \n");
else
strcat(fragment_shader, " depth_compare(); \n");
}
#ifdef USE_TOONIFY
strcat(fragment_shader, " toonify(intensity); \n");

View File

@ -290,6 +290,12 @@ void OGL_InitStates()
glEnableClientState( GL_FOG_COORDINATE_ARRAY_EXT );
}
if (g_bN64DepthCompare) {
glDisable( GL_DEPTH_TEST );
glDisable( GL_POLYGON_OFFSET_FILL );
glDepthFunc( GL_ALWAYS );
glDepthMask( FALSE );
} else
glPolygonOffset( -3.0f, -3.0f );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
@ -559,8 +565,7 @@ void OGL_UpdateStates()
else
glDisable( GL_DEPTH_TEST );
if (gDP.changed & CHANGED_RENDERMODE)
{
if (!g_bN64DepthCompare && (gDP.changed & CHANGED_RENDERMODE) > 0) {
if (gDP.otherMode.depthCompare)
glDepthFunc( GL_LEQUAL );
else
@ -568,14 +573,11 @@ void OGL_UpdateStates()
OGL_UpdateDepthUpdate();
// if (gDP.otherMode.depthMode == ZMODE_DEC)
// glEnable( GL_POLYGON_OFFSET_FILL );
// else
{
// glPolygonOffset( -3.0f, -3.0f );
if (gDP.otherMode.depthMode == ZMODE_DEC)
glEnable( GL_POLYGON_OFFSET_FILL );
else
glDisable( GL_POLYGON_OFFSET_FILL );
}
}
if ((gDP.changed & CHANGED_ALPHACOMPARE) || (gDP.changed & CHANGED_RENDERMODE))
{