renderer now uses vid.renderpath to select rendering techniques instead
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 9 Dec 2009 12:26:15 +0000 (12:26 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 9 Dec 2009 12:26:15 +0000 (12:26 +0000)
of r_glsl and gl_combine cvars (which are now read-only), use vid_gl13
and vid_gl20 to select a rendering path at startup

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9575 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
gl_backend.c
gl_draw.c
gl_rmain.c
r_shadow.c
render.h
vid_shared.c

index 687b2ab..0054851 100644 (file)
@@ -2071,16 +2071,6 @@ void CL_UpdateScreen(void)
        if (scr_fov.value > 170)
                Cvar_Set ("fov","170");
 
-       // validate r_textureunits cvar
-       if (r_textureunits.integer > (int)vid.texunits)
-               Cvar_SetValueQuick(&r_textureunits, vid.texunits);
-       if (r_textureunits.integer < 1)
-               Cvar_SetValueQuick(&r_textureunits, 1);
-
-       // validate gl_combine cvar
-       if (gl_combine.integer && !vid.support.arb_texture_env_combine)
-               Cvar_SetValueQuick(&gl_combine, 0);
-
        // intermission is always full screen
        if (cl.intermission)
                sb_lines = 0;
index 6ca588b..529401f 100644 (file)
@@ -1755,58 +1755,78 @@ void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, i
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
        CHECKGLERROR
-       if (!combinergb)
-               combinergb = GL_MODULATE;
-       if (!combinealpha)
-               combinealpha = GL_MODULATE;
-       if (!rgbscale)
-               rgbscale = 1;
-       if (!alphascale)
-               alphascale = 1;
-       if (combinergb != combinealpha || rgbscale != 1 || alphascale != 1 || combinergb == GL_DOT3_RGBA_ARB || combinergb == GL_DOT3_RGB_ARB)
+       switch(vid.renderpath)
        {
-               if (combinergb == GL_DECAL)
-                       combinergb = GL_INTERPOLATE_ARB;
-               if (unit->combine != GL_COMBINE_ARB)
-               {
-                       unit->combine = GL_COMBINE_ARB;
-                       GL_ActiveTexture(unitnum);
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);CHECKGLERROR
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE);CHECKGLERROR // for GL_INTERPOLATE_ARB mode
-               }
-               if (unit->combinergb != combinergb)
-               {
-                       unit->combinergb = combinergb;
-                       GL_ActiveTexture(unitnum);
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, unit->combinergb);CHECKGLERROR
-               }
-               if (unit->combinealpha != combinealpha)
-               {
-                       unit->combinealpha = combinealpha;
-                       GL_ActiveTexture(unitnum);
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, unit->combinealpha);CHECKGLERROR
-               }
-               if (unit->rgbscale != rgbscale)
+       case RENDERPATH_GL20:
+               // do nothing
+               break;
+       case RENDERPATH_GL13:
+               // GL_ARB_texture_env_combine
+               if (!combinergb)
+                       combinergb = GL_MODULATE;
+               if (!combinealpha)
+                       combinealpha = GL_MODULATE;
+               if (!rgbscale)
+                       rgbscale = 1;
+               if (!alphascale)
+                       alphascale = 1;
+               if (combinergb != combinealpha || rgbscale != 1 || alphascale != 1 || combinergb == GL_DOT3_RGBA_ARB || combinergb == GL_DOT3_RGB_ARB)
                {
-                       unit->rgbscale = rgbscale;
-                       GL_ActiveTexture(unitnum);
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, unit->rgbscale);CHECKGLERROR
+                       if (combinergb == GL_DECAL)
+                               combinergb = GL_INTERPOLATE_ARB;
+                       if (unit->combine != GL_COMBINE_ARB)
+                       {
+                               unit->combine = GL_COMBINE_ARB;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE);CHECKGLERROR // for GL_INTERPOLATE_ARB mode
+                       }
+                       if (unit->combinergb != combinergb)
+                       {
+                               unit->combinergb = combinergb;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, unit->combinergb);CHECKGLERROR
+                       }
+                       if (unit->combinealpha != combinealpha)
+                       {
+                               unit->combinealpha = combinealpha;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, unit->combinealpha);CHECKGLERROR
+                       }
+                       if (unit->rgbscale != rgbscale)
+                       {
+                               unit->rgbscale = rgbscale;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, unit->rgbscale);CHECKGLERROR
+                       }
+                       if (unit->alphascale != alphascale)
+                       {
+                               unit->alphascale = alphascale;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, unit->alphascale);CHECKGLERROR
+                       }
                }
-               if (unit->alphascale != alphascale)
+               else
                {
-                       unit->alphascale = alphascale;
-                       GL_ActiveTexture(unitnum);
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, unit->alphascale);CHECKGLERROR
+                       if (unit->combine != combinergb)
+                       {
+                               unit->combine = combinergb;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->combine);CHECKGLERROR
+                       }
                }
-       }
-       else
-       {
+               break;
+       case RENDERPATH_GL11:
+               // normal GL texenv
+               if (!combinergb)
+                       combinergb = GL_MODULATE;
                if (unit->combine != combinergb)
                {
                        unit->combine = combinergb;
                        GL_ActiveTexture(unitnum);
                        qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->combine);CHECKGLERROR
                }
+               break;
        }
 }
 
@@ -1841,84 +1861,118 @@ void R_Mesh_ResetTextureState(void)
        BACKENDACTIVECHECK
 
        CHECKGLERROR
