- // transparent sky would be ridiculous
- if (!(rsurface_texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
- {
- if (rsurface_mode != RSURFMODE_SKY)
- {
- if (rsurface_mode == RSURFMODE_GLSL)
- {
- qglUseProgramObjectARB(0);CHECKGLERROR
- }
- rsurface_mode = RSURFMODE_SKY;
- if (skyrendernow)
- {
- skyrendernow = false;
- R_Sky();
- // restore entity matrix
- R_Mesh_Matrix(&rsurface_entity->matrix);
- }
- GL_DepthMask(true);
- // LordHavoc: HalfLife maps have freaky skypolys so don't use
- // skymasking on them, and Quake3 never did sky masking (unlike
- // software Quake and software Quake2), so disable the sky masking
- // in Quake3 maps as it causes problems with q3map2 sky tricks,
- // and skymasking also looks very bad when noclipping outside the
- // level, so don't use it then either.
- if (rsurface_model->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_worldnovis)
- {
- GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], 1);
- R_Mesh_ColorPointer(NULL);
- R_Mesh_ResetTextureState();
- if (skyrendermasked)
- {
- // depth-only (masking)
- GL_ColorMask(0,0,0,0);
- // just to make sure that braindead drivers don't draw
- // anything despite that colormask...
- GL_BlendFunc(GL_ZERO, GL_ONE);
- }
- else
- {
- // fog sky
- GL_BlendFunc(GL_ONE, GL_ZERO);
- }
- }
- }
- // LordHavoc: HalfLife maps have freaky skypolys so don't use
- // skymasking on them, and Quake3 never did sky masking (unlike
- // software Quake and software Quake2), so disable the sky masking
- // in Quake3 maps as it causes problems with q3map2 sky tricks,
- // and skymasking also looks very bad when noclipping outside the
- // level, so don't use it then either.
- if (rsurface_model->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_worldnovis)
- {
- RSurf_PrepareVerticesForBatch(false, false, texturenumsurfaces, texturesurfacelist);
- RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
- if (skyrendermasked)
- GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
- }
- }
+ rsurface_mode = RSURFMODE_GLSL;
+ rsurface_glsl_texture = NULL;
+ rsurface_glsl_uselightmap = false;
+ R_Mesh_ResetTextureState();
+ }
+ if (rsurface_glsl_texture != rsurface_texture || rsurface_glsl_uselightmap != (rsurface_lightmaptexture != NULL))
+ {
+ rsurface_glsl_texture = rsurface_texture;
+ rsurface_glsl_uselightmap = rsurface_lightmaptexture != NULL;
+ GL_BlendFunc(rsurface_texture->currentlayers[0].blendfunc1, rsurface_texture->currentlayers[0].blendfunc2);
+ GL_DepthMask(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_BLENDED));
+ GL_Color(rsurface_entity->colormod[0], rsurface_entity->colormod[1], rsurface_entity->colormod[2], rsurface_texture->currentalpha);
+ R_SetupSurfaceShader(vec3_origin, lightmode == 2);
+ //permutation_deluxemapping = permutation_lightmapping = R_SetupSurfaceShader(vec3_origin, lightmode == 2, false);
+ //if (r_glsl_deluxemapping.integer)
+ // permutation_deluxemapping = R_SetupSurfaceShader(vec3_origin, lightmode == 2, true);
+ R_Mesh_TexCoordPointer(0, 2, rsurface_model->surfmesh.data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(4, 2, rsurface_model->surfmesh.data_texcoordlightmap2f);
+ GL_AlphaTest((rsurface_texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);
+ }
+ if (!r_glsl_permutation)
+ return;
+ RSurf_PrepareVerticesForBatch(true, true, texturenumsurfaces, texturesurfacelist);
+ R_Mesh_TexCoordPointer(1, 3, rsurface_svector3f);
+ R_Mesh_TexCoordPointer(2, 3, rsurface_tvector3f);
+ R_Mesh_TexCoordPointer(3, 3, rsurface_normal3f);
+ if (rsurface_texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)
+ {
+ R_Mesh_TexBind(7, R_GetTexture(r_texture_white));
+ if (r_glsl_permutation->loc_Texture_Deluxemap >= 0)
+ R_Mesh_TexBind(8, R_GetTexture(r_texture_blanknormalmap));
+ R_Mesh_ColorPointer(NULL);