From c7ba1d40e5f76993ee773e2d8790313dca2628db Mon Sep 17 00:00:00 2001 From: Tyler Young Date: Sun, 22 Jan 2023 17:48:43 -0500 Subject: [PATCH] Added colored crosshair to Quakespasm Enabled facingenemy in progdefs --- source/draw.h | 1 + source/gl_draw.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ source/gl_screen.c | 21 ++++++++++++------ source/progdefs.q1 | 1 + 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/source/draw.h b/source/draw.h index 17134e9..8bea9fd 100644 --- a/source/draw.h +++ b/source/draw.h @@ -30,6 +30,7 @@ extern qpic_t *draw_disc; // also used on sbar void Draw_Init (void); void Draw_Character (int x, int y, int num); +void Draw_CharacterRGBA(int x, int y, int num, float r, float g, float b, float a); //sB void Draw_DebugChar (char num); void Draw_StretchPic (int x, int y, qpic_t *pic, int x_value, int y_value); void Draw_Pic (int x, int y, qpic_t *pic); diff --git a/source/gl_draw.c b/source/gl_draw.c index 767dfba..de5acca 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -553,6 +553,60 @@ void Draw_Character (int x, int y, int num) glEnd (); } +/* +================ +Draw_CharacterRGBA + +This is the same as Draw_Character, but with RGBA color codes. +- MotoLegacy and ported to Quakespasm by sB :) +================ +*/ +void Draw_CharacterRGBA(int x, int y, int num, float r, float g, float b, float a) +{ + int row, col; + float frow, fcol, size; + + if (y <= -8) + return; // totally off screen + + num &= 255; + + if (num == 32) + return; //don't waste verts on spaces + + glEnable (GL_BLEND); + glColor4f(r, g, b, a); + glDisable (GL_ALPHA_TEST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + GL_Bind (char_texture); + glBegin (GL_QUADS); + + row = num>>4; + col = num&15; + + frow = row*0.0625; + fcol = col*0.0625; + size = 0.0625; + + glTexCoord2f (fcol, frow); + glVertex2f (x, y); + glTexCoord2f (fcol + size, frow); + glVertex2f (x+8, y); + glTexCoord2f (fcol + size, frow + size); + glVertex2f (x+8, y+8); + glTexCoord2f (fcol, frow + size); + glVertex2f (x, y+8); + + glEnd (); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_ALPHA_TEST); + glDisable (GL_BLEND); + glColor4f (1,1,1,1); +} + + /* ================ Draw_String -- johnfitz -- modified to call Draw_CharacterQuad diff --git a/source/gl_screen.c b/source/gl_screen.c index 2d0c054..f1f3567 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -1449,6 +1449,15 @@ void SCR_DrawCrosshair (void) if (cl.stats[STAT_HEALTH] < 20 || paused_hack == true || m_state == m_exit) { return; } + + float col; + + if (sv_player->v.facingenemy == 1) { + col = 0; + } else { + col = 255; + } + #ifdef VITA GL_SetCanvas(CANVAS_HUD); #else @@ -1472,7 +1481,7 @@ void SCR_DrawCrosshair (void) if (cl.stats[STAT_ACTIVEWEAPON] == W_M2) { - Draw_Character ((vid.width)/4-4, (vid.height)*3/4, 'O'); + Draw_CharacterRGBA ((vid.width)/4-4, (vid.height)*3/4, 'O', 255, col, col, 0.7); } else if (crosshair.value == 1 && cl.stats[STAT_ZOOM] != 1 && cl.stats[STAT_ZOOM] != 2 && cl.stats[STAT_ACTIVEWEAPON] != W_PANZER) { @@ -1485,22 +1494,22 @@ void SCR_DrawCrosshair (void) x_value = ((vid.width - 8)/4) - crosshair_offset_step; y_value = (vid.height - 8)*3/4; - Draw_Character (x_value, y_value, 158); + Draw_CharacterRGBA (x_value, y_value, 158, 255, col, col, 0.7); x_value = ((vid.width - 8)/4) + crosshair_offset_step; y_value = (vid.height - 8)*3/4; - Draw_Character (x_value, y_value, 158); + Draw_CharacterRGBA (x_value, y_value, 158, 255, col, col, 0.7); x_value = ((vid.width - 8)/4); y_value = (vid.height - 8)*3/4 - crosshair_offset_step; - Draw_Character (x_value, y_value, 157); + Draw_CharacterRGBA (x_value, y_value, 157, 255, col, col, 0.7); x_value = ((vid.width - 8)/4); y_value = (vid.height - 8)*3/4 + crosshair_offset_step; - Draw_Character (x_value, y_value, 157); + Draw_CharacterRGBA (x_value, y_value, 157, 255, col, col, 0.7); } else if (crosshair.value && cl.stats[STAT_ZOOM] != 1 && cl.stats[STAT_ZOOM] != 2) - Draw_Character ((vid.width - 8)/4/* + crosshair_x*/, (vid.height - 8)*3/4/* + crosshair_y*/, '.'); + Draw_CharacterRGBA ((vid.width - 8)/4/* + crosshair_x*/, (vid.height - 8)*3/4/* + crosshair_y*/, '.', 255, col, col, 0.7); if (cl.stats[STAT_ZOOM] == 2) { Draw_AlphaStretchPic (0, 0, vid.width, vid.height, 1, sniper_scope); } diff --git a/source/progdefs.q1 b/source/progdefs.q1 index b0346f2..66a1e48 100644 --- a/source/progdefs.q1 +++ b/source/progdefs.q1 @@ -161,6 +161,7 @@ typedef struct float Flash_Size; float currentmag2; float maxspeed; + float facingenemy; float renderGrayscale; vec3_t colormod; vec3_t glowmod;