diff --git a/Quake/gl_sky.c b/Quake/gl_sky.c index 273b8d25..3aa5d5f7 100644 --- a/Quake/gl_sky.c +++ b/Quake/gl_sky.c @@ -903,7 +903,7 @@ void Sky_DrawFace (int axis) vec3_t verts[4]; int i, j, start; float di,qi,dj,qj; - vec3_t vup, vright, temp, temp2; + vec3_t up, right, temp, temp2; Sky_SetBoxVert(-1.0, -1.0, axis, verts[0]); Sky_SetBoxVert(-1.0, 1.0, axis, verts[1]); @@ -913,8 +913,8 @@ void Sky_DrawFace (int axis) start = Hunk_LowMark (); p = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t)); - VectorSubtract(verts[2],verts[3],vup); - VectorSubtract(verts[2],verts[1],vright); + VectorSubtract(verts[2],verts[3],up); + VectorSubtract(verts[2],verts[1],right); di = q_max((int)r_sky_quality.value, 1); qi = 1.0 / di; @@ -930,15 +930,15 @@ void Sky_DrawFace (int axis) continue; //if (i&1 ^ j&1) continue; //checkerboard test - VectorScale (vright, qi*i, temp); - VectorScale (vup, qj*j, temp2); + VectorScale (right, qi*i, temp); + VectorScale (up, qj*j, temp2); VectorAdd(temp,temp2,temp); VectorAdd(verts[0],temp,p->verts[0]); - VectorScale (vup, qj, temp); + VectorScale (up, qj, temp); VectorAdd (p->verts[0],temp,p->verts[1]); - VectorScale (vright, qi, temp); + VectorScale (right, qi, temp); VectorAdd (p->verts[1],temp,p->verts[2]); VectorAdd (p->verts[0],temp,p->verts[3]); diff --git a/Quake/gl_texmgr.c b/Quake/gl_texmgr.c index 188907d9..f9700a00 100644 --- a/Quake/gl_texmgr.c +++ b/Quake/gl_texmgr.c @@ -1282,34 +1282,32 @@ void TexMgr_ReloadImage (gltexture_t *glt, int shirt, int pants) // mark = Hunk_LowMark (); - if (glt->source_file[0] && glt->source_offset) - { + if (glt->source_file[0] && glt->source_offset) { //lump inside file - long size; FILE *f; COM_FOpenFile(glt->source_file, &f, NULL); - if (!f) - goto invalid; + if (!f) goto invalid; fseek (f, glt->source_offset, SEEK_CUR); - size = (long) (glt->source_width * glt->source_height); + size = glt->source_width * glt->source_height; /* should be SRC_INDEXED, but no harm being paranoid: */ - if (glt->source_format == SRC_RGBA) + if (glt->source_format == SRC_RGBA) { size *= 4; - else if (glt->source_format == SRC_LIGHTMAP) + } + else if (glt->source_format == SRC_LIGHTMAP) { size *= lightmap_bytes; + } data = (byte *) Hunk_Alloc (size); fread (data, 1, size, f); fclose (f); } - else if (glt->source_file[0] && !glt->source_offset) + else if (glt->source_file[0] && !glt->source_offset) { data = Image_LoadImage (glt->source_file, (int *)&glt->source_width, (int *)&glt->source_height); //simple file - else if (!glt->source_file[0] && glt->source_offset) + } + else if (!glt->source_file[0] && glt->source_offset) { data = (byte *) glt->source_offset; //image in memory - - if (!data) - { -invalid: - Con_Printf ("TexMgr_ReloadImage: invalid source for %s\n", glt->name); + } + if (!data) { +invalid: Con_Printf ("TexMgr_ReloadImage: invalid source for %s\n", glt->name); Hunk_FreeToLowMark(mark); return; } diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 8ae59564..c9263352 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -661,10 +661,9 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb /* Make window fullscreen if needed, and show the window */ if (fullscreen) { - Uint32 flags = vid_desktopfullscreen.value ? - SDL_WINDOW_FULLSCREEN_DESKTOP : - SDL_WINDOW_FULLSCREEN; - if (SDL_SetWindowFullscreen (draw_context, flags) != 0) + const Uint32 flag = vid_desktopfullscreen.value ? + SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN; + if (SDL_SetWindowFullscreen (draw_context, flag) != 0) Sys_Error ("Couldn't set fullscreen state mode"); } diff --git a/Quake/glquake.h b/Quake/glquake.h index 315be98b..474e72cd 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -310,7 +310,7 @@ struct lightmap_s // main memory so texsubimage can update properly byte *data;//[4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT]; }; -extern struct lightmap_s *lightmap; +extern struct lightmap_s *lightmaps; extern int lightmap_count; //allocated lightmaps extern int gl_warpimagesize; //johnfitz -- for water warp diff --git a/Quake/r_brush.c b/Quake/r_brush.c index 14999089..ec3dc572 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -31,7 +31,7 @@ int gl_lightmap_format; int lightmap_bytes; #define MAX_SANITY_LIGHTMAPS (1u<<20) -struct lightmap_s *lightmap; +struct lightmap_s *lightmaps; int lightmap_count; int last_lightmap_allocated; int allocated[LMBLOCK_WIDTH]; @@ -663,8 +663,8 @@ void R_RenderDynamicLightmaps (msurface_t *fa) return; // add to lightmap chain - fa->polys->chain = lightmap[fa->lightmaptexturenum].polys; - lightmap[fa->lightmaptexturenum].polys = fa->polys; + fa->polys->chain = lightmaps[fa->lightmaptexturenum].polys; + lightmaps[fa->lightmaptexturenum].polys = fa->polys; // check for lightmap modification for (maps=0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++) @@ -677,7 +677,7 @@ void R_RenderDynamicLightmaps (msurface_t *fa) dynamic: if (r_dynamic.value) { - struct lightmap_s *lm = &lightmap[fa->lightmaptexturenum]; + struct lightmap_s *lm = &lightmaps[fa->lightmaptexturenum]; lm->modified = true; theRect = &lm->rectchange; if (fa->light_t < theRect->t) { @@ -724,11 +724,11 @@ int AllocBlock (int w, int h, int *x, int *y) if (texnum == lightmap_count) { lightmap_count++; - lightmap = (struct lightmap_s *) realloc(lightmap, sizeof(*lightmap)*lightmap_count); - memset(&lightmap[texnum], 0, sizeof(lightmap[texnum])); + lightmaps = (struct lightmap_s *) realloc(lightmaps, sizeof(*lightmaps)*lightmap_count); + memset(&lightmaps[texnum], 0, sizeof(lightmaps[texnum])); /* FIXME: we leave 'gaps' in malloc()ed data, CRC_Block() later accesses * that uninitialized data and valgrind complains for it. use calloc() ? */ - lightmap[texnum].data = (byte *) malloc(4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT); + lightmaps[texnum].data = (byte *) malloc(4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT); //as we're only tracking one texture, we don't need multiple copies of allocated any more. memset(allocated, 0, sizeof(allocated)); } @@ -786,7 +786,7 @@ void GL_CreateSurfaceLightmap (msurface_t *surf) tmax = (surf->extents[1]>>4)+1; surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t); - base = lightmap[surf->lightmaptexturenum].data; + base = lightmaps[surf->lightmaptexturenum].data; base += (surf->light_t * LMBLOCK_WIDTH + surf->light_s) * lightmap_bytes; R_BuildLightMap (surf, base, LMBLOCK_WIDTH*lightmap_bytes); } @@ -883,9 +883,9 @@ void GL_BuildLightmaps (void) //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; + free(lightmaps[i].data); + free(lightmaps); + lightmaps = NULL; last_lightmap_allocated = 0; lightmap_count = 0; @@ -928,7 +928,7 @@ void GL_BuildLightmaps (void) // for (i=0; imodified = false; lm->rectchange.l = LMBLOCK_WIDTH; lm->rectchange.t = LMBLOCK_HEIGHT; @@ -1252,7 +1252,7 @@ assumes lightmap texture is already bound */ static void R_UploadLightmap(int lmap) { - struct lightmap_s *lm = &lightmap[lmap]; + struct lightmap_s *lm = &lightmaps[lmap]; if (!lm->modified) return; @@ -1275,10 +1275,10 @@ void R_UploadLightmaps (void) for (lmap = 0; lmap < lightmap_count; lmap++) { - if (!lightmap[lmap].modified) + if (!lightmaps[lmap].modified) continue; - GL_Bind (lightmap[lmap].texture); + GL_Bind (lightmaps[lmap].texture); R_UploadLightmap(lmap); } } @@ -1308,7 +1308,7 @@ void R_RebuildAllLightmaps (void) { if (fa->flags & SURF_DRAWTILED) continue; - base = lightmap[fa->lightmaptexturenum].data; + base = lightmaps[fa->lightmaptexturenum].data; base += fa->light_t * LMBLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes; R_BuildLightMap (fa, base, LMBLOCK_WIDTH*lightmap_bytes); } @@ -1317,8 +1317,8 @@ void R_RebuildAllLightmaps (void) //for each lightmap, upload it for (i=0; inumtextures ; i++) if (mod->textures[i]) mod->textures[i]->texturechains[chain] = NULL; - + // clear lightmap chains for (i=0 ; itextures[i]->texturechains[chain_world] = NULL; // rebuild chains - #if 1 //iterate through surfaces one node at a time to rebuild chains //need to do it this way if we want to work with tyrann's skip removal tool @@ -249,7 +248,7 @@ void R_BuildLightmapChains (qmodel_t *model, texchain_t chain) // clear lightmap chains (already done in r_marksurfaces, but clearing them here to be safe becuase of r_stereo) for (i=0 ; inumtextures ; i++) @@ -497,10 +496,10 @@ static void R_BatchSurface (msurface_t *s) int num_surf_indices; num_surf_indices = R_NumTriangleIndicesForSurf (s); - + if (num_vbo_indices + num_surf_indices > MAX_BATCH_SIZE) R_FlushBatch(); - + R_TriangleIndicesForSurf (s, &vbo_indices[num_vbo_indices]); num_vbo_indices += num_surf_indices; } @@ -539,7 +538,7 @@ void R_DrawTextureChains_Multitexture (qmodel_t *model, entity_t *ent, texchain_ GL_EnableMultitexture(); // selects TEXTURE1 bound = true; } - GL_Bind (lightmap[s->lightmaptexturenum].texture); + GL_Bind (lightmaps[s->lightmaptexturenum].texture); glBegin(GL_POLYGON); v = s->polys->verts[0]; for (j=0 ; jpolys->numverts ; j++, v+= VERTEXSIZE) @@ -777,11 +776,11 @@ void R_DrawLightmapChains (void) for (i=0 ; ichain) + GL_Bind (lightmaps[i].texture); + for (p = lightmaps[i].polys; p; p=p->chain) { glBegin (GL_POLYGON); v = p->verts[0]; @@ -878,10 +877,10 @@ void GLWorld_CreateShaders (void) " result.a = Alpha;\n" // FIXME: This will make almost transparent things cut holes though heavy fog " gl_FragColor = result;\n" "}\n"; - + if (!gl_glsl_alias_able) return; - + r_world_program = GL_CreateProgram (vertSource, fragSource, sizeof(bindings)/sizeof(bindings[0]), bindings); if (r_world_program != 0) @@ -916,7 +915,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) int lastlightmap; gltexture_t *fullbright = NULL; float entalpha; - + entalpha = (ent != NULL) ? ENTALPHA_DECODE(ent->alpha) : 1.0f; // enable blending / disable depth writes @@ -925,9 +924,9 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) glDepthMask (GL_FALSE); glEnable (GL_BLEND); } - + GL_UseProgramFunc (r_world_program); - + // Bind the buffers GL_BindBuffer (GL_ARRAY_BUFFER, gl_bmodel_vbo); GL_BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); // indices come from client memory! @@ -935,11 +934,11 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) GL_EnableVertexAttribArrayFunc (vertAttrIndex); GL_EnableVertexAttribArrayFunc (texCoordsAttrIndex); GL_EnableVertexAttribArrayFunc (LMCoordsAttrIndex); - + GL_VertexAttribPointerFunc (vertAttrIndex, 3, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0)); GL_VertexAttribPointerFunc (texCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0) + 3); GL_VertexAttribPointerFunc (LMCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0) + 5); - + // set uniforms GL_Uniform1iFunc (texLoc, 0); GL_Uniform1iFunc (LMTexLoc, 1); @@ -948,7 +947,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) GL_Uniform1iFunc (useOverbrightLoc, (int)gl_overbright.value); GL_Uniform1iFunc (useAlphaTestLoc, 0); GL_Uniform1fFunc (alphaLoc, entalpha); - + for (i=0 ; inumtextures ; i++) { t = model->textures[i]; @@ -990,7 +989,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) R_FlushBatch (); GL_SelectTexture (GL_TEXTURE1); - GL_Bind (lightmap[s->lightmaptexturenum].texture); + GL_Bind (lightmaps[s->lightmaptexturenum].texture); lastlightmap = s->lightmaptexturenum; R_BatchSurface (s); @@ -1002,15 +1001,15 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) if (bound && t->texturechains[chain]->flags & SURF_DRAWFENCE) GL_Uniform1iFunc (useAlphaTestLoc, 0); // Flip alpha test back off } - + // clean up GL_DisableVertexAttribArrayFunc (vertAttrIndex); GL_DisableVertexAttribArrayFunc (texCoordsAttrIndex); GL_DisableVertexAttribArrayFunc (LMCoordsAttrIndex); - + GL_UseProgramFunc (0); GL_SelectTexture (GL_TEXTURE0); - + if (entalpha < 1) { glDepthMask (GL_TRUE);