- memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
- return;
- }
- // anything else is a typical wall, lightmap * texture + glow
- dolightmap = (ent->flags & RENDER_LIGHT);
- dobase = true;
- doambient = r_ambient.value > 0;
- doglow = t->skin.glow != NULL;
- dofog = fogenabled;
- if (t->textureflags & Q3TEXTUREFLAG_TWOSIDED)
- qglDisable(GL_CULL_FACE);
- if (!dolightmap && dobase)
- {
- dolightmap = false;
- dobase = false;
- GL_DepthMask(true);
- GL_DepthTest(true);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_Color(ent->colormod[0], ent->colormod[1], ent->colormod[2], 1);
- if (t->textureflags & Q3TEXTUREFLAG_TWOSIDED)
- qglDisable(GL_CULL_FACE);
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(t->skin.base);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- if (r_lightmapintensity <= 0 && dolightmap && dobase)
- {
- dolightmap = false;
- dobase = false;
- GL_DepthMask(true);
- GL_DepthTest(true);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_Color(0, 0, 0, 1);
- memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- if (r_textureunits.integer >= 2 && gl_combine.integer && dolightmap && dobase)
- {
- // dualtexture combine
- dolightmap = false;
- dobase = false;
- GL_DepthMask(true);
- GL_DepthTest(true);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(t->skin.base);
- GL_Color(r_lightmapintensity * ent->colormod[0], r_lightmapintensity * ent->colormod[1], r_lightmapintensity * ent->colormod[2], 1);
- m.pointer_color = NULL;
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- if (!face->lightmaptexture)
- continue;
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
- m.texrgbscale[1] = 2;
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- if (r_lightmapintensity == 1 && ent->colormod[0] == 1 && ent->colormod[1] == 1 && ent->colormod[2] == 1)
- {
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- if (face->lightmaptexture)
- continue;
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
- m.texrgbscale[1] = 2;
- m.pointer_color = face->mesh.data_lightmapcolor4f;
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- else
- {
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- if (face->lightmaptexture)
- continue;
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
- m.texrgbscale[1] = 2;
- m.pointer_color = varray_color4f;
- for (i = 0;i < face->mesh.num_vertices;i++)
- {
- varray_color4f[i*4+0] = face->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0] * r_lightmapintensity;
- varray_color4f[i*4+1] = face->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1] * r_lightmapintensity;
- varray_color4f[i*4+2] = face->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2] * r_lightmapintensity;
- varray_color4f[i*4+3] = face->mesh.data_lightmapcolor4f[i*4+3];
- }
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- }
- // single texture
- if (dolightmap)
- {
- GL_DepthMask(true);
- GL_DepthTest(true);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.tex[0] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordlightmap2f;
- if (face->lightmaptexture)
- m.pointer_color = NULL;
- else
- m.pointer_color = face->mesh.data_lightmapcolor4f;
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- if (dobase)
- {
- GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
- GL_DepthMask(false);
- GL_DepthTest(true);
- GL_Color(r_lightmapintensity * ent->colormod[0], r_lightmapintensity * ent->colormod[1], r_lightmapintensity * ent->colormod[2], 1);
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(t->skin.base);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- if (doambient)
- {
- GL_BlendFunc(GL_ONE, GL_ONE);
- GL_DepthMask(false);
- GL_DepthTest(true);
- GL_Color(r_ambient.value * (1.0f / 128.0f) * ent->colormod[0], r_ambient.value * (1.0f / 128.0f) * ent->colormod[1], r_ambient.value * (1.0f / 128.0f) * ent->colormod[2], 1);
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(t->skin.base);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
- {
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
- R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
- GL_LockArrays(0, 0);
- }
- }
- if (doglow)