]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
OpenGL 2.0 path: Make handling of Alpha-To-Coverage same as AlphaTest (enabling befor...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 11 May 2011 22:59:39 +0000 (22:59 +0000)
committervortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 11 May 2011 22:59:39 +0000 (22:59 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11146 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_rmain.c
r_shadow.c
vid_sdl.c

index e8d2e6408dd4dc597c2a52bfbb9dbb86e4ec4c10..5fbf7979fc6ef37406d8bdd491726e427e91acbf 100644 (file)
@@ -1437,7 +1437,7 @@ static void GL_Backend_ResetState(void)
 
                qglColorMask(1, 1, 1, 1);CHECKGLERROR
                qglAlphaFunc(gl_state.alphafunc, gl_state.alphafuncvalue);CHECKGLERROR
-               qglDisable((vid_multisampling.integer && r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
+               qglDisable((r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
                qglBlendFunc(gl_state.blendfunc1, gl_state.blendfunc2);CHECKGLERROR
                qglDisable(GL_BLEND);CHECKGLERROR
                qglCullFace(gl_state.cullface);CHECKGLERROR
@@ -2134,11 +2134,11 @@ void GL_AlphaTest(int state)
                        CHECKGLERROR
                        if (gl_state.alphatest)
                        {
-                               qglEnable((vid_multisampling.integer && r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
+                               qglEnable((r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
                        }
                        else
                        {
-                               qglDisable((vid_multisampling.integer && r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
+                               qglDisable((r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
                        }
                        break;
                case RENDERPATH_D3D9:
index 020fa1e8ab9db3fbbebf3b4232c122ad7606dacd..354160da4166f594ee9e76c55591b359d6facd62 100644 (file)
@@ -2092,12 +2092,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
        matrix4x4_t tempmatrix;
        r_waterstate_waterplane_t *waterplane = (r_waterstate_waterplane_t *)surfacewaterplane;
        if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-       {
                permutation |= SHADERPERMUTATION_ALPHAKILL;
-               GL_AlphaTest(true);
-       }
-       else
-               GL_AlphaTest(false);
        if (rsurface.texture->r_water_waterscroll[0] && rsurface.texture->r_water_waterscroll[1])
                permutation |= SHADERPERMUTATION_NORMALMAPSCROLLBLEND; // todo: make generic
        if (rsurfacepass == RSURFPASS_BACKGROUND)
@@ -9461,7 +9456,6 @@ static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface
                GL_DepthMask(true);
                R_SetupShader_Surface(vec3_origin, (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) != 0, 1, 1, rsurface.texture->specularscale, RSURFPASS_DEFERREDGEOMETRY, texturenumsurfaces, texturesurfacelist, NULL);
                RSurf_DrawBatch();
-               return;
        }
 
        // bind lightmap texture
@@ -9508,7 +9502,11 @@ static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface
        // render surface batch normally
        GL_DepthMask(writedepth && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_BLENDED));
        R_SetupShader_Surface(vec3_origin, (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) != 0, 1, 1, rsurface.texture->specularscale, RSURFPASS_BASE, texturenumsurfaces, texturesurfacelist, NULL);
+       if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
+               GL_AlphaTest(true);
        RSurf_DrawBatch();
+       if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
+               GL_AlphaTest(false);
 }
 
 static void R_DrawTextureSurfaceList_GL13(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth)
index 47507cf91484eacd0a6c1cb1db160450384044af..909015ebef7dca093f1c8462f56df201307cb8ad 100644 (file)
@@ -1952,7 +1952,6 @@ void R_Shadow_RenderMode_Begin(void)
        CHECKGLERROR
        R_Mesh_ResetTextureState();
        GL_BlendFunc(GL_ONE, GL_ZERO);
-       GL_AlphaTest(false);
        GL_DepthRange(0, 1);
        GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
        GL_DepthTest(true);
@@ -3170,10 +3169,16 @@ static void R_Shadow_RenderLighting_Light_GLSL(int texturenumsurfaces, const msu
        // ARB2 GLSL shader path (GFFX5200, Radeon 9500)
        R_SetupShader_Surface(lightcolor, false, ambientscale, diffusescale, specularscale, RSURFPASS_RTLIGHT, texturenumsurfaces, texturesurfacelist, NULL);
        if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
+       {
                GL_DepthFunc(GL_EQUAL);
+               GL_AlphaTest(true);
+       }
        RSurf_DrawBatch();
        if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
+       {
                GL_DepthFunc(GL_LEQUAL);
+               GL_AlphaTest(false);
+       }
 }
 
 static void R_Shadow_RenderLighting_Light_Vertex_Pass(int firstvertex, int numvertices, int numtriangles, const int *element3i, vec3_t diffusecolor2, vec3_t ambientcolor2)
index f7f95bb4ecce1a247b375b73fe67cbca8da978c5..fdd70caaa2c386827c795f4d90ade552b1e771d2 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -2294,10 +2294,16 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
        vid_usinghidecursor = false;
 
        // enable multisampling
-       if (mode->samples > 1 && vid_multisampling.integer)
+       if (vid_multisampling.integer)
        {
                if (vid.support.arb_multisample)
+               {
                        qglEnable(GL_MULTISAMPLE_ARB);
+                       // it seems that enabling GL_MULTISAMPLE_ARB forces antialiasing to always work, fix the cvar as well
+                       // make sure vid_sample is at least 2 to make things correct
+                       if (vid_samples.integer < 2)
+                               Cvar_SetValueQuick(&vid_samples, 0);    
+               }
                else
                {
                        Cvar_SetValueQuick(&vid_multisampling, 0);