-       for (unitnum = 0;unitnum < vid.teximageunits;unitnum++)
+       switch(vid.renderpath)
        {
-               gltextureunit_t *unit = gl_state.units + unitnum;
-               // update 2d texture binding
-               if (unit->t2d)
+       case RENDERPATH_GL20:
+               for (unitnum = 0;unitnum < vid.teximageunits;unitnum++)
                {
-                       GL_ActiveTexture(unitnum);
-                       if (unitnum < vid.texunits)
+                       gltextureunit_t *unit = gl_state.units + unitnum;
+                       if (unit->t2d)
                        {
-                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                               unit->t2d = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
+                       }
+                       if (unit->t3d)
+                       {
+                               unit->t3d = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
+                       }
+                       if (unit->tcubemap)
+                       {
+                               unit->tcubemap = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
+                       }
+                       if (unit->trectangle)
+                       {
+                               unit->trectangle = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglBindTexture(GL_TEXTURE_RECTANGLE_ARB, unit->trectangle);CHECKGLERROR
                        }
-                       unit->t2d = 0;
-                       qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
                }
-               // update 3d texture binding
-               if (unit->t3d)
+               for (unitnum = 0;unitnum < vid.texarrayunits;unitnum++)
                {
-                       GL_ActiveTexture(unitnum);
-                       if (unitnum < vid.texunits)
+                       gltextureunit_t *unit = gl_state.units + unitnum;
+                       if (unit->arrayenabled)
                        {
-                               qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                               unit->arrayenabled = false;
+                               GL_ClientActiveTexture(unitnum);
+                               qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
                        }
-                       unit->t3d = 0;
-                       qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
                }
-               // update cubemap texture binding
-               if (unit->tcubemap)
+               for (unitnum = 0;unitnum < vid.texunits;unitnum++)
                {
-                       GL_ActiveTexture(unitnum);
-                       if (unitnum < vid.texunits)
+                       gltextureunit_t *unit = gl_state.units + unitnum;
+                       if (unit->texmatrixenabled)
                        {
-                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                               unit->texmatrixenabled = false;
+                               unit->matrix = identitymatrix;
+                               CHECKGLERROR
+                               GL_ActiveTexture(unitnum);
+                               qglMatrixMode(GL_TEXTURE);CHECKGLERROR
+                               qglLoadIdentity();CHECKGLERROR
+                               qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
                        }
-                       unit->tcubemap = 0;
-                       qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
                }
-               // update rectangle texture binding
-               if (unit->trectangle)
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               for (unitnum = 0;unitnum < vid.texunits;unitnum++)
                {
-                       GL_ActiveTexture(unitnum);
-                       if (unitnum < vid.texunits)
+                       gltextureunit_t *unit = gl_state.units + unitnum;
+                       if (unit->t2d)
+                       {
+                               unit->t2d = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
+                       }
+                       if (unit->t3d)
+                       {
+                               unit->t3d = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
+                       }
+                       if (unit->tcubemap)
+                       {
+                               unit->tcubemap = 0;
+                               GL_ActiveTexture(unitnum);
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
+                       }
+                       if (unit->trectangle)
                        {
+                               unit->trectangle = 0;
+                               GL_ActiveTexture(unitnum);
                                qglDisable(GL_TEXTURE_RECTANGLE_ARB);CHECKGLERROR
+                               qglBindTexture(GL_TEXTURE_RECTANGLE_ARB, unit->trectangle);CHECKGLERROR
+                       }
+                       if (unit->arrayenabled)
+                       {
+                               unit->arrayenabled = false;
+                               GL_ClientActiveTexture(unitnum);
+                               qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       }
+                       if (unit->texmatrixenabled)
+                       {
+                               unit->texmatrixenabled = false;
+                               unit->matrix = identitymatrix;
+                               CHECKGLERROR
+                               GL_ActiveTexture(unitnum);
+                               qglMatrixMode(GL_TEXTURE);CHECKGLERROR
+                               qglLoadIdentity();CHECKGLERROR
+                               qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
+                       }
+                       if (unit->combine != GL_MODULATE)
+                       {
+                               unit->combine = GL_MODULATE;
+                               GL_ActiveTexture(unitnum);
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->combine);CHECKGLERROR
                        }
-                       unit->trectangle = 0;
-                       qglBindTexture(GL_TEXTURE_RECTANGLE_ARB, unit->trectangle);CHECKGLERROR
-               }
-       }
-       for (unitnum = 0;unitnum < vid.texarrayunits;unitnum++)
-       {
-               gltextureunit_t *unit = gl_state.units + unitnum;
-               // texture array unit is disabled, disable the array
-               if (unit->arrayenabled)
-               {
-                       unit->arrayenabled = false;
-                       GL_ClientActiveTexture(unitnum);
-                       qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
-               }
-       }
-       for (unitnum = 0;unitnum < vid.texunits;unitnum++)
-       {
-               gltextureunit_t *unit = gl_state.units + unitnum;
-               // no texmatrix specified, revert to identity
-               if (unit->texmatrixenabled)
-               {
-                       unit->texmatrixenabled = false;
-                       unit->matrix = identitymatrix;
-                       CHECKGLERROR
-                       GL_ActiveTexture(unitnum);
-                       qglMatrixMode(GL_TEXTURE);CHECKGLERROR
-                       qglLoadIdentity();CHECKGLERROR
-                       qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
-               }
-               if (unit->combine != GL_MODULATE)
-               {
-                       unit->combine = GL_MODULATE;
-                       GL_ActiveTexture(unitnum);
-                       qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->combine);CHECKGLERROR
                }
+               break;
        }
 }
index 7a0fa72..6061c8d 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -1339,49 +1339,58 @@ static float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 1000
 void R_DrawGamma(void)
 {
        float c[4];
-       if (!vid_usinghwgamma && !(r_glsl.integer && v_glslgamma.integer))
+       switch(vid.renderpath)
        {
-               // all the blends ignore depth
-               R_Mesh_VertexPointer(blendvertex3f, 0, 0);
-               R_Mesh_ColorPointer(NULL, 0, 0);
-               R_Mesh_ResetTextureState();
-               R_SetupGenericShader(false);
-               GL_DepthMask(true);
-               GL_DepthRange(0, 1);
-               GL_PolygonOffset(0, 0);
-               GL_DepthTest(false);
-               if (v_color_enable.integer)
-               {
-                       c[0] = v_color_white_r.value;
-                       c[1] = v_color_white_g.value;
-                       c[2] = v_color_white_b.value;
-               }
-               else
-                       c[0] = c[1] = c[2] = v_contrast.value;
-               if (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
-               {
-                       GL_BlendFunc(GL_DST_COLOR, GL_ONE);
-                       while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
-                       {
-                               GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1);
-                               R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
-                               VectorScale(c, 0.5, c);
-                       }
-               }
-               if (v_color_enable.integer)
-               {
-                       c[0] = v_color_black_r.value;
-                       c[1] = v_color_black_g.value;
-                       c[2] = v_color_black_b.value;
-               }
-               else
-                       c[0] = c[1] = c[2] = v_brightness.value;
-               if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f)
+       case RENDERPATH_GL20:
+               if (vid_usinghwgamma || v_glslgamma.integer)
+                       return;
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               if (vid_usinghwgamma)
+                       return;
+               break;
+       }
+       // all the blends ignore depth
+       R_Mesh_VertexPointer(blendvertex3f, 0, 0);
+       R_Mesh_ColorPointer(NULL, 0, 0);
+       R_Mesh_ResetTextureState();
+       R_SetupGenericShader(false);
+       GL_DepthMask(true);
+       GL_DepthRange(0, 1);
+       GL_PolygonOffset(0, 0);
+       GL_DepthTest(false);
+       if (v_color_enable.integer)
+       {
+               c[0] = v_color_white_r.value;
+               c[1] = v_color_white_g.value;
+               c[2] = v_color_white_b.value;
+       }
+       else
+               c[0] = c[1] = c[2] = v_contrast.value;
+       if (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
+       {
+               GL_BlendFunc(GL_DST_COLOR, GL_ONE);
+               while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
                {
-                       GL_BlendFunc(GL_ONE, GL_ONE);
-                       GL_Color(c[0], c[1], c[2], 1);
+                       GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1);
                        R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
+                       VectorScale(c, 0.5, c);
                }
        }
