From ce7af50b2021e374ca73c8678dc7e320d42df2d9 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 14 May 2007 14:34:53 +0000 Subject: [PATCH] added a proper gl_lightmaps rendering path, previously the gl_lightmaps option did not work with r_glsl 1 and affected sprites (which it was not meant to) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7280 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 26783594..bfb11c60 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -3223,9 +3223,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) t->currentnumlayers = 0; if (!(t->currentmaterialflags & MATERIALFLAG_NODRAW)) { - if (gl_lightmaps.integer) - R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE, r_texture_white, &identitymatrix, 1, 1, 1, 1); - else if (!(t->currentmaterialflags & MATERIALFLAG_SKY)) + if (!(t->currentmaterialflags & MATERIALFLAG_SKY)) { int blendfunc1, blendfunc2, depthmask; if (t->currentmaterialflags & MATERIALFLAG_ADD) @@ -4473,6 +4471,34 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur R_DrawTextureSurfaceList_ShowSurfaces(texturenumsurfaces, texturesurfacelist); r_refdef.stats.entities_surfaces += texturenumsurfaces; } + else if (gl_lightmaps.integer) + { + rmeshstate_t m; + if (rsurface_mode != RSURFMODE_MULTIPASS) + rsurface_mode = RSURFMODE_MULTIPASS; + GL_DepthRange(0, (rsurface_texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1); + GL_DepthTest(true); + GL_CullFace((rsurface_texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces + GL_BlendFunc(GL_ONE, GL_ZERO); + GL_DepthMask(writedepth); + GL_Color(1,1,1,1); + GL_AlphaTest(false); + R_Mesh_ColorPointer(NULL, 0, 0); + memset(&m, 0, sizeof(m)); + m.tex[0] = R_GetTexture(r_texture_white); + m.pointer_texcoord[0] = rsurface_model->surfmesh.data_texcoordlightmap2f; + m.pointer_texcoord_bufferobject[0] = rsurface_model->surfmesh.vbo; + m.pointer_texcoord_bufferoffset[0] = rsurface_model->surfmesh.vbooffset_texcoordlightmap2f; + R_Mesh_TextureState(&m); + RSurf_PrepareVerticesForBatch(rsurface_lightmode == 2, false, texturenumsurfaces, texturesurfacelist); + if (rsurface_lightmode == 2) + RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false); + else if (rsurface_uselightmaptexture) + RSurf_DrawBatch_GL11_Lightmap(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false); + else + RSurf_DrawBatch_GL11_VertexColor(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false); + r_refdef.stats.entities_surfaces += texturenumsurfaces; + } else if (rsurface_texture->currentmaterialflags & MATERIALFLAG_SKY) { R_DrawTextureSurfaceList_Sky(texturenumsurfaces, texturesurfacelist); -- 2.39.2