Skip to content

Commit

Permalink
miscellaneous clean-ups:
Browse files Browse the repository at this point in the history
- better uniform name for 10 bit color lightmaps in GLSL fragSource
- 10bit color lightmap enablement checks are now done by way of the
  new read-only cvar r_lightmapwide
- cache gl_overbright.value as a boolean before use
- GLSL uniform lacations are GLint type, not GLuint
- fixes for -Wstrict-prototypes warnings
- many globals in sbar.c, view.c, r_alias.c, r_brush.c, gl_rmisc.c,
  gl_fog.c, gl_rlight.c, and r_part.c are now static. removed some
  unused globals there, too.
- minor whitespace tidy-ups.
- clarifications in changelog.
  • Loading branch information
sezero committed Sep 1, 2023
1 parent 6e4487b commit 1c94763
Show file tree
Hide file tree
Showing 19 changed files with 204 additions and 203 deletions.
4 changes: 2 additions & 2 deletions Linux/sgml/Quakespasm.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ QuakeSpasm 0.94 has support for playing the 2021 re-release content: Copy the qu
<item> Fix a potential crash after loading of saved game.
<item> Fix possible out-of-bound reads when handling progs type sizes.
<item> Fix Dutch angle VP_PARALLEL_UPRIGHT sprites.
<item> Fix an issue with blending of lights by using 10 bit color depth for lightmaps. (GLSL mode only -- disable with "-nopackedpixels", if necessary.)
<item> Enable the depth_clamp opengl extension, if available (disable with "-nodepthclamp", if necessary.)
<item> Fix an issue with lights blending by using 10 bit color depth for lightmaps. (For GLSL mode only.) Disable with "-nopackedpixels", if necessary.
<item> Enable depth_clamp opengl extension if available. Fixes issues with water surface when going in and out of water in ej3_aesop. Disable with "-nodepthclamp", if necessary.
<item> No relative motions when the window is not focused.
<item> Status bar and intermission screen tweaks.
<item> Properly display monster counts > 3 digits.
Expand Down
24 changes: 12 additions & 12 deletions Quake/gl_fog.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DEFAULT_DENSITY 0.0
#define DEFAULT_GRAY 0.3

float fog_density;
float fog_red;
float fog_green;
float fog_blue;

float old_density;
float old_red;
float old_green;
float old_blue;

float fade_time; //duration of fade
float fade_done; //time when fade will be done
static float fog_density;
static float fog_red;
static float fog_green;
static float fog_blue;

static float old_density;
static float old_red;
static float old_green;
static float old_blue;

static float fade_time; //duration of fade
static float fade_done; //time when fade will be done

/*
=============
Expand Down
13 changes: 5 additions & 8 deletions Quake/gl_refrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "quakedef.h"

mnode_t *r_pefragtopnode;
static mnode_t *r_pefragtopnode;


//===========================================================================

/*
===============================================================================
Expand All @@ -39,16 +37,16 @@ removed, so I trimmed out unused functionality and fields in efrag_t.
Now, efrags are just a linked list for each leaf of the static
entities that touch that leaf. The efrags are hunk-allocated so there is no
fixed limit.
This is inspired by MH's tutorial, and code from RMQEngine.
http://forums.insideqc.com/viewtopic.php?t=1930
===============================================================================
*/

vec3_t r_emins, r_emaxs;
static vec3_t r_emins, r_emaxs;

entity_t *r_addent;
static entity_t *r_addent;


#define EXTRA_EFRAGS 128
Expand Down Expand Up @@ -221,4 +219,3 @@ void R_StoreEfrags (efrag_t **ppefrag)
ppefrag = &pefrag->leafnext;
}
}

9 changes: 3 additions & 6 deletions Quake/gl_rlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "quakedef.h"

int r_dlightframecount;
static int r_dlightframecount;

extern cvar_t r_flatlightstyles; //johnfitz

Expand Down Expand Up @@ -129,8 +129,7 @@ void R_RenderDlights (void)
if (!gl_flashblend.value)
return;

r_dlightframecount = r_framecount + 1; // because the count hasn't
// advanced yet for this frame
r_dlightframecount = r_framecount + 1; // because the count hasn't advanced yet for this frame
glDepthMask (0);
glDisable (GL_TEXTURE_2D);
glShadeModel (GL_SMOOTH);
Expand Down Expand Up @@ -175,7 +174,6 @@ void R_MarkLights (dlight_t *light, int num, mnode_t *node)
int i, j, s, t;

start:

if (node->contents < 0)
return;

Expand Down Expand Up @@ -242,8 +240,7 @@ void R_PushDlights (void)
if (gl_flashblend.value)
return;

r_dlightframecount = r_framecount + 1; // because the count hasn't
// advanced yet for this frame
r_dlightframecount = r_framecount + 1; // because the count hasn't advanced yet for this frame
l = cl_dlights;

for (i=0 ; i<MAX_DLIGHTS ; i++, l++)
Expand Down
6 changes: 3 additions & 3 deletions Quake/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ static GLuint r_gamma_program;
static int r_gamma_texture_width, r_gamma_texture_height;

