Skip to content

Commit

Permalink
scr_concolor for simple console background
Browse files Browse the repository at this point in the history
  • Loading branch information
timbergeron committed Sep 24, 2024
1 parent 7e9588a commit bba777d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
64 changes: 57 additions & 7 deletions Quake/gl_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,26 +980,43 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, plcolour_t top, plcolour
Draw_Pic (x, y, pic);
}

extern cvar_t scr_concolor; // woods #concolor

/*
================
Draw_ConsoleBackground -- johnfitz -- rewritten
Draw_ConsoleBackground -- johnfitz -- rewritten -- woods #concolor
================
*/
void Draw_ConsoleBackground (void)
{
qpic_t *pic;
float alpha;
plcolour_t conback_color;
const char* conback_str = scr_concolor.string;

// Parse the scr_conback cvar
conback_color = CL_PLColours_Parse(conback_str);

pic = Draw_CachePic ("gfx/conback.lmp");
pic->width = vid.conwidth;
pic->height = vid.conheight;
// Determine if the default background image should be used
int use_default = (conback_color.type == 0 ||
(conback_color.type == 2 &&
conback_color.rgb[0] == 0xFF &&
conback_color.rgb[1] == 0xFF &&
conback_color.rgb[2] == 0xFF));

GL_SetCanvas (CANVAS_CONSOLE); // Ensure we're drawing on the console canvas

alpha = (con_forcedup) ? 1.0f : scr_conalpha.value;

GL_SetCanvas (CANVAS_CONSOLE); //in case this is called from weird places
if (alpha <= 0.0f)
return; // Nothing to draw

if (alpha > 0.0f)
if (use_default) // Use the default background image
{
pic = Draw_CachePic ("gfx/conback.lmp");
pic->width = vid.conwidth;
pic->height = vid.conheight;

if (alpha < 1.0f)
{
if (premul_hud)
Expand Down Expand Up @@ -1027,8 +1044,41 @@ void Draw_ConsoleBackground (void)
glColor4f (1,1,1,1);
}
}
}
else
{
byte* rgb = CL_PLColours_ToRGB(&conback_color); // Render a solid color background based on scr_conback
float r, g, b;

if (rgb)
{
r = rgb[0] / 255.0f;
g = rgb[1] / 255.0f;
b = rgb[2] / 255.0f;
}
else
r = g = b = 1.0f; // Fallback to white if RGB is not available

// Set the color with alpha
glColor4f(r, g, b, alpha);

// Enable blending for transparency
glEnable (GL_BLEND);
glDisable(GL_TEXTURE_2D); // Disable texture rendering

// Draw a filled quad covering the console area
glBegin(GL_QUADS);
glVertex2f(0, 0);
glVertex2f(vid.conwidth, 0);
glVertex2f(vid.conwidth, vid.conheight);
glVertex2f(0, vid.conheight);
glEnd();

// Reset OpenGL states
glEnable(GL_TEXTURE_2D); // Re-enable textures
glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1); // Reset color
}
}

/*
=============
Expand Down
3 changes: 3 additions & 0 deletions Quake/gl_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ cvar_t gl_load24bit_skins = {"gl_load24bit_skins", "0", CVAR_ARCHIVE }; // woods
cvar_t gl_load24bit_hud = {"gl_load24bit_hud", "1", CVAR_ARCHIVE}; // woods #24bithud
void Cache_Flush_f (cvar_t* var); // woods #loadskins

cvar_t scr_concolor = {"scr_concolor", "", CVAR_ARCHIVE}; // woods #concolor

extern cvar_t r_fastturb; // woods #fastturb

static byte *mod_novis;
Expand Down Expand Up @@ -89,6 +91,7 @@ void Mod_Init (void)
Cvar_RegisterVariable (&gl_load24bit_hud); // woods #24bithud
Cvar_RegisterVariable (&mod_lightscale_broken);
Cvar_RegisterVariable (&mod_lightgrid);
Cvar_RegisterVariable (&scr_concolor); // woods #concolor

Cmd_AddCommand ("mcache", Mod_Print);

Expand Down
3 changes: 2 additions & 1 deletion Quake/gl_vidsdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,8 @@ void VID_Init (void)
"vid_desktopfullscreen",
"vid_borderless",
"gl_load24bit", //including this here so we don't start up to the wrong setting.
"gl_load24bit_hud" // woods #24bithud
"gl_load24bit_hud", // woods #24bithud
"scr_concolor" // woods #concolor
};
#define num_readvars ( sizeof(read_vars)/sizeof(read_vars[0]) )

Expand Down

0 comments on commit bba777d

Please sign in to comment.