From ed4de07e9a44fd0962e950925a886c6523497828 Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV <despair@users.sourceforge.net> Date: Sat, 1 Sep 2001 08:57:04 +0000 Subject: [PATCH] Header and variable declaration cleanups, tiny bit of whitespace. --- libs/video/renderer/gl/gl_draw.c | 44 ++++---- libs/video/renderer/gl/gl_dyn_fires.c | 7 +- libs/video/renderer/gl/gl_dyn_lights.c | 6 +- libs/video/renderer/gl/gl_dyn_part.c | 38 +++---- libs/video/renderer/gl/gl_dyn_textures.c | 14 ++- libs/video/renderer/gl/gl_funcs.c | 10 +- libs/video/renderer/gl/gl_graph.c | 29 +++-- libs/video/renderer/gl/gl_rmain.c | 81 ++++++-------- libs/video/renderer/gl/gl_rmisc.c | 4 +- libs/video/renderer/gl/gl_rsurf.c | 134 ++++++++++------------- libs/video/renderer/gl/gl_screen.c | 72 +++++------- libs/video/renderer/gl/gl_skin.c | 22 ++-- libs/video/renderer/gl/gl_sky.c | 27 ++--- libs/video/renderer/gl/gl_sky_clip.c | 39 +++---- libs/video/renderer/gl/gl_textures.c | 35 +++--- libs/video/renderer/gl/gl_warp.c | 33 +++--- libs/video/renderer/gl/noisetextures.c | 6 +- 17 files changed, 269 insertions(+), 332 deletions(-) diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index 704824e2b..094e4308f 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -45,25 +45,20 @@ #include "QF/render.h" #include "QF/screen.h" #include "QF/sys.h" -#include "QF/vid.h" #include "QF/va.h" #include "QF/vfs.h" -#include "QF/GL/qf_textures.h" -#include "QF/GL/types.h" +#include "QF/vid.h" #include "QF/GL/defines.h" #include "QF/GL/funcs.h" #include "QF/GL/qf_screen.h" +#include "QF/GL/qf_textures.h" #include "QF/GL/qf_vid.h" +#include "QF/GL/types.h" #include "r_cvar.h" #include "r_shared.h" #include "sbar.h" -extern byte *vid_basepal; - -extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor, - *r_lightmap_components; - byte *draw_chars; // 8*8 graphic characters qpic_t *draw_backtile; @@ -104,12 +99,17 @@ static int numcachepics; static byte menuplyr_pixels[4096]; +extern byte *vid_basepal; + +extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor, + *r_lightmap_components; + qpic_t * Draw_PicFromWad (const char *name) { - qpic_t *p; glpic_t *gl; + qpic_t *p; p = W_GetLumpName (name); gl = (glpic_t *) p->data; @@ -135,8 +135,8 @@ Draw_CachePic (const char *path, qboolean alpha) { cachepic_t *pic; int i; - qpic_t *dat; glpic_t *gl; + qpic_t *dat; // First, check if its cached.. for (pic = cachepics, i = 0; i < numcachepics; pic++, i++) @@ -185,9 +185,8 @@ Draw_CachePic (const char *path, qboolean alpha) void Draw_TextBox (int x, int y, int width, int lines) { + int cx, cy, n; qpic_t *p; - int cx, cy; - int n; // draw left side cx = x; @@ -288,8 +287,8 @@ Draw_Init (void) void Draw_Character (int x, int y, int num) { - int row, col; float frow, fcol, size; + int row, col; if (num == 32) return; // space @@ -343,9 +342,9 @@ Draw_AltString (int x, int y, const char *str) void Draw_Crosshair (int swap) { - int x, y; - extern vrect_t scr_vrect; unsigned char *pColor; + int x, y; + extern vrect_t scr_vrect; switch (crosshair->int_val) { case 0: @@ -404,8 +403,8 @@ void Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height) { - glpic_t *gl; float newsl, newtl, newsh, newth; + glpic_t *gl; gl = (glpic_t *) pic->data; @@ -438,10 +437,9 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) { - int v, u, c; + byte *src; + int c, p, u, v; unsigned int trans[64 * 64], *dest; - byte *src; - int p; qfglBindTexture (GL_TEXTURE_2D, translate_texture); @@ -488,11 +486,11 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) void Draw_ConsoleBackground (int lines) { - int y; - qpic_t *conback; - glpic_t *gl; - float ofs; byte alpha; + float ofs; + int y; + glpic_t *gl; + qpic_t *conback; // This can be a CachePic now, just like in software conback = Draw_CachePic ("gfx/conback.lmp", false); diff --git a/libs/video/renderer/gl/gl_dyn_fires.c b/libs/video/renderer/gl/gl_dyn_fires.c index 9332eb663..887c631e0 100644 --- a/libs/video/renderer/gl/gl_dyn_fires.c +++ b/libs/video/renderer/gl/gl_dyn_fires.c @@ -59,10 +59,10 @@ void R_DrawFire (fire_t *f) { - int i, j; - vec3_t vec, vec2; float radius; float *b_sin, *b_cos; + int i, j; + vec3_t vec, vec2; b_sin = bubble_sintable; b_cos = bubble_costable; @@ -72,7 +72,8 @@ R_DrawFire (fire_t *f) // figure out if we're inside the area of effect VectorSubtract (f->origin, r_origin, vec); if (Length (vec) < radius) { - AddLightBlend (f->color[0], f->color[1], f->color[2], f->size * 0.0003); // we are + AddLightBlend (f->color[0], f->color[1], f->color[2], + f->size * 0.0003); // we are return; } // we're not - draw it diff --git a/libs/video/renderer/gl/gl_dyn_lights.c b/libs/video/renderer/gl/gl_dyn_lights.c index 3a0f4ce4a..71f79eae3 100644 --- a/libs/video/renderer/gl/gl_dyn_lights.c +++ b/libs/video/renderer/gl/gl_dyn_lights.c @@ -70,9 +70,9 @@ AddLightBlend (float r, float g, float b, float a2) void R_InitBubble () { - int i; float a; float *bub_sin, *bub_cos; + int i; bub_sin = bubble_sintable; bub_cos = bubble_costable; @@ -87,10 +87,10 @@ R_InitBubble () void R_RenderDlight (dlight_t *light) { - int i, j; - vec3_t v; float rad; float *bub_sin, *bub_cos; + int i, j; + vec3_t v; bub_sin = bubble_sintable; bub_cos = bubble_costable; diff --git a/libs/video/renderer/gl/gl_dyn_part.c b/libs/video/renderer/gl/gl_dyn_part.c index 48183df71..c503d9a41 100644 --- a/libs/video/renderer/gl/gl_dyn_part.c +++ b/libs/video/renderer/gl/gl_dyn_part.c @@ -57,14 +57,14 @@ static particle_t *particles, **freeparticles; static short r_numparticles, numparticles; -extern cvar_t *cl_max_particles; +int ramp[8] = { 0x6d, 0x6b, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; extern int part_tex_dot; extern int part_tex_spark; extern int part_tex_smoke[8]; extern int part_tex_smoke_ring[8]; -int ramp[8] = { 0x6d, 0x6b, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; +extern cvar_t *cl_max_particles; inline particle_t * @@ -100,8 +100,8 @@ particle_new_random (ptype_t type, int texnum, vec3_t org, int org_fuzz, float scale, int vel_fuzz, float die, byte color, byte alpha) { - vec3_t porg, pvel; int j; + vec3_t porg, pvel; for (j = 0; j < 3; j++) { if (org_fuzz) @@ -172,11 +172,10 @@ R_ClearParticles (void) void R_ReadPointFile_f (void) { - VFile *f; - vec3_t org; - int r; - int c; char name[MAX_OSPATH], *mapname, *t1; + int c, r; + vec3_t org; + VFile *f; mapname = strdup (r_worldentity.model->name); if (!mapname) @@ -331,7 +330,7 @@ R_RunPuffEffect (vec3_t org, particle_effect_t type, byte count) void R_RunParticleEffect (vec3_t org, int color, int count) { - int i, j, scale; + int scale, i, j; vec3_t porg; if (!r_particles->int_val) @@ -379,8 +378,8 @@ R_RunSpikeEffect (vec3_t org, particle_effect_t type) void R_LavaSplash (vec3_t org) { - int i, j; float vel; + int i, j; vec3_t dir, porg, pvel; if (!r_particles->int_val) @@ -410,8 +409,8 @@ R_LavaSplash (vec3_t org) void R_TeleportSplash (vec3_t org) { - int i, j, k; float vel; + int i, j, k; vec3_t dir, porg, pvel; if (!r_particles->int_val) @@ -441,13 +440,11 @@ R_TeleportSplash (vec3_t org) void R_RocketTrail (int type, entity_t *ent) { - vec3_t vec, subtract; - float len, dist; - int j, ptex; - ptype_t ptype; - vec3_t porg, pvel, up, right; - float pdie, pscale; byte palpha, pcolor; + float dist, len, pdie, pscale; + int ptex, j; + ptype_t ptype; + vec3_t porg, pvel, up, right, subtract, vec; if (type == 0) R_AddFire (ent->old_origin, ent->origin, ent); @@ -554,16 +551,13 @@ R_RocketTrail (int type, entity_t *ent) void R_DrawParticles (void) { - byte i; - float grav, fast_grav, dvel; - float minparticledist; + byte alpha, i; unsigned char *at; - byte alpha; - float scale; + float dvel, grav, fast_grav, minparticledist, scale; + int activeparticles, maxparticle, j, k; particle_t *part; vec3_t up, right, o_up, o_right; vec3_t up_scale, right_scale, up_right_scale, down_right_scale; - int activeparticles, maxparticle, j, k; // LordHavoc: particles should not affect zbuffer qfglDepthMask (GL_FALSE); diff --git a/libs/video/renderer/gl/gl_dyn_textures.c b/libs/video/renderer/gl/gl_dyn_textures.c index 4cb9fbd78..ae32ff77e 100644 --- a/libs/video/renderer/gl/gl_dyn_textures.c +++ b/libs/video/renderer/gl/gl_dyn_textures.c @@ -63,8 +63,8 @@ GDT_Init (void) static void GDT_InitDotParticleTexture (void) { - int x, y, dx2, dy, d; byte data[16][16][2]; + int x, y, dx2, dy, d; for (x = 0; x < 16; x++) { dx2 = x - 8; @@ -92,8 +92,8 @@ GDT_InitDotParticleTexture (void) static void GDT_InitSparkParticleTexture (void) { - int x, y, dx2, dy, d; byte data[16][16][2]; + int x, y, dx2, dy, d; for (x = 0; x < 16; x++) { dx2 = 8 - abs(x - 8); @@ -123,9 +123,10 @@ GDT_InitSparkParticleTexture (void) static void GDT_InitSmokeParticleTexture (void) { - int i, x, y, c; + byte d; + byte data[32][32][2], noise1[32][32], noise2[32][32]; float dx, dy2; - byte d, data[32][32][2], noise1[32][32], noise2[32][32]; + int i, x, y, c; for (i = 0; i < 8; i++) { noise_plasma (&noise1[0][0], 32); @@ -161,9 +162,10 @@ GDT_InitSmokeParticleTexture (void) static void GDT_InitSmokeRingParticleTexture (void) { - int i, x, y, b; + byte d; + byte data[32][32][2], noise1[32][32], noise2[32][32]; float dx, dy, c, c2; - byte d, data[32][32][2], noise1[32][32], noise2[32][32]; + int i, x, y, b; for (i = 0; i < 8; i++) { noise_diamondsquare (&noise1[0][0], 32); diff --git a/libs/video/renderer/gl/gl_funcs.c b/libs/video/renderer/gl/gl_funcs.c index bd636cc47..f46dd78b4 100644 --- a/libs/video/renderer/gl/gl_funcs.c +++ b/libs/video/renderer/gl/gl_funcs.c @@ -39,14 +39,15 @@ #ifdef HAVE_STRINGS_H # include <strings.h> #endif + #include <stdio.h> #include <QF/cvar.h> #include <QF/console.h> #include <QF/sys.h> -#include <QF/GL/types.h> -#include <QF/GL/funcs.h> #include <QF/GL/extensions.h> +#include <QF/GL/funcs.h> +#include <QF/GL/types.h> #include "r_cvar.h" @@ -92,8 +93,8 @@ GLF_Init (void) void * QFGL_ProcAddress (void *handle, const char *name, qboolean crit) { - static qboolean inited = false; void *glfunc = NULL; + static qboolean inited = false; #if defined(HAVE_DLOPEN) static QF_glXGetProcAddressARB glGetProcAddress = NULL; @@ -125,7 +126,8 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit) glfunc = GetProcAddress (handle, name); #endif if (glGetProcAddress && glfunc != glGetProcAddress (name)) { - Con_DPrintf ("mismatch! [%p != %p]\n", glfunc, glGetProcAddress (name)); + Con_DPrintf ("mismatch! [%p != %p]\n", glfunc, + glGetProcAddress (name)); return glfunc; } diff --git a/libs/video/renderer/gl/gl_graph.c b/libs/video/renderer/gl/gl_graph.c index 1b137d5b8..ce00fc0bc 100644 --- a/libs/video/renderer/gl/gl_graph.c +++ b/libs/video/renderer/gl/gl_graph.c @@ -36,31 +36,31 @@ # include <strings.h> #endif -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> #include "QF/cvar.h" #include "QF/draw.h" #include "QF/sys.h" -#include "QF/GL/qf_textures.h" #include "QF/GL/defines.h" #include "QF/GL/funcs.h" +#include "QF/GL/qf_textures.h" #include "r_cvar.h" #define NUM_GRAPH_TEXTURES 8 -extern byte *draw_chars; // 8*8 graphic characters - -extern cvar_t *r_netgraph; -extern cvar_t *r_netgraph_alpha; -extern cvar_t *r_netgraph_box; - -static int graph_index; -static int graph_size[NUM_GRAPH_TEXTURES]; -static int graph_width[NUM_GRAPH_TEXTURES]; static byte *graph_texels[NUM_GRAPH_TEXTURES]; -int graph_texture[NUM_GRAPH_TEXTURES]; +int graph_texture[NUM_GRAPH_TEXTURES]; +static int graph_index; +static int graph_size[NUM_GRAPH_TEXTURES]; +static int graph_width[NUM_GRAPH_TEXTURES]; + +extern byte *draw_chars; // 8*8 graphic characters + +extern cvar_t *r_netgraph; +extern cvar_t *r_netgraph_alpha; +extern cvar_t *r_netgraph_box; int @@ -76,12 +76,9 @@ R_InitGraphTextures (int base) void R_LineGraph (int x, int y, int *h_vals, int count) { - int i, j; - int h; - int s; byte color; - int size; byte *dest; + int size, h, i, j, s; if (!count) return; diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 5d009b751..3dfbc5cb7 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -135,11 +135,12 @@ R_RotateForEntity (entity_t *e) static mspriteframe_t * R_GetSpriteFrame (entity_t *currententity) { - msprite_t *psprite; - mspritegroup_t *pspritegroup; + float fullinterval, targettime, time; + float *pintervals; + int frame, numframes, i; + msprite_t *psprite; mspriteframe_t *pspriteframe; - int i, numframes, frame; - float *pintervals, fullinterval, targettime, time; + mspritegroup_t *pspritegroup; psprite = currententity->model->cache.data; frame = currententity->frame; @@ -178,11 +179,10 @@ R_GetSpriteFrame (entity_t *currententity) static void R_DrawSpriteModel (entity_t *e) { - vec3_t point; - mspriteframe_t *frame; float *up, *right; - vec3_t v_forward, v_right, v_up; msprite_t *psprite; + mspriteframe_t *frame; + vec3_t point, v_forward, v_right, v_up; // don't even bother culling, because it's just a single // polygon without a surface cache @@ -228,9 +228,7 @@ R_DrawSpriteModel (entity_t *e) qfglDisable (GL_ALPHA_TEST); } -/* - ALIAS MODELS -*/ +/* ALIAS MODELS */ #define NUMVERTEXNORMALS 162 @@ -238,26 +236,25 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = { #include "anorms.h" }; -vec3_t shadevector; -float shadelight; - // precalculated dot products for quantized angles #define SHADEDOT_QUANT 16 float r_avertexnormal_dots[SHADEDOT_QUANT][256] = #include "anorm_dots.h" ; +float shadelight; float *shadedots = r_avertexnormal_dots[0]; - int lastposenum, lastposenum0; +vec3_t shadevector; + static void GL_DrawAliasFrame (vert_order_t *vo, qboolean fb) { - float l; + float l; + int count; + int *order; blended_vert_t *verts; - int *order; - int count; verts = vo->verts; order = vo->order; @@ -315,11 +312,11 @@ extern vec3_t lightspot; static void GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum) { - trivertx_t *verts; - int *order; - vec3_t point; float height, lheight; int count; + int *order; + vec3_t point; + trivertx_t *verts; lheight = currententity->origin[2] - lightspot[2]; @@ -376,11 +373,11 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum) void GL_DrawAliasBlendedShadow (aliashdr_t *paliashdr, int pose1, int pose2, entity_t *e) { - trivertx_t *verts1, *verts2; - float lerp; + float blend, height, lheight, lerp; + int count; + int *order; + trivertx_t *verts1, *verts2; vec3_t point1, point2; - int *order, count; - float height, lheight, blend; blend = (r_realtime - e->frame_start_time) / e->frame_interval; blend = min (blend, 1); @@ -443,13 +440,10 @@ GL_DrawAliasBlendedShadow (aliashdr_t *paliashdr, int pose1, int pose2, entity_t vert_order_t * GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e) { - vert_order_t *vo; - int count; - int pose; - int numposes; - trivertx_t *verts; - int i; float interval; + int count, numposes, pose, i; + trivertx_t *verts; + vert_order_t *vo; if ((frame >= paliashdr->mdl.numframes) || (frame < 0)) { Con_DPrintf ("R_AliasSetupFrame: no such frame %d\n", frame); @@ -543,18 +537,13 @@ GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e) static void R_DrawAliasModel (entity_t *e, qboolean cull) { - int lnum; - vec3_t dist; - float add; - model_t *clmodel; - vec3_t mins, maxs; - aliashdr_t *paliashdr; - float an; - int anim; - int texture; + float add, an; + int anim, lnum, skinnum, texture; int fb_texture = 0; - int skinnum; + aliashdr_t *paliashdr; + model_t *clmodel; qboolean modelIsFullbright = false; + vec3_t dist, mins, maxs; vert_order_t *vo; clmodel = currententity->model; @@ -726,9 +715,9 @@ R_DrawAliasModel (entity_t *e, qboolean cull) static void R_ShowNearestLoc (void) { - location_t *nearloc; - vec3_t trueloc; dlight_t *dl; + location_t *nearloc; + vec3_t trueloc; if (r_drawentities->int_val) return; @@ -912,8 +901,8 @@ static void R_SetupGL (void) { float screenaspect; - extern int glwidth, glheight; int x, x2, y2, y, w, h; + extern int glwidth, glheight; // set up viewpoint qfglMatrixMode (GL_PROJECTION); @@ -1023,9 +1012,9 @@ void R_RenderBrushPoly (msurface_t *fa); void R_Mirror (void) { - float d; - msurface_t *s; + float d; entity_t **ent; + msurface_t *s; if (!mirror) return; @@ -1126,9 +1115,9 @@ R_RenderView (void) qboolean R_CullBlocked (vec3_t mins, vec3_t maxs, vec3_t org) { + float rad; static struct trace_t trace; vec3_t point; - float rad; if (!gl_occlusion->int_val) return false; diff --git a/libs/video/renderer/gl/gl_rmisc.c b/libs/video/renderer/gl/gl_rmisc.c index 5795f2328..36218e987 100644 --- a/libs/video/renderer/gl/gl_rmisc.c +++ b/libs/video/renderer/gl/gl_rmisc.c @@ -176,8 +176,8 @@ R_Init (void) void R_NewMap (model_t *worldmodel, struct model_s **models, int num_models) { - int i; cvar_t *r_skyname; + int i; for (i = 0; i < 256; i++) d_lightstylevalue[i] = 264; // normal light value @@ -223,8 +223,8 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models) void R_TimeRefresh_f (void) { - int i; double start, stop, time; + int i; qfglFinish (); GL_EndRendering (); diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index ca6f3a86f..5a41c8f5d 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -45,10 +45,10 @@ #include "QF/sys.h" #include "QF/GL/defines.h" #include "QF/GL/funcs.h" -#include "QF/GL/qf_textures.h" #include "QF/GL/qf_rmain.h" -#include "QF/GL/qf_vid.h" #include "QF/GL/qf_sky.h" +#include "QF/GL/qf_textures.h" +#include "QF/GL/qf_vid.h" #include "compat.h" #include "r_cvar.h" @@ -57,16 +57,14 @@ void EmitWaterPolys (msurface_t *fa); -qboolean r_cache_thrash; +qboolean r_cache_thrash; -extern vec3_t shadecolor; // Ender (Extend) Colormod - -int active_lightmaps; -int dlightdivtable[8192]; -int gl_internalformat; -int lightmap_bytes; // 1, 3, or 4 -int lightmap_textures; -int skytexturenum; +int active_lightmaps; +int dlightdivtable[8192]; +int gl_internalformat; +int lightmap_bytes; // 1, 3, or 4 +int lightmap_textures; +int skytexturenum; // LordHavoc: since lightmaps are now allocated only as needed, allow a ridiculous number :) #define MAX_LIGHTMAPS 1024 @@ -75,23 +73,25 @@ int skytexturenum; // keep lightmap texture data in main memory so texsubimage can update properly // LordHavoc: changed to be allocated at runtime (typically lower memory usage) -byte *lightmaps[MAX_LIGHTMAPS]; +byte *lightmaps[MAX_LIGHTMAPS]; // unsigned int blocklights[BLOCK_WIDTH * BLOCK_HEIGHT * 3]; unsigned int blocklights[18 * 18 * 3]; -int allocated[MAX_LIGHTMAPS][BLOCK_WIDTH]; +int allocated[MAX_LIGHTMAPS][BLOCK_WIDTH]; typedef struct glRect_s { unsigned short l, t, w, h; } glRect_t; -glpoly_t *fullbright_polys[MAX_GLTEXTURES]; -qboolean lightmap_modified[MAX_LIGHTMAPS]; -glpoly_t *lightmap_polys[MAX_LIGHTMAPS]; -glRect_t lightmap_rectchange[MAX_LIGHTMAPS]; +glpoly_t *fullbright_polys[MAX_GLTEXTURES]; +qboolean lightmap_modified[MAX_LIGHTMAPS]; +glpoly_t *lightmap_polys[MAX_LIGHTMAPS]; +glRect_t lightmap_rectchange[MAX_LIGHTMAPS]; -msurface_t *waterchain = NULL; -msurface_t *sky_chain; +msurface_t *waterchain = NULL; +msurface_t *sky_chain; + +extern vec3_t shadecolor; // Ender (Extend) Colormod // LordHavoc: place for gl_rsurf setup code @@ -99,6 +99,7 @@ void glrsurf_init (void) { int s; + memset (&lightmaps, 0, sizeof (lightmaps)); dlightdivtable[0] = 1048576 >> 7; for (s = 1; s < 8192; s++) @@ -128,11 +129,12 @@ R_RecursiveLightUpdate (mnode_t *node) void R_AddDynamicLights (msurface_t *surf) { - int sdtable[18], lnum, td, maxdist, maxdist2, maxdist3, i, j, s, t, - smax, tmax, red, green, blue; + float dist, f; + int lnum, maxdist, maxdist2, maxdist3, red, green, blue, smax, + tmax, td, i, j, s, t; + int sdtable[18]; unsigned int *bl; - float dist, f; - vec3_t impact, local; + vec3_t impact, local; // use 64bit integer... shame it's not very standardized... #if _MSC_VER || __BORLANDC__ @@ -209,12 +211,10 @@ R_AddDynamicLights (msurface_t *surf) void R_BuildLightMap (msurface_t *surf, byte * dest, int stride) { - int smax, tmax; - int i, j, size, shift; - byte *lightmap; - unsigned int scale; - int maps; - float t2; + byte *lightmap; + float t2; + int maps, shift, size, smax, tmax, i, j; + unsigned int scale; unsigned int *bl; surf->cached_dlight = (surf->dlightframe == r_framecount); @@ -309,8 +309,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) texture_t * R_TextureAnimation (texture_t *base) { - int relative; - int count; + int count, relative; if (currententity->frame) { if (base->alternate_anims) @@ -334,13 +333,11 @@ R_TextureAnimation (texture_t *base) return base; } -/* - BRUSH MODELS -*/ +/* BRUSH MODELS */ -extern int solidskytexture; -extern int alphaskytexture; extern float speedscale; // for top sky and bottom sky +extern int solidskytexture; +extern int alphaskytexture; void GL_UploadLightmap (int i, int x, int y, int w, int h) @@ -372,9 +369,8 @@ GL_UploadLightmap (int i, int x, int y, int w, int h) void R_DrawMultitexturePoly (msurface_t *s) { - int maps; float *v; - int i; + int maps, i; texture_t *texture = R_TextureAnimation (s->texinfo->texture); c_brush_polys++; @@ -433,9 +429,9 @@ R_DrawMultitexturePoly (msurface_t *s) void R_BlendLightmaps (void) { + float *v; int i, j; glpoly_t *p; - float *v; qfglDepthMask (GL_FALSE); // don't bother writing Z @@ -473,9 +469,9 @@ R_BlendLightmaps (void) void R_RenderFullbrights (void) { + float *v; int i, j; glpoly_t *p; - float *v; qfglBlendFunc (GL_ONE, GL_ONE); for (i = 1; i < MAX_GLTEXTURES; i++) { @@ -484,7 +480,8 @@ R_RenderFullbrights (void) qfglBindTexture (GL_TEXTURE_2D, i); for (p = fullbright_polys[i]; p; p = p->fb_chain) { qfglBegin (GL_POLYGON); - for (j = 0, v = p->verts[0]; j < p->numverts; j++, v += VERTEXSIZE) { + for (j = 0, v = p->verts[0]; j < p->numverts; j++, v += VERTEXSIZE) + { qfglTexCoord2fv (&v[3]); qfglVertex3fv (v); } @@ -498,11 +495,9 @@ void R_RenderBrushPoly (msurface_t *fa) { byte *base; - int maps; - glRect_t *theRect; - int i; float *v; - int smax, tmax; + int maps, smax, tmax, i; + glRect_t *theRect; texture_t *texture = R_TextureAnimation (fa->texinfo->texture); c_brush_polys++; @@ -636,14 +631,13 @@ DrawTextureChains (void) void R_DrawBrushModel (entity_t *e) { - int i; - int k; - vec3_t mins, maxs; - msurface_t *psurf; float dot; - mplane_t *pplane; + int i, k; model_t *clmodel; + mplane_t *pplane; + msurface_t *psurf; qboolean rotated; + vec3_t mins, maxs; currententity = e; @@ -739,18 +733,16 @@ R_DrawBrushModel (entity_t *e) qfglPopMatrix (); } -/* - WORLD MODEL -*/ +/* WORLD MODEL */ void R_RecursiveWorldNode (mnode_t *node) { + double dot; int c, side; + mleaf_t *pleaf; mplane_t *plane; msurface_t *surf; - mleaf_t *pleaf; - double dot; if (node->contents == CONTENTS_SOLID) return; @@ -866,13 +858,12 @@ R_DrawWorld (void) void R_MarkLeaves (void) { - byte *vis; - mnode_t *node; - mleaf_t *leaf; + byte solid[4096]; + byte *vis; + int c, i; + mleaf_t *leaf; + mnode_t *node; msurface_t **mark; - int i; - int c; - byte solid[4096]; if (r_oldviewleaf == r_viewleaf && !r_novis->int_val) return; @@ -907,17 +898,13 @@ R_MarkLeaves (void) } } -/* - LIGHTMAP ALLOCATION -*/ +/* LIGHTMAP ALLOCATION */ // returns a texture number and the position inside it int AllocBlock (int w, int h, int *x, int *y) { - int i, j; - int best, best2; - int texnum; + int best, best2, texnum, i, j; for (texnum = 0; texnum < MAX_LIGHTMAPS; texnum++) { best = BLOCK_HEIGHT; @@ -955,19 +942,18 @@ AllocBlock (int w, int h, int *x, int *y) return 0; } -mvertex_t *r_pcurrentvertbase; -model_t *currentmodel; int nColinElim; +model_t *currentmodel; +mvertex_t *r_pcurrentvertbase; void BuildSurfaceDisplayList (msurface_t *fa) { - int i, lindex, lnumverts; - medge_t *pedges, *r_pedge; - int vertpage; - float *vec; float s, t; + float *vec; + int lindex, lnumverts, vertpage, i; glpoly_t *poly; + medge_t *pedges, *r_pedge; // reconstruct the polygon pedges = currentmodel->edges; @@ -1060,8 +1046,8 @@ BuildSurfaceDisplayList (msurface_t *fa) void GL_CreateSurfaceLightmap (msurface_t *surf) { - int smax, tmax; byte *base; + int smax, tmax; if (surf->flags & (SURF_DRAWSKY | SURF_DRAWTURB)) return; diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index 0dfd5ec1f..19a1f5bdf 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -61,9 +61,6 @@ #include "sbar.h" #include "view.h" -extern float v_blend[4]; -extern void GL_Set2D (void); - /* background clear rendering @@ -131,8 +128,6 @@ int scr_fullupdate; int clearconsole; int clearnotify; -extern int sb_lines; - viddef_t vid; // global video state vrect_t scr_vrect; @@ -144,9 +139,7 @@ qboolean block_drawing; void SCR_ScreenShot_f (void); -/* - CENTER PRINTING -*/ +/* CENTER PRINTING */ char scr_centerstring[1024]; float scr_centertime_start; // for slow victory printing @@ -155,6 +148,11 @@ int scr_center_lines; int scr_erase_lines; int scr_erase_center; +extern float v_blend[4]; +extern int sb_lines; + +extern void GL_Set2D (void); + /* SCR_CenterPrint @@ -182,10 +180,7 @@ void SCR_DrawCenterString (void) { char *start; - int l; - int j; - int x, y; - int remaining; + int remaining, j, l, x, y; // the finale prints the characters one at a time if (r_force_fullscreen /*FIXME better test*/) @@ -245,8 +240,7 @@ SCR_CheckDrawCenterString (int swap) float CalcFov (float fov_x, float width, float height) { - float a; - float x; + float a, x; if (fov_x < 1 || fov_x > 179) Sys_Error ("Bad fov: %f", fov_x); @@ -404,18 +398,19 @@ SCR_DrawTurtle (int swap) Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle); } -extern cvar_t *show_time; extern cvar_t *show_fps; +extern cvar_t *show_time; void SCR_DrawFPS (int swap) { + char st[80]; + double t; static double lastframetime; - double t; - extern int fps_count; - static int lastfps; - int i, x, y; - char st[80]; + int i, x, y; + static int lastfps; + + extern int fps_count; if (!show_fps->int_val) return; @@ -452,12 +447,11 @@ SCR_DrawFPS (int swap) void SCR_DrawTime (int swap) { - int x, y; char st[80]; - + char *timefmt = NULL; + int x, y; + struct tm *local = NULL; time_t utc = 0; - struct tm *local = NULL; - char *timefmt = NULL; // any cvar that can take multiple settings must be able to handle abuse. if (show_time->int_val <= 0) @@ -549,14 +543,10 @@ SCR_DrawConsole (int swap) tex_t * SCR_ScreenShot (int width, int height) { - int x, y; unsigned char *src, *dest; - int w, h; - int dx, dy, dex, dey, nx; - int r, b, g; - int count; - float fracw, frach; - tex_t *tex; + float fracw, frach; + int count, dex, dey, dx, dy, nx, r, g, b, x, y, w, h; + tex_t *tex; tex = Hunk_TempAlloc (field_offset (tex_t, data[vid.width * vid.height * 3])); @@ -645,13 +635,11 @@ SCR_ScreenShot_f (void) int MipColor (int r, int g, int b) { - int i; - float dist; + float bestdist, dist; + int r1, g1, b1, i; int best = 0; - float bestdist; - int r1, g1, b1; - static int lr = -1, lg = -1, lb = -1; static int lastbest; + static int lr = -1, lg = -1, lb = -1; if (r == lr && g == lg && b == lb) return lastbest; @@ -681,10 +669,8 @@ extern byte *draw_chars; // 8*8 graphic characters void SCR_DrawCharToSnap (int num, byte * dest, int width) { - int row, col; byte *source; - int drawline; - int x; + int col, row, drawline, x; row = num >> 4; col = num & 15; @@ -707,10 +693,10 @@ SCR_DrawCharToSnap (int num, byte * dest, int width) void SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y) { - byte *buf = tex->data; byte *dest; + byte *buf = tex->data; const unsigned char *p; - int width = tex->width; + int width = tex->width; dest = buf + ((y * width) + x); @@ -727,9 +713,7 @@ void SCR_DrawNotifyString (void) { char *start; - int l; - int j; - int x, y; + int j, l, x, y; start = scr_notifystring; diff --git a/libs/video/renderer/gl/gl_skin.c b/libs/video/renderer/gl/gl_skin.c index 4e52d5322..b9ea2bde3 100644 --- a/libs/video/renderer/gl/gl_skin.c +++ b/libs/video/renderer/gl/gl_skin.c @@ -82,10 +82,10 @@ build_skin_8 (byte * original, int tinwidth, int tinheight, unsigned int scaled_width, unsigned int scaled_height, int inwidth, qboolean alpha) { + byte *inrow; + byte pixels[512 * 256], *out; + int i, j; unsigned int frac, fracstep; - byte *inrow; - byte pixels[512 * 256], *out; - int i, j; out = pixels; memset (pixels, 0, sizeof (pixels)); @@ -114,11 +114,11 @@ build_skin_32 (byte * original, int tinwidth, int tinheight, unsigned int scaled_width, unsigned int scaled_height, int inwidth, qboolean alpha) { + byte *inrow; + int i, j; + int samples = alpha ? gl_alpha_format : gl_solid_format; unsigned int frac, fracstep; - byte *inrow; unsigned int pixels[512 * 256], *out; - int i, j; - int samples = alpha ? gl_alpha_format : gl_solid_format; out = pixels; memset (pixels, 0, sizeof (pixels)); @@ -176,9 +176,9 @@ build_skin (int texnum, byte *ptexels, int width, int height, void Skin_Do_Translation (skin_t *player_skin, int slot, skin_t *skin) { - int texnum = skin->texture; - int inwidth, inheight; byte *original; + int inwidth, inheight; + int texnum = skin->texture; tex_t *skin_texels; if ((skin_texels = (tex_t*)Skin_Cache (player_skin)) != NULL) { @@ -197,10 +197,10 @@ Skin_Do_Translation (skin_t *player_skin, int slot, skin_t *skin) void Skin_Do_Translation_Model (model_t *model, int skinnum, int slot, skin_t *skin) { - int texnum = skin->texture; - int inwidth, inheight; - aliashdr_t *paliashdr; byte *original; + int inwidth, inheight; + int texnum = skin->texture; + aliashdr_t *paliashdr; if (!model) // player doesn't have a model yet return; diff --git a/libs/video/renderer/gl/gl_sky.c b/libs/video/renderer/gl/gl_sky.c index 160388de1..aaf98fb84 100644 --- a/libs/video/renderer/gl/gl_sky.c +++ b/libs/video/renderer/gl/gl_sky.c @@ -54,25 +54,24 @@ #include "view.h" #include "r_cvar.h" -extern model_t *loadmodel; - -extern int skytexturenum; - +char *suf[6] = { "rt", "bk", "lf", "ft", "up", "dn" }; +float speedscale; // for top sky and bottom sky int solidskytexture; int alphaskytexture; -float speedscale; // for top sky and bottom sky // Set to true if a valid skybox is loaded --KB qboolean skyloaded = false; +extern int skytexturenum; +extern model_t *loadmodel; + -char *suf[6] = { "rt", "bk", "lf", "ft", "up", "dn" }; void R_LoadSkys (const char *skyname) { + char name[64]; int i; VFile *f; - char name[64]; if (strcasecmp (skyname, "none") == 0) { skyloaded = false; @@ -187,8 +186,8 @@ vec3_t domescale; void R_DrawSkyLayer (float s) { - int a, b; float x, y, a1x, a1y, a2x, a2y; + int a, b; vec3_t v; for (a = 0; a < 16; a++) { @@ -278,17 +277,15 @@ R_DrawSky (void) void R_InitSky (texture_t *mt) { - int i, j, p; - byte *src; - unsigned int trans[128 * 128]; - unsigned int transpix; - int r, g, b; + byte *src; + int i, j, p, r, g, b; + unsigned int transpix; + unsigned int trans[128 * 128]; unsigned int *rgba; src = (byte *) mt + mt->offsets[0]; - // make an average value for the back to avoid - // a fringe on the top level + // make an average value for the back to avoid a fringe on the top level r = g = b = 0; for (i = 0; i < 128; i++) diff --git a/libs/video/renderer/gl/gl_sky_clip.c b/libs/video/renderer/gl/gl_sky_clip.c index 3c1e0733e..873806ccf 100644 --- a/libs/video/renderer/gl/gl_sky_clip.c +++ b/libs/video/renderer/gl/gl_sky_clip.c @@ -51,9 +51,6 @@ #include "r_shared.h" #include "view.h" -extern qboolean skyloaded; -extern vec5_t skyvec[6][4]; - #define BOX_WIDTH 2056 /* cube face to sky texture offset conversion */ @@ -107,6 +104,9 @@ struct box_def { struct face_def face[6]; }; +extern qboolean skyloaded; +extern vec5_t skyvec[6][4]; + /* determine_face @@ -123,8 +123,8 @@ struct box_def { static int determine_face (vec3_t v) { - float a[3]; float m; + float a[3]; int i = 0; m = a[0] = fabs (v[0]); @@ -174,20 +174,14 @@ determine_face (vec3_t v) static int find_intersect (int face1, vec3_t x1, int face2, vec3_t x2, vec3_t y) { - vec3_t n; // normal to the plane formed by the - - // eye and the two points on the cube. - - vec3_t x = { 0, 0, 0 }; // point on cube edge of adjoining - - // faces. always on an axis plane. - - vec3_t v = { 0, 0, 0 }; // direction vector of cube edge. - - // always +ve - - vec_t x_n, v_n; // x.n and v.n int axis; + vec3_t n; // normal to the plane formed by the + // eye and the two points on the cube. + vec3_t x = { 0, 0, 0 }; // point on cube edge of adjoining + // faces. always on an axis plane. + vec3_t v = { 0, 0, 0 }; // direction vector of cube edge. + // always +ve + vec_t x_n, v_n; // x.n and v.n vec3_t t; x[face_axis[face1]] = face_offset[face1]; @@ -286,10 +280,10 @@ insert_cube_vertices (struct box_def *box, struct visit_def visit, int count, ...) { int i; - vec3_t **v; - va_list args; int face = visit.face; int ind = visit.leave + 1; + va_list args; + vec3_t **v; #ifdef __BORLANDC__ // This is fix for borland alloca "feature" which fails to restore stack @@ -339,9 +333,9 @@ static void cross_cube_edge (struct box_def *box, int face1, vec3_t v1, int face2, vec3_t v2) { - vec3_t l; int axis; int face = -1; + vec3_t l; axis = find_intersect (face1, v1, face2, v2, l); if (l[axis] > 1024) @@ -376,10 +370,9 @@ cross_cube_edge (struct box_def *box, int face1, vec3_t v1, int face2, static void process_corners (struct box_def *box) { - struct visit_def *visit = box->visited_faces; - int max_visit = 0; int i; - int center = -1; + int center = -1, max_visit = 0; + struct visit_def *visit = box->visited_faces; if (visit[box->face_count - 1].face == visit[0].face) { box->face_count--; diff --git a/libs/video/renderer/gl/gl_textures.c b/libs/video/renderer/gl/gl_textures.c index b94930694..1aa29b4c8 100644 --- a/libs/video/renderer/gl/gl_textures.c +++ b/libs/video/renderer/gl/gl_textures.c @@ -52,12 +52,8 @@ #include "QF/GL/qf_vid.h" #include "compat.h" -#include "sbar.h" #include "r_cvar.h" - -extern int gl_filter_min, gl_filter_max; -extern unsigned char d_15to8table[65536]; -extern cvar_t *gl_picmip; +#include "sbar.h" typedef struct { int texnum; @@ -180,11 +176,15 @@ static glformat_t formats[] = { int gl_alpha_format = 4, gl_lightmap_format = 4, gl_solid_format = 3; +extern unsigned char d_15to8table[65536]; +extern int gl_filter_min, gl_filter_max; +extern cvar_t *gl_picmip; + void GL_TextureMode_f (void) { - int i; + int i; gltexture_t *glt; if (Cmd_Argc () == 1) { @@ -210,7 +210,7 @@ GL_TextureMode_f (void) gl_filter_min = modes[i].minimize; gl_filter_max = modes[i].maximize; -// change all the existing mipmap texture objects + // change all the existing mipmap texture objects for (i = 0, glt = gltextures; i < numgltextures; i++, glt++) { if (glt->mipmap) { qfglBindTexture (GL_TEXTURE_2D, glt->texnum); @@ -253,9 +253,9 @@ static void GL_ResampleTexture (unsigned int *in, int inwidth, int inheight, unsigned int *out, int outwidth, int outheight) { - int i, j; + int i, j; + unsigned int frac, fracstep; unsigned int *inrow; - unsigned int frac, fracstep; if (!outwidth || !outheight) return; @@ -275,9 +275,9 @@ static void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight) { - int i, j; unsigned char *inrow; - unsigned int frac, fracstep; + int i, j; + unsigned int frac, fracstep; if (!outwidth || !outheight) return; @@ -301,8 +301,8 @@ GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, static void GL_MipMap (byte * in, int width, int height) { - int i, j; byte *out; + int i, j; width <<= 2; height >>= 1; @@ -327,10 +327,9 @@ GL_MipMap (byte * in, int width, int height) static void GL_MipMap8Bit (byte * in, int width, int height) { - int i, j; - byte *out; + byte *at1, *at2, *at3, *at4, *out; + int i, j; unsigned short r, g, b; - byte *at1, *at2, *at3, *at4; height >>= 1; out = in; @@ -358,8 +357,8 @@ static void GL_Upload32 (unsigned int *data, int width, int height, qboolean mipmap, qboolean alpha) { + int scaled_width, scaled_height, intformat; unsigned int *scaled; - int scaled_width, scaled_height, intformat; if (!width || !height) return; // Null texture @@ -505,8 +504,8 @@ extern qboolean VID_Is8bit (void); void GL_Upload8 (byte * data, int width, int height, qboolean mipmap, qboolean alpha) { + int i, s, p; unsigned int *trans = NULL; - int i, s, p; s = width * height; trans = malloc (s * sizeof (unsigned int)); @@ -549,8 +548,8 @@ int GL_LoadTexture (const char *identifier, int width, int height, byte * data, qboolean mipmap, qboolean alpha, int bytesperpixel) { + int crc, i; gltexture_t *glt; - int i, crc; // LordHavoc: now just using a standard CRC for texture validation crc = CRC_Block (data, width * height * bytesperpixel); diff --git a/libs/video/renderer/gl/gl_warp.c b/libs/video/renderer/gl/gl_warp.c index aff12877d..00558dc7b 100644 --- a/libs/video/renderer/gl/gl_warp.c +++ b/libs/video/renderer/gl/gl_warp.c @@ -33,24 +33,23 @@ #include "QF/cvar.h" #include "QF/sys.h" -#include "r_shared.h" #include "r_cvar.h" +#include "r_shared.h" #include "QF/GL/defines.h" #include "QF/GL/funcs.h" -extern model_t *loadmodel; - msurface_t *warpface; extern cvar_t *gl_subdivide_size; +extern model_t *loadmodel; void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs) { - int i, j; float *v; + int i, j; mins[0] = mins[1] = mins[2] = 9999; maxs[0] = maxs[1] = maxs[2] = -9999; @@ -67,16 +66,13 @@ BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs) void SubdividePolygon (int numverts, float *verts) { - int i, j, k; - vec3_t mins, maxs; - float m; - float *v; - vec3_t front[64], back[64]; - int f, b; + float frac, m, s, t; float dist[64]; - float frac; + float *v; + int b, f, i, j, k; glpoly_t *poly; - float s, t; + vec3_t mins, maxs; + vec3_t front[64], back[64]; if (numverts > 60) Sys_Error ("numverts = %i", numverts); @@ -85,8 +81,7 @@ SubdividePolygon (int numverts, float *verts) for (i = 0; i < 3; i++) { m = (mins[i] + maxs[i]) * 0.5; - m = - gl_subdivide_size->value * floor (m / gl_subdivide_size->value + + m = gl_subdivide_size->value * floor (m / gl_subdivide_size->value + 0.5); if (maxs[i] - m < 8) continue; @@ -155,11 +150,9 @@ SubdividePolygon (int numverts, float *verts) void GL_SubdivideSurface (msurface_t *fa) { - vec3_t verts[64]; - int numverts; - int i; - int lindex; float *vec; + int lindex, numverts, i; + vec3_t verts[64]; warpface = fa; @@ -194,10 +187,10 @@ float turbsin[] = { void EmitWaterPolys (msurface_t *fa) { - glpoly_t *p; + float os, ot, s, t; float *v; int i; - float s, t, os, ot; + glpoly_t *p; vec3_t nv; for (p = fa->polys; p; p = p->next) { diff --git a/libs/video/renderer/gl/noisetextures.c b/libs/video/renderer/gl/noisetextures.c index a5c2c4104..ba7a901db 100644 --- a/libs/video/renderer/gl/noisetextures.c +++ b/libs/video/renderer/gl/noisetextures.c @@ -39,6 +39,7 @@ #ifdef HAVE_STRINGS_H # include <strings.h> #endif + #include <stdlib.h> #include "QF/mathlib.h" @@ -47,7 +48,8 @@ void noise_diamondsquare (unsigned char *noise, int size) { - int x, y, g, g2, amplitude, min, max, size1 = size - 1; + int amplitude, max, min, g, g2, x, y; + int size1 = size - 1; int *noisebuf; #define n(x,y) noisebuf[((y)&size1)*size+((x)&size1)] @@ -102,7 +104,7 @@ noise_diamondsquare (unsigned char *noise, int size) void noise_plasma (unsigned char *noise, int size) { - int a, b, c, d, i, j, k; + int a, b, c, d, i, j, k; if (128 >= size) d = 64 / size;