// uniforms used in gamma shader
static GLuint gammaLoc;
static GLuint contrastLoc;
static GLuint textureLoc;
static GLint gammaLoc;
static GLint contrastLoc;
static GLint textureLoc;

/*
=============
Expand Down
14 changes: 10 additions & 4 deletions Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix

extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz

cvar_t r_lightmapwide = {"r_lightmapwide","0",CVAR_ROM};


/*
====================
Expand All @@ -58,6 +60,7 @@ GL_Overbright_f -- johnfitz
*/
static void GL_Overbright_f (cvar_t *var)
{
Cvar_SetROM ("r_lightmapwide", gl_packed_pixels ? "1" : "0");
R_RebuildAllLightmaps ();
}

Expand Down Expand Up @@ -163,8 +166,6 @@ R_Init
*/
void R_Init (void)
{
extern cvar_t gl_finish;

Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);

Expand Down Expand Up @@ -219,6 +220,8 @@ void R_Init (void)
Cvar_RegisterVariable (&r_noshadow_list);
Cvar_SetCallback (&r_noshadow_list, R_Model_ExtraFlags_List_f);
//johnfitz
Cvar_RegisterVariable (&r_lightmapwide);
Cvar_SetROM ("r_lightmapwide", gl_packed_pixels ? "1" : "0");

Cvar_RegisterVariable (&gl_zfix); // QuakeSpasm z-fighting fix
Cvar_RegisterVariable (&r_lavaalpha);
Expand Down Expand Up @@ -250,8 +253,10 @@ void R_TranslatePlayerSkin (int playernum)

//FIXME: if gl_nocolors is on, then turned off, the textures may be out of sync with the scoreboard colors.
if (!gl_nocolors.value)
{
if (playertextures[playernum])
TexMgr_ReloadImage (playertextures[playernum], top, bottom);
}
}

