From 782cf9ec572ccb022d81d23d42e1fd69f2d2890e Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 2 Mar 2009 15:26:43 +0000 Subject: [PATCH] work around ATI bug in corona occlusion testing (use glDepthFunc, not glEnable) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8770 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 1 + r_shadow.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gl_rmain.c b/gl_rmain.c index eada61fd..3a3416bf 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -4358,6 +4358,7 @@ float spritetexcoord2f[4*2] = {0, 1, 0, 0, 1, 0, 1, 1}; void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, qboolean depthdisable, qboolean depthshort, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca) { + // NOTE: this must not call qglDepthFunc (see r_shadow.c, R_BeginCoronaQuery) thanks to ATI float fog = 1.0f; float vertex3f[12]; diff --git a/r_shadow.c b/r_shadow.c index b8e2e51f..5b98bd1e 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -3520,9 +3520,12 @@ void R_BeginCoronaQuery(rtlight_t *rtlight, float scale, qboolean usequery) rtlight->corona_queryindex_allpixels = r_queries[r_numqueries++]; rtlight->corona_queryindex_visiblepixels = r_queries[r_numqueries++]; CHECKGLERROR + // NOTE: we can't disable depth testing using R_DrawSprite's depthdisable argument, which calls GL_DepthTest, as that's broken in the ATI drivers qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, rtlight->corona_queryindex_allpixels); - R_DrawSprite(GL_ONE, GL_ZERO, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, 1, 1, 1, 1); + qglDepthFunc(GL_ALWAYS); + R_DrawSprite(GL_ONE, GL_ZERO, r_shadow_lightcorona, NULL, false, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, 1, 1, 1, 1); qglEndQueryARB(GL_SAMPLES_PASSED_ARB); + qglDepthFunc(GL_LEQUAL); qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, rtlight->corona_queryindex_visiblepixels); R_DrawSprite(GL_ONE, GL_ZERO, r_shadow_lightcorona, NULL, false, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, 1, 1, 1, 1); qglEndQueryARB(GL_SAMPLES_PASSED_ARB); -- 2.39.2