diff --git a/include/r_cvar.h b/include/r_cvar.h index 9595e408b..188e04bdf 100644 --- a/include/r_cvar.h +++ b/include/r_cvar.h @@ -1,5 +1,3 @@ -extern unsigned char lighthalf_v[3]; - extern struct cvar_s *cl_crossx; extern struct cvar_s *cl_crossy; extern struct cvar_s *cl_verstring; diff --git a/include/r_shared.h b/include/r_shared.h index 449a18496..b1b2a950e 100644 --- a/include/r_shared.h +++ b/include/r_shared.h @@ -66,6 +66,9 @@ extern struct cvar_s *r_clearcolor; extern int sintable[SIN_BUFFER_SIZE]; extern int intsintable[SIN_BUFFER_SIZE]; +extern byte color_white[4]; +extern byte color_black[4]; + extern vec3_t vup, base_vup; extern vec3_t vpn, base_vpn; extern vec3_t vright, base_vright; diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index f0f21c952..704824e2b 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -56,6 +56,7 @@ #include "QF/GL/qf_vid.h" #include "r_cvar.h" +#include "r_shared.h" #include "sbar.h" extern byte *vid_basepal; @@ -71,6 +72,8 @@ static int translate_texture; static int char_texture; static int cs_texture; // crosshair texturea +static byte color_0_8[4] = { 204, 204, 204, 255 }; + static byte cs_data[64] = { 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -372,7 +375,7 @@ Draw_Crosshair (int swap) qfglTexCoord2f (0, 1); qfglVertex2f (x - 4, y + 12); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); break; } } @@ -412,7 +415,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, newtl = (float) srcy / (float) pic->height; newth = newtl + (float) height / (float) pic->height; - qfglColor3f (0.8, 0.8, 0.8); + qfglColor3ubv (color_0_8); qfglBindTexture (GL_TEXTURE_2D, gl->texnum); qfglBegin (GL_QUADS); qfglTexCoord2f (newsl, newtl); @@ -424,7 +427,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, qfglTexCoord2f (newsl, newth); qfglVertex2f (x, y + height); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } /* @@ -462,7 +465,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); - qfglColor3f (0.8, 0.8, 0.8); + qfglColor3ubv (color_0_8); qfglBegin (GL_QUADS); qfglTexCoord2f (0, 0); qfglVertex2f (x, y); @@ -473,7 +476,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) qfglTexCoord2f (0, 1); qfglVertex2f (x, y + pic->height); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } /* @@ -489,7 +492,7 @@ Draw_ConsoleBackground (int lines) qpic_t *conback; glpic_t *gl; float ofs; - float alpha; + byte alpha; // This can be a CachePic now, just like in software conback = Draw_CachePic ("gfx/conback.lmp", false); @@ -520,13 +523,14 @@ Draw_ConsoleBackground (int lines) y = vid.height * scr_consize->value; if (!r_active || lines > y) { - alpha = 1.0; + alpha = 255; } else { // set up to draw alpha console - alpha = (float) (gl_conalpha->value * lines) / y; + alpha = 255 * (gl_conalpha->value * lines) / y; } - qfglColor4f (0.8, 0.8, 0.8, alpha); + color_0_8[3] = alpha; + qfglColor4ubv (color_0_8); // draw the console texture qfglBindTexture (GL_TEXTURE_2D, gl->texnum); @@ -542,8 +546,8 @@ Draw_ConsoleBackground (int lines) qfglEnd (); // turn off alpha blending - if (alpha < 1.0) { - qfglColor3f (0.8, 0.8, 0.8); + if (alpha < 255) { + qfglColor3ubv (color_0_8); } if (gl_conspin->value) { @@ -554,7 +558,7 @@ Draw_ConsoleBackground (int lines) Draw_AltString (vid.conwidth - strlen (cl_verstring->string) * 8 - 11, lines - 14, cl_verstring->string); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } /* @@ -566,7 +570,7 @@ Draw_ConsoleBackground (int lines) void Draw_TileClear (int x, int y, int w, int h) { - qfglColor3f (0.8, 0.8, 0.8); + qfglColor3ubv (color_0_8); qfglBindTexture (GL_TEXTURE_2D, *(int *) draw_backtile->data); qfglBegin (GL_QUADS); qfglTexCoord2f (x / 64.0, y / 64.0); @@ -578,7 +582,7 @@ Draw_TileClear (int x, int y, int w, int h) qfglTexCoord2f (x / 64.0, (y + h) / 64.0); qfglVertex2f (x, y + h); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } /* @@ -590,8 +594,7 @@ void Draw_Fill (int x, int y, int w, int h, int c) { qfglDisable (GL_TEXTURE_2D); - qfglColor3f (vid_basepal[c * 3] / 255.0, vid_basepal[c * 3 + 1] / 255.0, - vid_basepal[c * 3 + 2] / 255.0); + qfglColor3ubv (vid_basepal + c * 3); qfglBegin (GL_QUADS); @@ -601,7 +604,7 @@ Draw_Fill (int x, int y, int w, int h, int c) qfglVertex2f (x, y + h); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); qfglEnable (GL_TEXTURE_2D); } @@ -618,7 +621,7 @@ Draw_FadeScreen (void) qfglVertex2f (0, vid.height); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); qfglEnable (GL_TEXTURE_2D); Sbar_Changed (); @@ -666,5 +669,5 @@ GL_Set2D (void) qfglDisable (GL_DEPTH_TEST); qfglDisable (GL_CULL_FACE); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } diff --git a/libs/video/renderer/gl/gl_dyn_fires.c b/libs/video/renderer/gl/gl_dyn_fires.c index 0a9b09dd4..9332eb663 100644 --- a/libs/video/renderer/gl/gl_dyn_fires.c +++ b/libs/video/renderer/gl/gl_dyn_fires.c @@ -81,7 +81,7 @@ R_DrawFire (fire_t *f) for (i = 0; i < 3; i++) vec[i] = f->origin[i] - vpn[i] * radius; qfglVertex3fv (vec); - qfglColor3f (0.0, 0.0, 0.0); + qfglColor3ubv (color_black); // don't panic, this just draws a bubble... for (i = 16; i >= 0; i--) { @@ -98,7 +98,6 @@ R_DrawFire (fire_t *f) b_cos += 2; } qfglEnd (); - qfglColor3ubv (lighthalf_v); } /* @@ -127,6 +126,7 @@ R_UpdateFires (void) R_DrawFire (f); } + qfglColor3ubv (color_white); qfglEnable (GL_TEXTURE_2D); qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qfglDepthMask (GL_TRUE); diff --git a/libs/video/renderer/gl/gl_dyn_lights.c b/libs/video/renderer/gl/gl_dyn_lights.c index f6bbfc6b5..3a0f4ce4a 100644 --- a/libs/video/renderer/gl/gl_dyn_lights.c +++ b/libs/video/renderer/gl/gl_dyn_lights.c @@ -112,7 +112,7 @@ R_RenderDlight (dlight_t *light) v[i] = light->origin[i] + v[i] * rad; qfglVertex3fv (v); - qfglColor3f (0, 0, 0); + qfglColor3ubv (color_black); for (i = 16; i >= 0; i--) { for (j = 0; j < 3; j++) @@ -149,7 +149,7 @@ R_RenderDlights (void) if (!gl_dlight_smooth->int_val) qfglShadeModel (GL_FLAT); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); qfglEnable (GL_TEXTURE_2D); qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qfglDepthMask (GL_TRUE); diff --git a/libs/video/renderer/gl/gl_dyn_part.c b/libs/video/renderer/gl/gl_dyn_part.c index f847e675d..48183df71 100644 --- a/libs/video/renderer/gl/gl_dyn_part.c +++ b/libs/video/renderer/gl/gl_dyn_part.c @@ -724,6 +724,6 @@ R_DrawParticles (void) } numparticles = activeparticles; - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); qfglDepthMask (GL_TRUE); } diff --git a/libs/video/renderer/gl/gl_graph.c b/libs/video/renderer/gl/gl_graph.c index 1a90d4b5c..1b137d5b8 100644 --- a/libs/video/renderer/gl/gl_graph.c +++ b/libs/video/renderer/gl/gl_graph.c @@ -138,7 +138,5 @@ R_LineGraph (int x, int y, int *h_vals, int count) qfglVertex2f (x, y - s); qfglEnd (); - qfglColor3ubv (lighthalf_v); - graph_index = (graph_index + 1) % NUM_GRAPH_TEXTURES; } diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 1456a5acb..356d3a4c5 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -266,7 +266,8 @@ GL_DrawAliasFrame (vert_order_t *vo, qboolean fb) qfglDepthMask (GL_FALSE); if (fb) { - qfglColor4f (1, 1, 1, modelalpha); + color_white[3] = modelalpha * 255; + qfglColor4ubv (color_white); } while ((count = *order++)) { @@ -302,7 +303,6 @@ GL_DrawAliasFrame (vert_order_t *vo, qboolean fb) if (modelalpha != 1.0) qfglDepthMask (GL_TRUE); - qfglColor3ubv (lighthalf_v); } extern vec3_t lightspot; @@ -701,7 +701,8 @@ R_DrawAliasModel (entity_t *e, qboolean cull) R_RotateForEntity (e); qfglDisable (GL_TEXTURE_2D); - qfglColor4f (0, 0, 0, 0.5); + color_black[3] = 128; + qfglColor4ubv (color_black); if (gl_lerp_anim->int_val) { GL_DrawAliasBlendedShadow (paliashdr, lastposenum0, lastposenum, @@ -711,7 +712,6 @@ R_DrawAliasModel (entity_t *e, qboolean cull) } qfglEnable (GL_TEXTURE_2D); - qfglColor3ubv (lighthalf_v); qfglPopMatrix (); } } @@ -783,6 +783,7 @@ R_DrawEntitiesOnList (void) R_DrawAliasModel (currententity, true); } + qfglColor3ubv (color_white); for (i = 0; i < r_numvisedicts; i++) { if (r_visedicts[i]->model->type != mod_sprite) @@ -812,6 +813,7 @@ R_DrawViewModel (void) qfglDepthRange (gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin)); R_DrawAliasModel (currententity, false); qfglDepthRange (gldepthmin, gldepthmax); + qfglColor3ubv (color_white); } static int @@ -1012,12 +1014,6 @@ R_RenderScene (void) R_DrawEntitiesOnList (); R_RenderDlights (); - - if (r_timegraph->int_val) - R_TimeGraph (); - - if (r_zgraph->int_val) - R_ZGraph (); } void R_RenderBrushPoly (msurface_t *fa); @@ -1074,12 +1070,13 @@ R_Mirror (void) qfglLoadMatrixf (r_base_world_matrix); - qfglColor4f (1, 1, 1, r_mirroralpha->value); + color_white[2] = r_mirroralpha->value * 255; + qfglColor4ubv (color_white); s = r_worldentity.model->textures[mirrortexturenum]->texturechain; for (; s; s = s->texturechain) R_RenderBrushPoly (s); r_worldentity.model->textures[mirrortexturenum]->texturechain = NULL; - qfglColor4f (1, 1, 1, 1); + qfglColor3ubv (color_white); } /* @@ -1115,6 +1112,12 @@ R_RenderView (void) // render mirror view R_Mirror (); + + if (r_timegraph->int_val) + R_TimeGraph (); + + if (r_zgraph->int_val) + R_ZGraph (); } #if 0 diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index e4a5ec568..ca6f3a86f 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -381,7 +381,6 @@ R_DrawMultitexturePoly (msurface_t *s) i = s->lightmaptexturenum; - qfglColor3f (1, 1, 1); // Binds world to texture env 0 qglActiveTexture (gl_mtex_enum + 0); qfglBindTexture (GL_TEXTURE_2D, texture->gl_texturenum); @@ -428,7 +427,6 @@ R_DrawMultitexturePoly (msurface_t *s) s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum]; fullbright_polys[texture->gl_fb_texturenum] = s->polys; } - qfglColor3ubv (lighthalf_v); qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } @@ -443,8 +441,6 @@ R_BlendLightmaps (void) qfglBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); - qfglColor3f (1, 1, 1); - for (i = 0; i < MAX_LIGHTMAPS; i++) { p = lightmap_polys[i]; if (!p) @@ -469,7 +465,6 @@ R_BlendLightmaps (void) } // Return to normal blending --KB - qfglColor3ubv (lighthalf_v); qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qfglDepthMask (GL_TRUE); // back to normal Z buffering @@ -512,7 +507,6 @@ R_RenderBrushPoly (msurface_t *fa) c_brush_polys++; - qfglColor3f (1, 1, 1); qfglBindTexture (GL_TEXTURE_2D, texture->gl_texturenum); qfglBegin (GL_POLYGON); @@ -564,7 +558,6 @@ R_RenderBrushPoly (msurface_t *fa) R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes); } } - qfglColor3ubv (lighthalf_v); } void @@ -576,9 +569,10 @@ GL_WaterSurface (msurface_t *s) qfglBindTexture (GL_TEXTURE_2D, i); if (r_wateralpha->value < 1.0) { qfglDepthMask (GL_FALSE); - qfglColor4f (1, 1, 1, r_wateralpha->value); + color_white[3] = r_wateralpha->value * 255; + qfglColor4ubv (color_white); EmitWaterPolys (s); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); qfglDepthMask (GL_TRUE); } else EmitWaterPolys (s); @@ -598,7 +592,8 @@ R_DrawWaterSurfaces (void) if (r_wateralpha->value < 1.0) { qfglDepthMask (GL_FALSE); - qfglColor4f (1, 1, 1, r_wateralpha->value); + color_white[3] = r_wateralpha->value * 255; + qfglColor4ubv (color_white); } i = -1; @@ -614,7 +609,7 @@ R_DrawWaterSurfaces (void) if (r_wateralpha->value < 1.0) { qfglDepthMask (GL_TRUE); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } } @@ -710,11 +705,6 @@ R_DrawBrushModel (entity_t *e) // draw texture for (i = 0; i < clmodel->nummodelsurfaces; i++, psurf++) { -/* FIXME: Not in qw? - if (psurf->flags & SURF_DRAWSKY) - return; -*/ - // find which side of the node we are on pplane = psurf->plane; diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index efbe856d3..0dfd5ec1f 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -877,7 +877,7 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs, int swap) qfglVertex2f (0, vid.height); qfglEnd (); - qfglColor3ubv (lighthalf_v); + qfglColor3ubv (color_white); } qfglEnable (GL_TEXTURE_2D); diff --git a/libs/video/renderer/gl/gl_sky_clip.c b/libs/video/renderer/gl/gl_sky_clip.c index 7cb8161f6..3c1e0733e 100644 --- a/libs/video/renderer/gl/gl_sky_clip.c +++ b/libs/video/renderer/gl/gl_sky_clip.c @@ -47,8 +47,9 @@ #include "QF/GL/qf_sky.h" #include "QF/GL/qf_vid.h" -#include "view.h" #include "r_cvar.h" +#include "r_shared.h" +#include "view.h" extern qboolean skyloaded; extern vec5_t skyvec[6][4]; @@ -672,7 +673,7 @@ R_DrawSkyChain (msurface_t *sky_chain) if (gl_sky_clip->int_val > 2) { qfglDisable (GL_BLEND); qfglDisable (GL_TEXTURE_2D); - qfglColor3f (0, 0, 0); + qfglColor3ubv (color_black); while (sc) { glpoly_t *p = sc->polys; @@ -684,6 +685,7 @@ R_DrawSkyChain (msurface_t *sky_chain) } qfglEnable (GL_TEXTURE_2D); qfglEnable (GL_BLEND); + qfglColor3ubv (color_white); return; } @@ -704,7 +706,7 @@ R_DrawSkyChain (msurface_t *sky_chain) // clipped qfglDisable (GL_BLEND); qfglDisable (GL_TEXTURE_2D); - qfglColor3f (0, 0, 0); + qfglColor3ubv (color_black); while (sc) { glpoly_t *p = sc->polys; @@ -716,10 +718,12 @@ R_DrawSkyChain (msurface_t *sky_chain) } qfglEnable (GL_TEXTURE_2D); qfglEnable (GL_BLEND); + qfglColor3ubv (color_white); } #if 0 // seems to work, but this is the wrong place to do it. - qfglColor4f (1,1,1,0); + color_white[3] = 0; + qfglColor4ubv (color_white); sc = sky_chain; while (sc) { glpoly_t *p = sc->polys; @@ -735,66 +739,5 @@ R_DrawSkyChain (msurface_t *sky_chain) } sc = sc->texturechain; } -#endif - qfglColor3ubv (lighthalf_v); -#if 0 - qfglDisable (GL_TEXTURE_2D); - sc = sky_chain; - qfglColor3f (1, 1, 1); - while (sc) { - glpoly_t *p = sc->polys; - - while (p) { - int i; - - qfglBegin (GL_LINE_LOOP); - for (i = 0; i < p->numverts; i++) { - qfglVertex3fv (p->verts[i]); - } - qfglEnd (); - p = p->next; - } - sc = sc->texturechain; - } - sc = sky_chain; - qfglColor3f (0, 1, 0); - qfglBegin (GL_POINTS); - while (sc) { - glpoly_t *p = sc->polys; - - while (p) { - int i; - vec3_t x, c = { 0, 0, 0 }; - - for (i = 0; i < p->numverts; i++) { - VectorSubtract (p->verts[i], r_refdef.vieworg, x); - VectorAdd (x, c, c); - } - VectorScale (c, 1.0 / p->numverts, c); - VectorAdd (c, r_refdef.vieworg, c); - qfglVertex3fv (c); - p = p->next; - } - sc = sc->texturechain; - } - qfglEnd (); - if (skyloaded) { - int i, j; - - qfglColor3f (1, 0, 0); - for (i = 0; i < 6; i++) { - vec3_t v; - - qfglBegin (GL_LINE_LOOP); - for (j = 0; j < 4; j++) { - memcpy (v, &skyvec[i][j][2], sizeof (v)); - VectorAdd (v, r_refdef.vieworg, v); - qfglVertex3fv (v); - } - qfglEnd (); - } - } - qfglColor3ubv (lighthalf_v); - qfglEnable (GL_TEXTURE_2D); #endif } diff --git a/libs/video/renderer/r_cvar.c b/libs/video/renderer/r_cvar.c index 44df761b1..1a1117eef 100644 --- a/libs/video/renderer/r_cvar.c +++ b/libs/video/renderer/r_cvar.c @@ -123,8 +123,6 @@ cvar_t *scr_showram; cvar_t *scr_showturtle; cvar_t *scr_viewsize; -unsigned char lighthalf_v[3] = {255, 255, 255}; - void R_Init_Cvars (void) diff --git a/libs/video/renderer/r_main.c b/libs/video/renderer/r_main.c index c8ada9c33..d02302ece 100644 --- a/libs/video/renderer/r_main.c +++ b/libs/video/renderer/r_main.c @@ -29,6 +29,9 @@ int r_lineadj; qboolean r_active; float r_time1; +byte color_white[4] = { 255, 255, 255, 0 }; // alpha will be explicitly set +byte color_black[4] = { 0, 0, 0, 0 }; // alpha will be explicitly set + fire_t r_fires[MAX_FIRES];