/*
Expand Down Expand Up @@ -332,6 +337,7 @@ static void R_ParseWorldspawn (void)
return; // error
if (com_token[0] != '{')
return; // error

while (1)
{
data = COM_Parse(data);
Expand Down Expand Up @@ -584,7 +590,7 @@ void R_DeleteShaders (void)
gl_num_programs = 0;
}

GLuint current_array_buffer, current_element_array_buffer;
static GLuint current_array_buffer, current_element_array_buffer;

/*
====================
Expand Down Expand Up @@ -628,7 +634,7 @@ This must be called if you do anything that could make the cached bindings
invalid (e.g. manually binding, destroying the context).
====================
*/
void GL_ClearBufferBindings ()
void GL_ClearBufferBindings (void)
{
if (!gl_vbo_able)
return;
Expand Down
13 changes: 8 additions & 5 deletions Quake/gl_texmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "quakedef.h"

const int gl_solid_format = 3;
const int gl_alpha_format = 4;
static const int gl_solid_format = 3;
static const int gl_alpha_format = 4;

static cvar_t gl_texturemode = {"gl_texturemode", "", CVAR_ARCHIVE};
static cvar_t gl_texture_anisotropy = {"gl_texture_anisotropy", "1", CVAR_ARCHIVE};
Expand Down Expand Up @@ -1054,7 +1054,7 @@ static void TexMgr_LoadImage32 (gltexture_t *glt, unsigned *data)
mipwidth = glt->width;
mipheight = glt->height;

for (miplevel=1; mipwidth > 1 || mipheight > 1; miplevel++)
for (miplevel = 1; mipwidth > 1 || mipheight > 1; miplevel++)
{
if (mipwidth > 1)
{
Expand Down Expand Up @@ -1178,11 +1178,14 @@ TexMgr_LoadLightmap -- handles lightmap data
*/
static void TexMgr_LoadLightmap (gltexture_t *glt, byte *data)
{
const GLint internalfmt = gl_packed_pixels ? GL_RGB10_A2 : lightmap_bytes;
const GLenum type = gl_packed_pixels ? GL_UNSIGNED_INT_10_10_10_2 : GL_UNSIGNED_BYTE;
const qboolean wide10bits = !!r_lightmapwide.value;
const GLenum type = wide10bits ? GL_UNSIGNED_INT_10_10_10_2 : GL_UNSIGNED_BYTE;
const GLint internalfmt = wide10bits ? GL_RGB10_A2 : lightmap_bytes;

// upload it
GL_Bind (glt);
glTexImage2D (GL_TEXTURE_2D, 0, internalfmt, glt->width, glt->height, 0, gl_lightmap_format, type, data);

// set filter modes
TexMgr_SetFilterModes (glt);
}
Expand Down
70 changes: 33 additions & 37 deletions Quake/gl_vidsdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,28 +1211,28 @@ static void GL_CheckExtensions (void)
GL_Uniform4fFunc = (QS_PFNGLUNIFORM4FPROC) SDL_GL_GetProcAddress("glUniform4f");

if (GL_CreateShaderFunc &&
GL_DeleteShaderFunc &&
GL_DeleteProgramFunc &&
GL_ShaderSourceFunc &&
GL_CompileShaderFunc &&
GL_GetShaderivFunc &&
GL_GetShaderInfoLogFunc &&
GL_GetProgramivFunc &&
GL_GetProgramInfoLogFunc &&
GL_CreateProgramFunc &&
GL_AttachShaderFunc &&
GL_LinkProgramFunc &&
GL_BindAttribLocationFunc &&
GL_UseProgramFunc &&
GL_GetAttribLocationFunc &&
GL_VertexAttribPointerFunc &&
GL_EnableVertexAttribArrayFunc &&
GL_DisableVertexAttribArrayFunc &&
GL_GetUniformLocationFunc &&
GL_Uniform1iFunc &&
GL_Uniform1fFunc &&
GL_Uniform3fFunc &&
GL_Uniform4fFunc)
GL_DeleteShaderFunc &&
GL_DeleteProgramFunc &&
GL_ShaderSourceFunc &&
GL_CompileShaderFunc &&
GL_GetShaderivFunc &&
GL_GetShaderInfoLogFunc &&
GL_GetProgramivFunc &&
GL_GetProgramInfoLogFunc &&
GL_CreateProgramFunc &&
GL_AttachShaderFunc &&
GL_LinkProgramFunc &&
GL_BindAttribLocationFunc &&
GL_UseProgramFunc &&
GL_GetAttribLocationFunc &&
GL_VertexAttribPointerFunc &&
GL_EnableVertexAttribArrayFunc &&
GL_DisableVertexAttribArrayFunc &&
GL_GetUniformLocationFunc &&
GL_Uniform1iFunc &&
GL_Uniform1fFunc &&
GL_Uniform3fFunc &&
GL_Uniform4fFunc)
{
Con_Printf("FOUND: GLSL\n");
gl_glsl_able = true;
Expand Down Expand Up @@ -1283,22 +1283,19 @@ static void GL_CheckExtensions (void)
Con_Printf("Enabled: EXT_packed_pixels\n");
}
#if 0 /* Disabling for non-GLSL path, needs more surgery. */
else if (GL_ParseExtensionList(gl_extensions, "GL_APPLE_packed_pixels"))
{
Con_Printf("FOUND: APPLE_packed_pixels\n");
gl_packed_pixels = true;
}
else if (GL_ParseExtensionList(gl_extensions, "GL_EXT_packed_pixels"))
{
Con_Printf("FOUND: EXT_packed_pixels\n");
gl_packed_pixels = true;
}
else
{
if (GL_ParseExtensionList(gl_extensions, "GL_APPLE_packed_pixels"))
{
Con_Printf("FOUND: APPLE_packed_pixels\n");
gl_packed_pixels = true;
}
else if (GL_ParseExtensionList(gl_extensions, "GL_EXT_packed_pixels"))
{
Con_Printf("FOUND: EXT_packed_pixels\n");
gl_packed_pixels = true;
}
else
{
Con_Warning ("packed_pixels not supported\n");
}
Con_Warning ("packed_pixels not supported\n");
}
#endif

Expand Down Expand Up @@ -2415,4 +2412,3 @@ static void VID_Menu_f (void)
VID_Menu_RebuildBppList ();
VID_Menu_RebuildRateList ();
}

4 changes: 3 additions & 1 deletion Quake/glquake.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ extern cvar_t r_pos;
extern cvar_t r_waterwarp;
extern cvar_t r_fullbright;
extern cvar_t r_lightmap;
extern cvar_t r_lightmapwide;
extern cvar_t r_shadows;
extern cvar_t r_wateralpha;
extern cvar_t r_lavaalpha;
Expand All @@ -151,6 +152,7 @@ extern cvar_t gl_affinemodels;
extern cvar_t gl_polyblend;
extern cvar_t gl_flashblend;
extern cvar_t gl_nocolors;
extern cvar_t gl_finish;

extern cvar_t gl_playermip;

Expand Down Expand Up @@ -426,7 +428,7 @@ void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain);
void R_DrawWorld_Water (void);

void GL_BindBuffer (GLenum target, GLuint buffer);
void GL_ClearBufferBindings ();
void GL_ClearBufferBindings (void);

void GLSLGamma_DeleteTexture (void);
void GLSLGamma_GammaCorrect (void);
Expand Down
9 changes: 4 additions & 5 deletions Quake/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef _QUAKE_INPUT_H
#define _QUAKE_INPUT_H
#ifndef QUAKE_INPUT_H
#define QUAKE_INPUT_H

// input.h -- external (non-keyboard) input devices

Expand Down Expand Up @@ -48,10 +48,9 @@ void IN_ClearStates (void);
// restores all button and position states to defaults

// called when the app becomes active
void IN_Activate ();
void IN_Activate (void);

// called when the app becomes inactive
void IN_Deactivate (qboolean free_cursor);

#endif /* _QUAKE_INPUT_H */

#endif
Loading

0 comments on commit 1c94763

Please sign in to comment.