+       if (v_color_enable.integer)
+       {
+               c[0] = v_color_black_r.value;
+               c[1] = v_color_black_g.value;
+               c[2] = v_color_black_b.value;
+       }
+       else
+               c[0] = c[1] = c[2] = v_brightness.value;
+       if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f)
+       {
+               GL_BlendFunc(GL_ONE, GL_ONE);
+               GL_Color(c[0], c[1], c[2], 1);
+               R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
+       }
 }
 
index df28719..71bdf13 100644 (file)
@@ -108,8 +108,8 @@ cvar_t gl_fogend = {0, "gl_fogend","0", "nehahra fog end distance (for Nehahra c
 cvar_t gl_skyclip = {0, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"};
 
 cvar_t r_textureunits = {0, "r_textureunits", "32", "number of texture units to use in GL 1.1 and GL 1.3 rendering paths"};
-cvar_t gl_combine = {0, "gl_combine", "1", "enables the OpenGL 1.3 rendering path"};
-cvar_t r_glsl = {CVAR_SAVE, "r_glsl", "1", "enables the OpenGL 2.0 rendering path"};
+static cvar_t gl_combine = {CVAR_READONLY, "gl_combine", "1", "indicates whether the OpenGL 1.3 rendering path is active"};
+static cvar_t r_glsl = {CVAR_READONLY, "r_glsl", "1", "indicates whether the OpenGL 2.0 rendering path is active"};
 
 cvar_t r_glsl_deluxemapping = {CVAR_SAVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"};
 cvar_t r_glsl_offsetmapping = {CVAR_SAVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"};
@@ -2041,59 +2041,56 @@ void R_SetupShader_SetPermutation(unsigned int mode, unsigned int permutation)
 
 void R_SetupGenericShader(qboolean usetexture)
 {
-       if (vid.support.arb_fragment_shader)
+       switch(vid.renderpath)
        {
-               if (r_glsl.integer)
-                       R_SetupShader_SetPermutation(SHADERMODE_GENERIC, usetexture ? SHADERPERMUTATION_DIFFUSE : 0);
-               else if (r_glsl_permutation)
-               {
-                       r_glsl_permutation = NULL;
-                       qglUseProgramObjectARB(0);CHECKGLERROR
-               }
+       case RENDERPATH_GL20:
+               R_SetupShader_SetPermutation(SHADERMODE_GENERIC, usetexture ? SHADERPERMUTATION_DIFFUSE : 0);
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               break;
        }
 }
 
 void R_SetupGenericTwoTextureShader(int texturemode)
 {
-       if (vid.support.arb_fragment_shader)
+       switch (vid.renderpath)
        {
-               if (r_glsl.integer)
-                       R_SetupShader_SetPermutation(SHADERMODE_GENERIC, SHADERPERMUTATION_DIFFUSE | SHADERPERMUTATION_SPECULAR | (r_shadow_glossexact.integer ? SHADERPERMUTATION_EXACTSPECULARMATH : 0) | (texturemode == GL_MODULATE ? SHADERPERMUTATION_COLORMAPPING : (texturemode == GL_ADD ? SHADERPERMUTATION_GLOW : (texturemode == GL_DECAL ? SHADERPERMUTATION_VERTEXTEXTUREBLEND : 0))));
-               else if (r_glsl_permutation)
-               {
-                       r_glsl_permutation = NULL;
-                       qglUseProgramObjectARB(0);CHECKGLERROR
-               }
-       }
-       if (!r_glsl_permutation)
+       case RENDERPATH_GL20:
+               R_SetupShader_SetPermutation(SHADERMODE_GENERIC, SHADERPERMUTATION_DIFFUSE | SHADERPERMUTATION_SPECULAR | (r_shadow_glossexact.integer ? SHADERPERMUTATION_EXACTSPECULARMATH : 0) | (texturemode == GL_MODULATE ? SHADERPERMUTATION_COLORMAPPING : (texturemode == GL_ADD ? SHADERPERMUTATION_GLOW : (texturemode == GL_DECAL ? SHADERPERMUTATION_VERTEXTEXTUREBLEND : 0))));
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
                R_Mesh_TexCombine(1, GL_DECAL, GL_DECAL, 1, 1);
+               break;
+       }
 }
 
 void R_SetupDepthOrShadowShader(void)
 {
-       if (vid.support.arb_fragment_shader)
+       switch (vid.renderpath)
        {
-               if (r_glsl.integer)
-                       R_SetupShader_SetPermutation(SHADERMODE_DEPTH_OR_SHADOW, 0);
-               else if (r_glsl_permutation)
-               {
-                       r_glsl_permutation = NULL;
-                       qglUseProgramObjectARB(0);CHECKGLERROR
-               }
+       case RENDERPATH_GL20:
+               R_SetupShader_SetPermutation(SHADERMODE_DEPTH_OR_SHADOW, 0);
+               break;
+       case RENDERPATH_GL13:
+               break;
+       case RENDERPATH_GL11:
+               break;
        }
 }
 
 void R_SetupShowDepthShader(void)
 {
-       if (vid.support.arb_fragment_shader)
+       switch (vid.renderpath)
        {
-               if (r_glsl.integer)
-                       R_SetupShader_SetPermutation(SHADERMODE_SHOWDEPTH, 0);
-               else if (r_glsl_permutation)
-               {
-                       r_glsl_permutation = NULL;
-                       qglUseProgramObjectARB(0);CHECKGLERROR
-               }
+       case RENDERPATH_GL20:
+               R_SetupShader_SetPermutation(SHADERMODE_SHOWDEPTH, 0);
+               break;
+       case RENDERPATH_GL13:
+               break;
+       case RENDERPATH_GL11:
+               break;
        }
 }
 
@@ -2947,8 +2944,33 @@ void R_Main_ResizeViewCache(void)
 
 void gl_main_start(void)
 {
-       r_loadnormalmap = r_loadgloss = vid.support.arb_texture_env_dot3 || vid.support.arb_fragment_shader;
-       r_loadfog = true;
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL20:
+               Cvar_SetValueQuick(&r_textureunits, vid.texunits);
+               Cvar_SetValueQuick(&gl_combine, 1);
+               Cvar_SetValueQuick(&r_glsl, 1);
+               r_loadnormalmap = true;
+               r_loadgloss = true;
+               r_loadfog = false;
+               break;
+       case RENDERPATH_GL13:
+               Cvar_SetValueQuick(&r_textureunits, vid.texunits);
+               Cvar_SetValueQuick(&gl_combine, 1);
+               Cvar_SetValueQuick(&r_glsl, 0);
+               r_loadnormalmap = true;
+               r_loadgloss = true;
+               r_loadfog = true;
+               break;
+       case RENDERPATH_GL11:
+               Cvar_SetValueQuick(&r_textureunits, vid.texunits);
+               Cvar_SetValueQuick(&gl_combine, 0);
+               Cvar_SetValueQuick(&r_glsl, 0);
+               r_loadnormalmap = false;
+               r_loadgloss = false;
+               r_loadfog = true;
+               break;
+       }
 
        r_numqueries = 0;
        r_maxqueries = 0;
@@ -3458,14 +3480,21 @@ qboolean R_AnimCache_GetEntity(entity_render_t *ent, qboolean wantnormals, qbool
 void R_AnimCache_CacheVisibleEntities(void)
 {
        int i;
-       qboolean wantnormals;
-       qboolean wanttangents;
+       qboolean wantnormals = !r_showsurfaces.integer;
+       qboolean wanttangents = !r_showsurfaces.integer;
 
        if (!r_animcachestate.maxindex)
                return;
 
-       wantnormals = !r_showsurfaces.integer;
-       wanttangents = !r_showsurfaces.integer && (r_glsl.integer || r_refdef.scene.rtworld || r_refdef.scene.rtdlight);
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL20:
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               wanttangents = false;
+               break;
+       }
 
        // TODO: thread this?
 
@@ -4013,6 +4042,18 @@ static void R_Water_StartFrame(void)
        int waterwidth, waterheight, texturewidth, textureheight;
        r_waterstate_waterplane_t *p;
 
+       if (vid.width > (int)vid.maxtexturesize_2d || vid.height > (int)vid.maxtexturesize_2d)
+               return;
+
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL20:
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               return;
+       }
+
        // set waterwidth and waterheight to the water resolution that will be
        // used (often less than the screen resolution for faster rendering)
        waterwidth = (int)bound(1, vid.width * r_water_resolutionmultiplier.value, vid.width);
@@ -4020,7 +4061,7 @@ static void R_Water_StartFrame(void)
 
        // calculate desired texture sizes
        // can't use water if the card does not support the texture size
-       if (!r_water.integer || !r_glsl.integer || !vid.support.arb_fragment_shader || waterwidth > (int)vid.maxtexturesize_2d || waterheight > (int)vid.maxtexturesize_2d || r_showsurfaces.integer)
+       if (!r_water.integer || r_showsurfaces.integer)
                texturewidth = textureheight = waterwidth = waterheight = 0;
        else if (vid.support.arb_texture_non_power_of_two)
        {
@@ -4246,6 +4287,15 @@ void R_Bloom_StartFrame(void)
 {
        int bloomtexturewidth, bloomtextureheight, screentexturewidth, screentextureheight;
 
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL20:
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               return;
+       }
+
        // set bloomwidth and bloomheight to the bloom resolution that will be
        // used (often less than the screen resolution for faster rendering)
        r_bloomstate.bloomwidth = bound(1, r_bloom_resolution.integer, vid.height);
@@ -4278,7 +4328,7 @@ void R_Bloom_StartFrame(void)
                Cvar_SetValueQuick(&r_damageblur, 0);
        }
 
-       if (!(r_glsl.integer && (r_glsl_postprocess.integer || (!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) || (v_glslgamma.integer && !vid_gammatables_trivial))) && !r_bloom.integer && !r_hdr.integer && (R_Stereo_Active() || (r_motionblur.value <= 0 && r_damageblur.value <= 0)))
+       if (!(r_glsl_postprocess.integer || (!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) || (v_glslgamma.integer && !vid_gammatables_trivial)) && !r_bloom.integer && !r_hdr.integer && (R_Stereo_Active() || (r_motionblur.value <= 0 && r_damageblur.value <= 0)))
                screentexturewidth = screentextureheight = 0;
        if (!r_hdr.integer && !r_bloom.integer)
                bloomtexturewidth = bloomtextureheight = 0;
@@ -4548,72 +4598,77 @@ void R_HDR_RenderBloomTexture(void)
 
 static void R_BlendView(void)
 {
-       if (r_bloomstate.texture_screen)
-       {
-               // make sure the buffer is available
-               if (r_bloom_blur.value < 1) { Cvar_SetValueQuick(&r_bloom_blur, 1); }
-
-               R_ResetViewRendering2D();
-               R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
-               R_Mesh_ColorPointer(NULL, 0, 0);
-               R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
-               GL_ActiveTexture(0);CHECKGLERROR
-
-               if(!R_Stereo_Active() && (r_motionblur.value > 0 || r_damageblur.value > 0))
-               {  
-                       // declare variables
-                       float speed;
-                       static float avgspeed;
-
-                       speed = VectorLength(cl.movement_velocity);
-
-                       cl.motionbluralpha = bound(0, (cl.time - cl.oldtime) / max(0.001, r_motionblur_vcoeff.value), 1);
-                       avgspeed = avgspeed * (1 - cl.motionbluralpha) + speed * cl.motionbluralpha;
-
-                       speed = (avgspeed - r_motionblur_vmin.value) / max(1, r_motionblur_vmax.value - r_motionblur_vmin.value);
-                       speed = bound(0, speed, 1);
-                       speed = speed * (1 - r_motionblur_bmin.value) + r_motionblur_bmin.value;
-
-                       // calculate values into a standard alpha
-                       cl.motionbluralpha = 1 - exp(-
-                                       (
-                                        (r_motionblur.value * speed / 80)
-                                        +
-                                        (r_damageblur.value * (cl.cshifts[CSHIFT_DAMAGE].percent / 1600))
-                                       )
-                                       /
-                                       max(0.0001, cl.time - cl.oldtime) // fps independent
-                                  );
-
-                       cl.motionbluralpha *= lhrandom(1 - r_motionblur_randomize.value, 1 + r_motionblur_randomize.value);
-                       cl.motionbluralpha = bound(0, cl.motionbluralpha, r_motionblur_maxblur.value);
-                       // apply the blur
-                       if (cl.motionbluralpha > 0)
-                       {
-                               R_SetupGenericShader(true);
-                               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-                               GL_Color(1, 1, 1, cl.motionbluralpha);
-                               R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
-                               R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
-                               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
-                               r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
-                       }
-               }
-
-               // copy view into the screen texture
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.viewport.x, r_refdef.view.viewport.y, r_refdef.view.viewport.width, r_refdef.view.viewport.height);CHECKGLERROR
-               r_refdef.stats.bloom_copypixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
-       }
+       unsigned int permutation;
 
-       if (r_glsl.integer && vid.support.arb_fragment_shader && (r_bloomstate.texture_screen || r_bloomstate.texture_bloom))
+       switch (vid.renderpath)
        {
-               unsigned int permutation =
+       case RENDERPATH_GL20:
+               permutation =
                          (r_bloomstate.texture_bloom ? SHADERPERMUTATION_BLOOM : 0)
                        | (r_refdef.viewblend[3] > 0 ? SHADERPERMUTATION_VIEWTINT : 0)
                        | ((v_glslgamma.value && !vid_gammatables_trivial) ? SHADERPERMUTATION_GAMMARAMPS : 0)
                        | (r_glsl_postprocess.integer ? SHADERPERMUTATION_POSTPROCESSING : 0)
                        | ((!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) ? SHADERPERMUTATION_SATURATION : 0);
 
+               if (r_bloomstate.texture_screen)
+               {
+                       // make sure the buffer is available
+                       if (r_bloom_blur.value < 1) { Cvar_SetValueQuick(&r_bloom_blur, 1); }
+
+                       R_ResetViewRendering2D();
+                       R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
+                       R_Mesh_ColorPointer(NULL, 0, 0);
+                       R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
+                       GL_ActiveTexture(0);CHECKGLERROR
+
+                       if(!R_Stereo_Active() && (r_motionblur.value > 0 || r_damageblur.value > 0))
+                       {
+                               // declare variables
+                               float speed;
+                               static float avgspeed;
+
+                               speed = VectorLength(cl.movement_velocity);
+
+                               cl.motionbluralpha = bound(0, (cl.time - cl.oldtime) / max(0.001, r_motionblur_vcoeff.value), 1);
+                               avgspeed = avgspeed * (1 - cl.motionbluralpha) + speed * cl.motionbluralpha;
+
+                               speed = (avgspeed - r_motionblur_vmin.value) / max(1, r_motionblur_vmax.value - r_motionblur_vmin.value);
+                               speed = bound(0, speed, 1);
+                               speed = speed * (1 - r_motionblur_bmin.value) + r_motionblur_bmin.value;
+
+                               // calculate values into a standard alpha
+                               cl.motionbluralpha = 1 - exp(-
+                                               (
+                                                (r_motionblur.value * speed / 80)
+                                                +
+                                                (r_damageblur.value * (cl.cshifts[CSHIFT_DAMAGE].percent / 1600))
+                                               )
+                                               /
+                                               max(0.0001, cl.time - cl.oldtime) // fps independent
+                                          );
+
+                               cl.motionbluralpha *= lhrandom(1 - r_motionblur_randomize.value, 1 + r_motionblur_randomize.value);
+                               cl.motionbluralpha = bound(0, cl.motionbluralpha, r_motionblur_maxblur.value);
+                               // apply the blur
+                               if (cl.motionbluralpha > 0)
+                               {
+                                       R_SetupGenericShader(true);
+                                       GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+                                       GL_Color(1, 1, 1, cl.motionbluralpha);
+                                       R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
+                                       R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
+                                       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
+                                       r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
+                               }
+                       }
+
+                       // copy view into the screen texture
+                       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.viewport.x, r_refdef.view.viewport.y, r_refdef.view.viewport.width, r_refdef.view.viewport.height);CHECKGLERROR
+                       r_refdef.stats.bloom_copypixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
+               }
+               else if (!r_bloomstate.texture_bloom)
+                       break; // no screen processing, no bloom, skip it
+
                if (r_bloomstate.texture_bloom && !r_bloomstate.hdr)
                {
                        // render simple bloom effect
@@ -4672,73 +4727,21 @@ static void R_BlendView(void)
                        qglUniform1fARB(r_glsl_permutation->loc_Saturation, r_glsl_saturation.value);
                R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
-               return;
-       }
-
-
-
-       if (r_bloomstate.texture_bloom && r_bloomstate.hdr)
-       {
-               // render high dynamic range bloom effect
-               // the bloom texture was made earlier this render, so we just need to
-               // blend it onto the screen...
-               R_ResetViewRendering2D();
-               R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
-               R_Mesh_ColorPointer(NULL, 0, 0);
-               R_SetupGenericShader(true);
-               GL_Color(1, 1, 1, 1);
-               GL_BlendFunc(GL_ONE, GL_ONE);
-               R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
-               R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
-               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
-               r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
-       }
-       else if (r_bloomstate.texture_bloom)
-       {
-               // render simple bloom effect
-               // copy the screen and shrink it and darken it for the bloom process
-               R_Bloom_CopyBloomTexture(r_bloom_colorscale.value);
-               // make the bloom texture
-               R_Bloom_MakeTexture();
-               // put the original screen image back in place and blend the bloom
-               // texture on it
-               R_ResetViewRendering2D();
-               R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
-               R_Mesh_ColorPointer(NULL, 0, 0);
-               GL_Color(1, 1, 1, 1);
-               GL_BlendFunc(GL_ONE, GL_ZERO);
-               // do both in one pass if possible
-               R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
-               R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
-               if (r_textureunits.integer >= 2 && gl_combine.integer)
-               {
-                       R_SetupGenericTwoTextureShader(GL_ADD);
-                       R_Mesh_TexBind(1, R_GetTexture(r_bloomstate.texture_screen));
-                       R_Mesh_TexCoordPointer(1, 2, r_bloomstate.screentexcoord2f, 0, 0);
-               }
-               else
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               if (r_refdef.viewblend[3] >= (1.0f / 256.0f))
                {
-                       R_SetupGenericShader(true);
+                       // apply a color tint to the whole view
+                       R_ResetViewRendering2D();
+                       R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
+                       R_Mesh_ColorPointer(NULL, 0, 0);
+                       R_SetupGenericShader(false);
+                       GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+                       GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
                        R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
-                       r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
-                       // now blend on the bloom texture
-                       GL_BlendFunc(GL_ONE, GL_ONE);
-                       R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
-                       R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
                }
-               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
-               r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
-       }
-       if (r_refdef.viewblend[3] >= (1.0f / 256.0f))
-       {
-               // apply a color tint to the whole view
-               R_ResetViewRendering2D();
-               R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
-               R_Mesh_ColorPointer(NULL, 0, 0);
-               R_SetupGenericShader(false);
-               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-               GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
-               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
+               break;
        }
 }
 
@@ -4858,39 +4861,47 @@ void R_UpdateVariables(void)
        else
                r_refdef.fogenabled = false;
 
-       if(r_glsl.integer && v_glslgamma.integer && !vid_gammatables_trivial)
+       switch(vid.renderpath)
        {
-               if(!r_texture_gammaramps || vid_gammatables_serial != r_texture_gammaramps_serial)
+       case RENDERPATH_GL20:
+               if(v_glslgamma.integer && !vid_gammatables_trivial)
                {
-                       // build GLSL gamma texture
+                       if(!r_texture_gammaramps || vid_gammatables_serial != r_texture_gammaramps_serial)
+                       {
+                               // build GLSL gamma texture
 #define RAMPWIDTH 256
-                       unsigned short ramp[RAMPWIDTH * 3];
-                       unsigned char rampbgr[RAMPWIDTH][4];
-                       int i;
+                               unsigned short ramp[RAMPWIDTH * 3];
+                               unsigned char rampbgr[RAMPWIDTH][4];
+                               int i;
 
-                       r_texture_gammaramps_serial = vid_gammatables_serial;
+                               r_texture_gammaramps_serial = vid_gammatables_serial;
 
-                       VID_BuildGammaTables(&ramp[0], RAMPWIDTH);
-                       for(i = 0; i < RAMPWIDTH; ++i)
-                       {
-                               rampbgr[i][0] = (unsigned char) (ramp[i + 2 * RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
-                               rampbgr[i][1] = (unsigned char) (ramp[i + RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
-                               rampbgr[i][2] = (unsigned char) (ramp[i] * 255.0 / 65535.0 + 0.5);
-                               rampbgr[i][3] = 0;
-                       }
-                       if (r_texture_gammaramps)
-                       {
-                               R_UpdateTexture(r_texture_gammaramps, &rampbgr[0][0], 0, 0, RAMPWIDTH, 1);
-                       }
-                       else
-                       {
-                               r_texture_gammaramps = R_LoadTexture2D(r_main_texturepool, "gammaramps", RAMPWIDTH, 1, &rampbgr[0][0], TEXTYPE_BGRA, TEXF_PRECACHE | TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_PERSISTENT, NULL);
+                               VID_BuildGammaTables(&ramp[0], RAMPWIDTH);
+                               for(i = 0; i < RAMPWIDTH; ++i)
+                               {
+                                       rampbgr[i][0] = (unsigned char) (ramp[i + 2 * RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
+                                       rampbgr[i][1] = (unsigned char) (ramp[i + RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
+                                       rampbgr[i][2] = (unsigned char) (ramp[i] * 255.0 / 65535.0 + 0.5);
+                                       rampbgr[i][3] = 0;
+                               }
+                               if (r_texture_gammaramps)
+                               {
+                                       R_UpdateTexture(r_texture_gammaramps, &rampbgr[0][0], 0, 0, RAMPWIDTH, 1);
+                               }
+                               else
+                               {
+                                       r_texture_gammaramps = R_LoadTexture2D(r_main_texturepool, "gammaramps", RAMPWIDTH, 1, &rampbgr[0][0], TEXTYPE_BGRA, TEXF_PRECACHE | TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_PERSISTENT, NULL);
+                               }
                        }
                }
-       }
-       else
-       {
-               // remove GLSL gamma texture
+               else
+               {
+                       // remove GLSL gamma texture
+               }
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               break;
        }
 }
 
@@ -7893,13 +7904,22 @@ static void R_DrawWorldTextureSurfaceList(int texturenumsurfaces, const msurface
        CHECKGLERROR
        RSurf_SetupDepthAndCulling();
        if (r_showsurfaces.integer == 3)
+       {
                R_DrawTextureSurfaceList_ShowSurfaces3(texturenumsurfaces, texturesurfacelist, writedepth);
-       else if (r_glsl.integer && vid.support.arb_fragment_shader)
+               return;
+       }
+       switch (vid.renderpath)
+       {
+       case RENDERPATH_GL20:
                R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth);
-       else if (gl_combine.integer && r_textureunits.integer >= 2)
+               break;
+       case RENDERPATH_GL13:
                R_DrawTextureSurfaceList_GL13(texturenumsurfaces, texturesurfacelist, writedepth);
-       else
+               break;
+       case RENDERPATH_GL11:
                R_DrawTextureSurfaceList_GL11(texturenumsurfaces, texturesurfacelist, writedepth);
+               break;
+       }
        CHECKGLERROR
 }
 
@@ -7908,13 +7928,22 @@ static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface
        CHECKGLERROR
        RSurf_SetupDepthAndCulling();
        if (r_showsurfaces.integer == 3)
+       {
                R_DrawTextureSurfaceList_ShowSurfaces3(texturenumsurfaces, texturesurfacelist, writedepth);
-       else if (r_glsl.integer && vid.support.arb_fragment_shader)
+               return;
+       }
+       switch (vid.renderpath)
+       {
+       case RENDERPATH_GL20:
                R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth);
-       else if (gl_combine.integer && r_textureunits.integer >= 2)
+               break;
+       case RENDERPATH_GL13:
                R_DrawTextureSurfaceList_GL13(texturenumsurfaces, texturesurfacelist, writedepth);
-       else
+               break;
+       case RENDERPATH_GL11:
                R_DrawTextureSurfaceList_GL11(texturenumsurfaces, texturesurfacelist, writedepth);
+               break;
+       }
        CHECKGLERROR
 }
 
@@ -7934,7 +7963,18 @@ static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const
        else if (r_showsurfaces.integer && r_showsurfaces.integer != 3)
                RSurf_ActiveModelEntity(ent, false, false);
        else
-               RSurf_ActiveModelEntity(ent, true, r_glsl.integer && vid.support.arb_fragment_shader);
+       {
+               switch (vid.renderpath)
+               {
+               case RENDERPATH_GL20:
+                       RSurf_ActiveModelEntity(ent, true, true);
+                       break;
+               case RENDERPATH_GL13:
+               case RENDERPATH_GL11:
+                       RSurf_ActiveModelEntity(ent, true, false);
+                       break;
+               }
+       }
 
        for (i = 0;i < numsurfaces;i = j)
        {
@@ -9104,7 +9144,18 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr
        else if (depthonly)
                RSurf_ActiveModelEntity(ent, false, false);
        else
-               RSurf_ActiveModelEntity(ent, true, r_glsl.integer && vid.support.arb_fragment_shader);
+       {
+               switch (vid.renderpath)
+               {
+               case RENDERPATH_GL20:
+                       RSurf_ActiveModelEntity(ent, true, true);
+                       break;
+               case RENDERPATH_GL13:
+               case RENDERPATH_GL11:
+                       RSurf_ActiveModelEntity(ent, true, false);
+                       break;
+               }
+       }
 
        surfaces = model->data_surfaces;
        update = model->brushq1.lightmapupdateflags;
index a57fdd2..ae949b6 100644 (file)
@@ -305,7 +305,7 @@ cvar_t r_shadow_shadowmapping_polygonoffset = {CVAR_SAVE, "r_shadow_shadowmappin
 cvar_t r_shadow_culltriangles = {0, "r_shadow_culltriangles", "1", "performs more expensive tests to remove unnecessary triangles of lit surfaces"};
 cvar_t r_shadow_polygonfactor = {0, "r_shadow_polygonfactor", "0", "how much to enlarge shadow volume polygons when rendering (should be 0!)"};
 cvar_t r_shadow_polygonoffset = {0, "r_shadow_polygonoffset", "1", "how much to push shadow volumes into the distance when rendering, to reduce chances of zfighting artifacts (should not be less than 0)"};
-cvar_t r_shadow_texture3d = {0, "r_shadow_texture3d", "1", "use 3D voxel textures for spherical attenuation rather than cylindrical (does not affect r_glsl lighting)"};
+cvar_t r_shadow_texture3d = {0, "r_shadow_texture3d", "1", "use 3D voxel textures for spherical attenuation rather than cylindrical (does not affect OpenGL 2.0 render path)"};
 cvar_t r_coronas = {CVAR_SAVE, "r_coronas", "1", "brightness of corona flare effects around certain lights, 0 disables corona effects"};
 cvar_t r_coronas_occlusionsizescale = {CVAR_SAVE, "r_coronas_occlusionsizescale", "0.1", "size of light source for corona occlusion checksm the proportion of hidden pixels controls corona intensity"};
 cvar_t r_coronas_occlusionquery = {CVAR_SAVE, "r_coronas_occlusionquery", "1", "use GL_ARB_occlusion_query extension if supported (fades coronas according to visibility)"};
@@ -379,61 +379,70 @@ void R_Shadow_SetShadowMode(void)
        r_shadow_shadowmapsampler = false;
        r_shadow_shadowmappcf = 0;
        r_shadow_shadowmode = R_SHADOW_SHADOWMODE_STENCIL;
-       if(r_shadow_shadowmapping.integer && r_glsl.integer && vid.support.arb_fragment_shader && vid.support.ext_framebuffer_object)
+       switch(vid.renderpath)
        {
-               if(r_shadow_shadowmapfilterquality < 0)
+       case RENDERPATH_GL20:
+               if(r_shadow_shadowmapping.integer && vid.support.ext_framebuffer_object)
                {
-                       if(strstr(gl_vendor, "NVIDIA")) 
+                       if(r_shadow_shadowmapfilterquality < 0)
                        {
-                               r_shadow_shadowmapsampler = vid.support.arb_shadow;
-                               r_shadow_shadowmappcf = 1;
+                               if(strstr(gl_vendor, "NVIDIA")) 
+                               {
+                                       r_shadow_shadowmapsampler = vid.support.arb_shadow;
+                                       r_shadow_shadowmappcf = 1;
+                               }
+                               else if(vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) 
+                                       r_shadow_shadowmappcf = 1;
+                               else if(strstr(gl_vendor, "ATI")) 
+                                       r_shadow_shadowmappcf = 1;
+                               else 
+                                       r_shadow_shadowmapsampler = vid.support.arb_shadow;
                        }
-                       else if(vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) 
-                               r_shadow_shadowmappcf = 1;
-                       else if(strstr(gl_vendor, "ATI")) 
-                               r_shadow_shadowmappcf = 1;
                        else 
-                               r_shadow_shadowmapsampler = vid.support.arb_shadow;
-               }
-               else 
-               {
-                       switch (r_shadow_shadowmapfilterquality)
                        {
+                               switch (r_shadow_shadowmapfilterquality)
+                               {
+                               case 1:
+                                       r_shadow_shadowmapsampler = vid.support.arb_shadow;
+                                       break;
+                               case 2:
+                                       r_shadow_shadowmapsampler = vid.support.arb_shadow;
+                                       r_shadow_shadowmappcf = 1;
+                                       break;
+                               case 3:
+                                       r_shadow_shadowmappcf = 1;
+                                       break;
+                               case 4:
+                                       r_shadow_shadowmappcf = 2;
+                                       break;
+                               }
+                       }
+                       switch (r_shadow_shadowmaptexturetype)
+                       {
+                       case 0:
+                               r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D;
+                               break;
                        case 1:
-                               r_shadow_shadowmapsampler = vid.support.arb_shadow;
+                               r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE;
                                break;
                        case 2:
-                               r_shadow_shadowmapsampler = vid.support.arb_shadow;
-                               r_shadow_shadowmappcf = 1;
+                               r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE;
                                break;
-                       case 3:
-                               r_shadow_shadowmappcf = 1;
-                               break;
-                       case 4:
-                               r_shadow_shadowmappcf = 2;
+                       default:
+                               if((vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) && r_shadow_shadowmappcf && !r_shadow_shadowmapsampler)
+                                       r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D;
+                               else if(vid.support.arb_texture_rectangle) 
+                                       r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE;
+                               else
+                                       r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D;
                                break;
                        }
                }
-               switch (r_shadow_shadowmaptexturetype)
-               {
-               case 0:
-                       r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D;
-                       break;
-               case 1:
-                       r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE;
-                       break;
-               case 2:
-                       r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE;
-                       break;
-               default:
-                       if((vid.support.amd_texture_texture4 || vid.support.arb_texture_gather) && r_shadow_shadowmappcf && !r_shadow_shadowmapsampler)
-                               r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D;
-                       else if(vid.support.arb_texture_rectangle) 
-                               r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE;
-                       else
-                               r_shadow_shadowmode = R_SHADOW_SHADOWMODE_SHADOWMAP2D;
-                       break;
-               }
+               break;
+       case RENDERPATH_GL13:
+               break;
+       case RENDERPATH_GL11:
+               break;
        }
 }
 
@@ -1865,12 +1874,21 @@ void R_Shadow_RenderMode_Begin(void)
                r_shadow_shadowingrendermode_zfail = R_SHADOW_RENDERMODE_ZFAIL_STENCIL;
        }
 
-       if (r_glsl.integer && vid.support.arb_fragment_shader)
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL20:
                r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_LIGHT_GLSL;
-       else if (vid.support.arb_texture_env_dot3 && vid.support.arb_texture_cube_map && r_shadow_dot3.integer && vid.stencil)
-               r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_LIGHT_DOT3;
-       else
+               break;
+       case RENDERPATH_GL13:
+               if (vid.support.arb_texture_env_dot3 && vid.support.arb_texture_cube_map && r_shadow_dot3.integer && vid.stencil)
+                       r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_LIGHT_DOT3;
+               else
+                       r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_LIGHT_VERTEX;
+               break;
+       case RENDERPATH_GL11:
                r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_LIGHT_VERTEX;
+               break;
+       }
 
        CHECKGLERROR
 #if 0
@@ -2683,7 +2701,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
        //
        // Limit mult to 64 for sanity sake.
        GL_Color(1,1,1,1);
-       if (r_shadow_texture3d.integer && rsurface.rtlight->currentcubemap != r_texture_whitecube && r_textureunits.integer >= 4)
+       if (r_shadow_texture3d.integer && rsurface.rtlight->currentcubemap != r_texture_whitecube && r_textureunits.integer >= 4 && vid.texunits >= 4)
        {
                // 3 3D combine path (Geforce3, Radeon 8500)
                memset(&m, 0, sizeof(m));
@@ -2704,7 +2722,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                m.texmatrix[2] = rsurface.entitytolight;
                GL_BlendFunc(GL_ONE, GL_ONE);
        }
-       else if (r_shadow_texture3d.integer && rsurface.rtlight->currentcubemap == r_texture_whitecube && r_textureunits.integer >= 2)
+       else if (r_shadow_texture3d.integer && rsurface.rtlight->currentcubemap == r_texture_whitecube && r_textureunits.integer >= 2 && vid.texunits >= 2)
        {
                // 2 3D combine path (Geforce3, original Radeon)
                memset(&m, 0, sizeof(m));
@@ -2720,7 +2738,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                m.texmatrix[1] = rsurface.texture->currenttexmatrix;
                GL_BlendFunc(GL_ONE, GL_ONE);
        }
-       else if (r_textureunits.integer >= 4 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
+       else if (r_textureunits.integer >= 4 && vid.texunits >= 4 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
        {
                // 4 2D combine path (Geforce3, Radeon 8500)
                memset(&m, 0, sizeof(m));
@@ -2749,7 +2767,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                }
                GL_BlendFunc(GL_ONE, GL_ONE);
        }
-       else if (r_textureunits.integer >= 3 && rsurface.rtlight->currentcubemap == r_texture_whitecube)
+       else if (r_textureunits.integer >= 3 && vid.texunits >= 3 && rsurface.rtlight->currentcubemap == r_texture_whitecube)
        {
                // 3 2D combine path (Geforce3, original Radeon)
                memset(&m, 0, sizeof(m));
@@ -2824,7 +2842,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
        GL_Color(1,1,1,1);
        // generate normalization cubemap texcoords
        R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(firstvertex, numvertices, numtriangles, element3i);
-       if (r_shadow_texture3d.integer && r_textureunits.integer >= 4)
+       if (r_shadow_texture3d.integer && r_textureunits.integer >= 4 && vid.texunits >= 4)
        {
                // 3/2 3D combine path (Geforce3, Radeon 8500)
                memset(&m, 0, sizeof(m));
@@ -2866,7 +2884,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                }
                GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
        }
-       else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
+       else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && vid.texunits >= 2 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
        {
                // 1/2/2 3D combine path (original Radeon)
                memset(&m, 0, sizeof(m));
@@ -2914,7 +2932,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                }
                GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
        }
-       else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap == r_texture_whitecube)
+       else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && vid.texunits >= 2 && rsurface.rtlight->currentcubemap == r_texture_whitecube)
        {
                // 2/2 3D combine path (original Radeon)
                memset(&m, 0, sizeof(m));
@@ -2948,7 +2966,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                m.texmatrix[1] = rsurface.entitytoattenuationxyz;
                GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
        }
-       else if (r_textureunits.integer >= 4)
+       else if (r_textureunits.integer >= 4 && vid.texunits >= 4)
        {
                // 4/2 2D combine path (Geforce3, Radeon 8500)
                memset(&m, 0, sizeof(m));
@@ -3063,7 +3081,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
        GL_Color(1,1,1,1);
        // generate normalization cubemap texcoords
        R_Shadow_GenTexCoords_Specular_NormalCubeMap(firstvertex, numvertices, numtriangles, element3i);
-       if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
+       if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && vid.texunits >= 2 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
        {
                // 2/0/0/1/2 3D combine blendsquare path
                memset(&m, 0, sizeof(m));
@@ -3118,7 +3136,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                }
                GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
        }
-       else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap == r_texture_whitecube /* && gl_support_blendsquare*/) // FIXME: detect blendsquare!
+       else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && vid.texunits >= 2 && rsurface.rtlight->currentcubemap == r_texture_whitecube /* && gl_support_blendsquare*/) // FIXME: detect blendsquare!
        {
                // 2/0/0/2 3D combine blendsquare path
                memset(&m, 0, sizeof(m));
index 2bbcc6a..fd40404 100644 (file)
--- a/render.h
+++ b/render.h
@@ -167,8 +167,6 @@ extern cvar_t r_renderview;
 extern cvar_t r_waterwarp;
 
 extern cvar_t r_textureunits;
-extern cvar_t gl_combine;
-extern cvar_t r_glsl;
 
 extern cvar_t r_glsl_offsetmapping;
 extern cvar_t r_glsl_offsetmapping_reliefmapping;
index 8a95e1a..4670080 100644 (file)
@@ -797,6 +797,7 @@ void VID_CheckExtensions(void)
        vid.support.arb_texture_compression = GL_CheckExtension("GL_ARB_texture_compression", texturecompressionfuncs, "-notexturecompression", false);
        vid.support.arb_texture_cube_map = GL_CheckExtension("GL_ARB_texture_cube_map", NULL, "-nocubemap", false);
        vid.support.arb_texture_env_combine = GL_CheckExtension("GL_ARB_texture_env_combine", NULL, "-nocombine", false) || GL_CheckExtension("GL_EXT_texture_env_combine", NULL, "-nocombine", false);
+       vid.support.arb_texture_env_dot3 = GL_CheckExtension("GL_ARB_texture_env_dot3", NULL, "-nodot3", false);
        vid.support.arb_texture_gather = GL_CheckExtension("GL_ARB_texture_gather", NULL, "-notexturegather", false);
        vid.support.arb_texture_non_power_of_two = GL_CheckExtension("GL_ARB_texture_non_power_of_two", NULL, "-notexturenonpoweroftwo", false);
        vid.support.arb_texture_rectangle = GL_CheckExtension("GL_ARB_texture_rectangle", NULL, "-norectangle", false);
@@ -821,6 +822,7 @@ void VID_CheckExtensions(void)
 // COMMANDLINEOPTION: GL: -nocubemap disables GL_ARB_texture_cube_map (required for bumpmapping)
 // COMMANDLINEOPTION: GL: -nocva disables GL_EXT_compiled_vertex_array (renders faster)
 // COMMANDLINEOPTION: GL: -nodepthtexture disables use of GL_ARB_depth_texture (required for shadowmapping)
+// COMMANDLINEOPTION: GL: -nodot3 disables use of GL_ARB_texture_env_dot3
 // COMMANDLINEOPTION: GL: -nodrawrangeelements disables GL_EXT_draw_range_elements (renders faster)
 // COMMANDLINEOPTION: GL: -noedgeclamp disables GL_EXT_texture_edge_clamp or GL_SGIS_texture_edge_clamp (recommended, some cards do not support the other texture clamp method)
 // COMMANDLINEOPTION: GL: -nofbo disables GL_EXT_framebuffer_object (which accelerates rendering), only used if GL_ARB_fragment_shader is also available
@@ -882,7 +884,9 @@ void VID_CheckExtensions(void)
        }
 
        vid.texunits = vid.teximageunits = vid.texarrayunits = 1;
-       if (vid.support.arb_fragment_shader && vid_gl20.integer)
+       if (vid.support.arb_multitexture)
+               qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&vid.texunits);
+       if (vid_gl20.integer && vid.support.arb_fragment_shader && vid.support.arb_vertex_shader && vid.support.arb_shader_objects)
        {
                qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&vid.texunits);
                qglGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, (int *)&vid.teximageunits);CHECKGLERROR
@@ -904,8 +908,6 @@ void VID_CheckExtensions(void)
        }
        else
        {
-               if (vid.support.arb_multitexture)
-                       qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&vid.texunits);
                vid.texunits = bound(1, vid.texunits, MAX_TEXTUREUNITS);
                vid.teximageunits = vid.texunits;
                vid.texarrayunits = vid.texunits;
@@ -999,8 +1001,16 @@ void VID_UpdateGamma(qboolean force, int rampsize)
                return;
 
        wantgamma = v_hwgamma.integer;
-       if(r_glsl.integer && v_glslgamma.integer)
-               wantgamma = 0;
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL20:
+               if (v_glslgamma.integer)
+                       wantgamma = 0;
+               break;
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               break;
+       }
        if(!vid_activewindow)
                wantgamma = 0;
 #define BOUNDCVAR(cvar, m1, m2) c = &(cvar);f = bound(m1, c->value, m2);if (c->value != f) Cvar_SetValueQuick(c, f);