3 cvar_t crosshair_brightness = {CVAR_SAVE, "crosshair_brightness", "1"};
4 cvar_t crosshair_alpha = {CVAR_SAVE, "crosshair_alpha", "1"};
5 cvar_t crosshair_flashspeed = {CVAR_SAVE, "crosshair_flashspeed", "2"};
6 cvar_t crosshair_flashrange = {CVAR_SAVE, "crosshair_flashrange", "0.1"};
7 cvar_t crosshair_size = {CVAR_SAVE, "crosshair_size", "1"};
9 // must match NUMCROSSHAIRS in gl_draw.c
10 #define NUMCROSSHAIRS 5
12 void R_Crosshairs_Init(void)
14 Cvar_RegisterVariable(&crosshair_brightness);
15 Cvar_RegisterVariable(&crosshair_alpha);
16 Cvar_RegisterVariable(&crosshair_flashspeed);
17 Cvar_RegisterVariable(&crosshair_flashrange);
18 Cvar_RegisterVariable(&crosshair_size);
21 void DrawCrosshair(int num)
28 if (num < 0 || num >= NUMCROSSHAIRS)
30 if (cl.viewentity >= 1 && cl.viewentity <= cl.maxclients)
32 i = (cl.scores[cl.viewentity-1].colors & 0xF) << 4;
33 if (i >= 208 && i < 224) // blue
35 else if (i < 128 || i >= 224) // 128-224 are backwards ranges (bright to dark, rather than dark to bright)
40 color = (qbyte *) &d_8to24table[i];
41 if (crosshair_flashspeed.value >= 0.01f)
42 base = (sin(realtime * crosshair_flashspeed.value * (M_PI*2.0f)) * crosshair_flashrange.value);
45 scale = crosshair_brightness.value * (1.0f / 255.0f);
46 picname = va("gfx/crosshair%i.tga", num + 1);
47 pic = Draw_CachePic(picname);
49 DrawQ_Pic((vid.conwidth - pic->width * crosshair_size.value) * 0.5f, (vid.conheight - pic->height * crosshair_size.value) * 0.5f, picname, pic->width * crosshair_size.value, pic->height * crosshair_size.value, color[0] * scale + base, color[1] * scale + base, color[2] * scale + base, crosshair_alpha.value, 0);