Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GL_BuildLightmaps (void)
- {
- char name[24];
- int i, j;
- struct lightmap_s *lm;
- qmodel_t *m;
- r_framecount = 1; // no dlightcache
- //Spike -- wipe out all the lightmap data (johnfitz -- the gltexture objects were already freed by Mod_ClearAll)
- for (i=0; i < lightmap_count; i++)
- free(lightmap[i].data);
- free(lightmap);
- lightmap = NULL;
- last_lightmap_allocated = 0;
- lightmap_count = 0;
- gl_lightmap_format = GL_RGBA;//FIXME: hardcoded for now!
- switch (gl_lightmap_format)
- {
- case GL_RGBA:
- lightmap_bytes = 4;
- break;
- case GL_BGRA:
- lightmap_bytes = 4;
- break;
- default:
- Sys_Error ("GL_BuildLightmaps: bad lightmap format");
- }
- for (j=1 ; j<MAX_MODELS ; j++)
- {
- m = cl.model_precache[j];
- if (!m)
- break;
- if (m->name[0] == '*')
- continue;
- r_pcurrentvertbase = m->vertexes;
- currentmodel = m;
- for (i=0 ; i<m->numsurfaces ; i++)
- {
- //johnfitz -- rewritten to use SURF_DRAWTILED instead of the sky/water flags
- //^ Lol
- if (m->surfaces[i].flags & SURF_DRAWSKY)
- continue;
- GL_CreateSurfaceLightmap(m->surfaces + i);
- BuildSurfaceDisplayList (m->surfaces + i);
- if (m->surfaces[i].flags & SURF_DRAWTILED)
- GL_SubdivideSurface(m->surfaces + i);
- //johnfitz
- }
- }
- //
- // upload all lightmaps that were filled
- //
- for (i=0; i<lightmap_count; i++)
- {
- lm = &lightmap[i];
- lm->modified = false;
- lm->rectchange.l = LMBLOCK_WIDTH;
- lm->rectchange.t = LMBLOCK_HEIGHT;
- lm->rectchange.w = 0;
- lm->rectchange.h = 0;
- //johnfitz -- use texture manager
- sprintf(name, "lightmap%07i",i);
- lm->texture = TexMgr_LoadImage (cl.worldmodel, name, LMBLOCK_WIDTH, LMBLOCK_HEIGHT,
- SRC_LIGHTMAP, lm->data, "", (src_offset_t)lm->data, TEXPREF_LINEAR | TEXPREF_NOPICMIP);
- //johnfitz
- }
- //johnfitz -- warn about exceeding old limits
- //GLQuake limit was 64 textures of 128x128. Estimate how many 128x128 textures we would need
- //given that we are using lightmap_count of LMBLOCK_WIDTH x LMBLOCK_HEIGHT
- i = lightmap_count * ((LMBLOCK_WIDTH / 128) * (LMBLOCK_HEIGHT / 128));
- if (i > 64)
- Con_DWarning("%i lightmaps exceeds standard limit of 64.\n",i);
- //johnfitz
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement