Even more conversion, lots of superfluous macro removal

This commit is contained in:
iikorni
2026-08-29 23:14:23 -05:00
parent 70e5c02355
commit de75b014b3
102 changed files with 7060 additions and 8179 deletions
+74 -74
View File
@@ -71,7 +71,7 @@ static char *gl_extensions_nice;
static vmode_t modelist[MAX_MODE_LIST];
static int nummodes;
static qboolean vid_initialized = false;
static bool vid_initialized = false;
#if defined(USE_SDL2)
static SDL_Window *draw_context;
@@ -80,8 +80,8 @@ static SDL_GLContext gl_context;
static SDL_Surface *draw_context;
#endif
static qboolean vid_locked = false; //johnfitz
static qboolean vid_changed = false;
static bool vid_locked = false; //johnfitz
static bool vid_changed = false;
static void VID_Menu_Init(void); //johnfitz
static void VID_Menu_f(void); //johnfitz
@@ -97,21 +97,21 @@ static void GL_SetupState(void); //johnfitz
viddef_t vid; // global video state
modestate_t modestate = MS_UNINIT;
qboolean scr_skipupdate;
bool scr_skipupdate;
qboolean gl_mtexable = false;
qboolean gl_packed_pixels = false;
qboolean gl_texture_env_combine = false; //johnfitz
qboolean gl_texture_env_add = false; //johnfitz
qboolean gl_swap_control = false; //johnfitz
qboolean gl_anisotropy_able = false; //johnfitz
bool gl_mtexable = false;
bool gl_packed_pixels = false;
bool gl_texture_env_combine = false; //johnfitz
bool gl_texture_env_add = false; //johnfitz
bool gl_swap_control = false; //johnfitz
bool gl_anisotropy_able = false; //johnfitz
float gl_max_anisotropy; //johnfitz
qboolean gl_texture_NPOT = false; //ericw
qboolean gl_vbo_able = false; //ericw
qboolean gl_glsl_able = false; //ericw
bool gl_texture_NPOT = false; //ericw
bool gl_vbo_able = false; //ericw
bool gl_glsl_able = false; //ericw
GLint gl_max_texture_units = 0; //ericw
qboolean gl_glsl_gamma_able = false; //ericw
qboolean gl_glsl_alias_able = false; //ericw
bool gl_glsl_gamma_able = false; //ericw
bool gl_glsl_alias_able = false; //ericw
int gl_stencilbits;
PFNGLMULTITEXCOORD2FARBPROC GL_MTexCoord2fFunc = NULL; //johnfitz
@@ -184,7 +184,7 @@ static unsigned short vid_sysgamma_green[256];
static unsigned short vid_sysgamma_blue[256];
#endif
static qboolean gammaworks = false; // whether hw-gamma works
static bool gammaworks = false; // whether hw-gamma works
static int fsaa;
/*
@@ -396,7 +396,7 @@ VID_GetFullscreen
returns true if we are in regular fullscreen or "desktop fullscren"
====================
*/
static qboolean VID_GetFullscreen(void) {
static bool VID_GetFullscreen(void) {
#if defined(USE_SDL2)
return (SDL_GetWindowFlags(draw_context) & SDL_WINDOW_FULLSCREEN) != 0;
#else
@@ -411,7 +411,7 @@ VID_GetDesktopFullscreen
returns true if we are specifically in "desktop fullscreen" mode
====================
*/
static qboolean VID_GetDesktopFullscreen(void) {
static bool VID_GetDesktopFullscreen(void) {
#if defined(USE_SDL2)
return (SDL_GetWindowFlags(draw_context) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
#else
@@ -424,7 +424,7 @@ static qboolean VID_GetDesktopFullscreen(void) {
VID_GetVSync
====================
*/
static qboolean VID_GetVSync(void) {
static bool VID_GetVSync(void) {
#if defined(USE_SDL2)
return SDL_GL_GetSwapInterval() == 1;
#else
@@ -455,7 +455,7 @@ void *VID_GetWindow(void) {
VID_HasMouseOrInputFocus
====================
*/
qboolean VID_HasMouseOrInputFocus(void) {
bool VID_HasMouseOrInputFocus(void) {
#if defined(USE_SDL2)
return (SDL_GetWindowFlags(draw_context) & (SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_FOCUS)) != 0;
#else
@@ -468,7 +468,7 @@ qboolean VID_HasMouseOrInputFocus(void) {
VID_IsMinimized
====================
*/
qboolean VID_IsMinimized(void) {
bool VID_IsMinimized(void) {
#if defined(USE_SDL2)
return !(SDL_GetWindowFlags(draw_context) & SDL_WINDOW_SHOWN);
#else
@@ -514,7 +514,7 @@ static SDL_DisplayMode *VID_SDL2_GetDisplayMode(int width, int height, int refre
VID_ValidMode
================
*/
static qboolean VID_ValidMode(int width, int height, int refreshrate, int bpp, qboolean fullscreen) {
static bool VID_ValidMode(int width, int height, int refreshrate, int bpp, bool fullscreen) {
// ignore width / height / bpp if vid_desktopfullscreen is enabled
if (fullscreen && vid_desktopfullscreen.value)
return true;
@@ -555,7 +555,7 @@ static qboolean VID_ValidMode(int width, int height, int refreshrate, int bpp, q
VID_SetMode
================
*/
static qboolean VID_SetMode(int width, int height, int refreshrate, int bpp, qboolean fullscreen) {
static bool VID_SetMode(int width, int height, int refreshrate, int bpp, bool fullscreen) {
int temp;
Uint32 flags;
char caption[50];
@@ -570,7 +570,7 @@ static qboolean VID_SetMode(int width, int height, int refreshrate, int bpp, qbo
scr_disabled_for_loading = true;
CDAudio_Pause();
BGM_Pause();
music::pause();
/* z-buffer depth */
if (bpp == 16) {
@@ -722,7 +722,7 @@ static qboolean VID_SetMode(int width, int height, int refreshrate, int bpp, qbo
modestate = VID_GetFullscreen() ? MS_FULLSCREEN : MS_WINDOWED;
CDAudio_Resume();
BGM_Resume();
music::resume();
scr_disabled_for_loading = temp;
// fix the leftover Alt from any Alt-Tab or the like that switched us away
@@ -760,7 +760,7 @@ VID_Restart -- johnfitz -- change video modes on the fly
*/
static void VID_Restart(void) {
int width, height, refreshrate, bpp;
qboolean fullscreen;
bool fullscreen;
if (vid_locked || !vid_changed)
return;
@@ -815,7 +815,7 @@ static void VID_Restart(void) {
: (scr_conscale.value > 0)
? (int) (vid.width / scr_conscale.value)
: vid.width;
vid.conwidth = CLAMP(320, vid.conwidth, vid.width);
vid.conwidth = std::clamp(vid.conwidth, 320, vid.width);
vid.conwidth &= 0xFFFFFFF8;
vid.conheight = vid.conwidth * vid.height / vid.width;
//
@@ -944,7 +944,7 @@ static void GL_Info_f(void) {
GL_CheckExtensions
===============
*/
static qboolean GL_ParseExtensionList(const char *list, const char *name) {
static bool GL_ParseExtensionList(const char *list, const char *name) {
const char *start;
const char *where, *terminator;
@@ -972,7 +972,7 @@ static void GL_CheckExtensions(void) {
// ARB_vertex_buffer_object
//
if (COM_CheckParm("-novbo"))
if (common::check_param("-novbo").has_value())
Con_Warning("Vertex buffer objects disabled at command line\n");
else if (gl_version_major < 1 || (gl_version_major == 1 && gl_version_minor < 5))
Con_Warning("OpenGL version < 1.5, skipping ARB_vertex_buffer_object check\n");
@@ -993,7 +993,7 @@ static void GL_CheckExtensions(void) {
// multitexture
//
if (COM_CheckParm("-nomtex"))
if (common::check_param("-nomtex").has_value())
Con_Warning("Mutitexture disabled at command line\n");
else if (GL_ParseExtensionList(gl_extensions, "GL_ARB_multitexture")) {
GL_MTexCoord2fFunc = (PFNGLMULTITEXCOORD2FARBPROC) SDL_GL_GetProcAddress("glMultiTexCoord2fARB");
@@ -1015,7 +1015,7 @@ static void GL_CheckExtensions(void) {
// texture_env_combine
//
if (COM_CheckParm("-nocombine"))
if (common::check_param("-nocombine").has_value())
Con_Warning("texture_env_combine disabled at command line\n");
else if (GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_env_combine")) {
Con_Printf("FOUND: ARB_texture_env_combine\n");
@@ -1029,7 +1029,7 @@ static void GL_CheckExtensions(void) {
// texture_env_add
//
if (COM_CheckParm("-noadd"))
if (common::check_param("-noadd").has_value())
Con_Warning("texture_env_add disabled at command line\n");
else if (GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_env_add")) {
Con_Printf("FOUND: ARB_texture_env_add\n");
@@ -1110,7 +1110,7 @@ static void GL_CheckExtensions(void) {
// texture_non_power_of_two
//
if (COM_CheckParm("-notexturenpot"))
if (common::check_param("-notexturenpot").has_value())
Con_Warning("texture_non_power_of_two disabled at command line\n");
else if (GL_ParseExtensionList(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
Con_Printf("FOUND: ARB_texture_non_power_of_two\n");
@@ -1121,7 +1121,7 @@ static void GL_CheckExtensions(void) {
// GLSL
//
if (COM_CheckParm("-noglsl"))
if (common::check_param("-noglsl").has_value())
Con_Warning("GLSL disabled at command line\n");
else if (gl_version_major >= 2) {
GL_CreateShaderFunc = (QS_PFNGLCREATESHADERPROC) SDL_GL_GetProcAddress("glCreateShader");
@@ -1183,7 +1183,7 @@ static void GL_CheckExtensions(void) {
}
// GLSL gamma
//
if (COM_CheckParm("-noglslgamma"))
if (common::check_param("-noglslgamma").has_value())
Con_Warning("GLSL gamma disabled at command line\n");
else if (gl_glsl_able) {
gl_glsl_gamma_able = true;
@@ -1193,7 +1193,7 @@ static void GL_CheckExtensions(void) {
}
// GLSL alias model rendering
//
if (COM_CheckParm("-noglslalias"))
if (common::check_param("-noglslalias").has_value())
Con_Warning("GLSL alias model rendering disabled at command line\n");
else if (gl_glsl_able && gl_vbo_able && gl_max_texture_units >= 3) {
gl_glsl_alias_able = true;
@@ -1204,7 +1204,7 @@ static void GL_CheckExtensions(void) {
// packed_pixels
//
if (COM_CheckParm("-nopackedpixels"))
if (common::check_param("-nopackedpixels").has_value())
Con_Warning("EXT_packed_pixels disabled at command line\n");
else if (gl_glsl_alias_able) {
gl_packed_pixels = true;
@@ -1223,7 +1223,7 @@ static void GL_CheckExtensions(void) {
#endif
// glGenerateMipmap for warp textures
if (COM_CheckParm("-nowarpmipmaps"))
if (common::check_param("-nowarpmipmaps").has_value())
Con_Warning("glGenerateMipmap disabled at command line\n");
else {
if (gl_version_major >= 3 || GL_ParseExtensionList(gl_extensions, "GL_ARB_framebuffer_object")) {
@@ -1305,7 +1305,7 @@ static void GL_Init(void) {
//johnfitz -- intel video workarounds from Baker
if (!strcmp(gl_vendor, "Intel")) {
Con_Printf("Intel Display Adapter detected, enabling gl_clear\n");
Cbuf_AddText("gl_clear 1");
command::buffer::add_text("gl_clear 1");
}
//johnfitz
@@ -1474,7 +1474,7 @@ static void VID_InitModelist(void) {
// enumerate fullscreen modes
flags = DEFAULT_SDL_FLAGS | SDL_FULLSCREEN;
for (i = 0; i < (int) Q_COUNTOF(bpps); i++) {
for (i = 0; i < (int) std::size(bpps); i++) {
if (nummodes >= MAX_MODE_LIST)
break;
@@ -1520,9 +1520,9 @@ VID_Init
*/
void VID_Init(void) {
static char vid_center[] = "SDL_VIDEO_CENTERED=center";
int p, width, height, refreshrate, bpp;
int width, height, refreshrate, bpp;
int display_width, display_height, display_refreshrate, display_bpp;
qboolean fullscreen;
bool fullscreen;
const char *read_vars[] = {
"vid_fullscreen",
"vid_width",
@@ -1534,7 +1534,7 @@ void VID_Init(void) {
"vid_desktopfullscreen",
"vid_borderless"
};
#define num_readvars Q_COUNTOF(read_vars)
#define num_readvars std::size(read_vars)
vid_fullscreen.inscribe(); //johnfitz
vid_width.inscribe(); //johnfitz
@@ -1604,46 +1604,46 @@ void VID_Init(void) {
fullscreen = (int) vid_fullscreen.value;
fsaa = (int) vid_fsaa.value;
if (COM_CheckParm("-current")) {
if (common::check_param("-current").has_value()) {
width = display_width;
height = display_height;
refreshrate = display_refreshrate;
bpp = display_bpp;
fullscreen = true;
} else {
p = COM_CheckParm("-width");
if (p && p < com_argc - 1) {
width = Q_atoi(com_argv[p + 1]);
auto p = common::check_param("-width");
if (p.has_value() && p.value() < com_argc - 1) {
width = std::atoi(com_argv[p.value() + 1]);
if (!COM_CheckParm("-height"))
if (!common::check_param("-height").has_value())
height = width * 3 / 4;
}
p = COM_CheckParm("-height");
if (p && p < com_argc - 1) {
height = Q_atoi(com_argv[p + 1]);
p = common::check_param("-height");
if (p.has_value() && p.value() < com_argc - 1) {
height = std::atoi(com_argv[p.value() + 1]);
if (!COM_CheckParm("-width"))
if (!common::check_param("-width").has_value())
width = height * 4 / 3;
}
p = COM_CheckParm("-refreshrate");
if (p && p < com_argc - 1)
refreshrate = Q_atoi(com_argv[p + 1]);
p = common::check_param("-refreshrate");
if (p.has_value() && p.value() < com_argc - 1)
refreshrate = std::atoi(com_argv[p.value() + 1]);
p = COM_CheckParm("-bpp");
if (p && p < com_argc - 1)
bpp = Q_atoi(com_argv[p + 1]);
p = common::check_param("-bpp");
if (p.has_value() && p.value() < com_argc - 1)
bpp = std::atoi(com_argv[p.value() + 1]);
if (COM_CheckParm("-window") || COM_CheckParm("-w"))
if (common::check_param("-window").has_value() || common::check_param("-w").has_value())
fullscreen = false;
else if (COM_CheckParm("-fullscreen") || COM_CheckParm("-f"))
else if (common::check_param("-fullscreen").has_value() || common::check_param("-f").has_value())
fullscreen = true;
}
p = COM_CheckParm("-fsaa");
if (p && p < com_argc - 1)
fsaa = atoi(com_argv[p + 1]);
auto p = common::check_param("-fsaa");
if (p.has_value() && p.value() < com_argc - 1)
fsaa = atoi(com_argv[p.value() + 1]);
if (!VID_ValidMode(width, height, refreshrate, bpp, fullscreen)) {
width = (int) vid_width.value;
@@ -1706,8 +1706,8 @@ void VID_Toggle(void) {
// TODO: Clear out the dead code, reinstate the fast path using SDL_SetWindowFullscreen
// inside VID_SetMode, check window size to fix WinXP issue. This will
// keep all the mode changing code in one place.
static qboolean vid_toggle_works = false;
qboolean toggleWorked;
static bool vid_toggle_works = false;
bool toggleWorked;
#if defined(USE_SDL2)
Uint32 flags = 0;
#endif
@@ -1756,7 +1756,7 @@ void VID_Toggle(void) {
Con_DPrintf("SDL_WM_ToggleFullScreen failed, attempting VID_Restart\n");
vrestart:
vid_fullscreen.set(VID_GetFullscreen() ? "0" : "1");
Cbuf_AddText("vid_restart\n");
command::buffer::add_text("vid_restart\n");
}
}
@@ -2074,10 +2074,10 @@ static void VID_MenuKey(int key) {
VID_Menu_ChooseNextRate(1);
break;
case VID_OPT_FULLSCREEN:
Cbuf_AddText("toggle vid_fullscreen\n");
command::buffer::add_text("toggle vid_fullscreen\n");
break;
case VID_OPT_VSYNC:
Cbuf_AddText("toggle vid_vsync\n"); // kristian
command::buffer::add_text("toggle vid_vsync\n"); // kristian
break;
default:
break;
@@ -2097,10 +2097,10 @@ static void VID_MenuKey(int key) {
VID_Menu_ChooseNextRate(-1);
break;
case VID_OPT_FULLSCREEN:
Cbuf_AddText("toggle vid_fullscreen\n");
command::buffer::add_text("toggle vid_fullscreen\n");
break;
case VID_OPT_VSYNC:
Cbuf_AddText("toggle vid_vsync\n");
command::buffer::add_text("toggle vid_vsync\n");
break;
default:
break;
@@ -2122,16 +2122,16 @@ static void VID_MenuKey(int key) {
VID_Menu_ChooseNextRate(1);
break;
case VID_OPT_FULLSCREEN:
Cbuf_AddText("toggle vid_fullscreen\n");
command::buffer::add_text("toggle vid_fullscreen\n");
break;
case VID_OPT_VSYNC:
Cbuf_AddText("toggle vid_vsync\n");
command::buffer::add_text("toggle vid_vsync\n");
break;
case VID_OPT_TEST:
Cbuf_AddText("vid_test\n");
command::buffer::add_text("vid_test\n");
break;
case VID_OPT_APPLY:
Cbuf_AddText("vid_restart\n");
command::buffer::add_text("vid_restart\n");
key_dest = key_game;
m_state = m_none;
IN_Activate();