2001-04-15 04:18:22 +00:00
|
|
|
/*
|
2013-01-24 03:15:25 +00:00
|
|
|
vid_win.c
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2013-01-24 03:15:25 +00:00
|
|
|
Win32 vid component
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
2021-03-27 11:09:37 +00:00
|
|
|
#include "QF/vid.h"
|
2013-01-24 12:11:33 +00:00
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
#include "context_win.h"
|
|
|
|
#include "d_iface.h"
|
|
|
|
#include "vid_internal.h"
|
|
|
|
#include "vid_sw.h"
|
2013-01-24 12:11:33 +00:00
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
static vid_internal_t vid_internal;
|
2013-01-24 12:11:33 +00:00
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
#if 0
|
2021-03-27 11:09:37 +00:00
|
|
|
static byte backingbuf[48 * 24];
|
2022-03-24 03:22:27 +00:00
|
|
|
#endif
|
2013-01-24 12:11:33 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
|
|
|
{
|
2022-03-24 03:22:27 +00:00
|
|
|
#if 0
|
2021-04-01 10:17:19 +00:00
|
|
|
int i, j, reps = 1, repshift = 0;
|
2013-01-24 12:11:33 +00:00
|
|
|
vrect_t rect;
|
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
if (!viddef.initialized || !win_sw_context)
|
2013-01-24 12:11:33 +00:00
|
|
|
return;
|
|
|
|
|
2021-07-11 04:33:40 +00:00
|
|
|
if (!viddef.buffer)
|
2013-01-24 12:11:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < (height << repshift); i += reps) {
|
|
|
|
for (j = 0; j < reps; j++) {
|
|
|
|
memcpy (&backingbuf[(i + j) * 24],
|
2021-07-11 04:33:40 +00:00
|
|
|
viddef.buffer + x + ((y << repshift) + i +
|
2013-01-24 12:11:33 +00:00
|
|
|
j) * viddef.rowbytes, width);
|
|
|
|
|
2021-07-11 04:33:40 +00:00
|
|
|
memcpy (viddef.buffer + x +
|
2013-01-24 12:11:33 +00:00
|
|
|
((y << repshift) + i + j) * viddef.rowbytes,
|
|
|
|
&pbitmap[(i >> repshift) * width], width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rect.x = x;
|
|
|
|
rect.y = y;
|
|
|
|
rect.width = width;
|
|
|
|
rect.height = height << repshift;
|
|
|
|
rect.next = NULL;
|
|
|
|
|
2021-07-11 04:30:52 +00:00
|
|
|
win_sw_context->update (win_sw_context, &rect);
|
2022-03-24 03:22:27 +00:00
|
|
|
#endif
|
2013-01-24 12:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
D_EndDirectRect (int x, int y, int width, int height)
|
2013-01-24 03:33:39 +00:00
|
|
|
{
|
2022-03-24 03:22:27 +00:00
|
|
|
#if 0
|
2021-04-01 10:17:19 +00:00
|
|
|
int i, j, reps = 1, repshift = 0;
|
2013-01-24 12:11:33 +00:00
|
|
|
vrect_t rect;
|
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
if (!viddef.initialized || !win_sw_context)
|
2013-01-24 12:11:33 +00:00
|
|
|
return;
|
|
|
|
|
2021-07-11 04:33:40 +00:00
|
|
|
if (!viddef.buffer)
|
2013-01-24 12:11:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < (height << repshift); i += reps) {
|
|
|
|
for (j = 0; j < reps; j++) {
|
2021-07-11 04:33:40 +00:00
|
|
|
memcpy (viddef.buffer + x +
|
2013-01-24 12:11:33 +00:00
|
|
|
((y << repshift) + i + j) * viddef.rowbytes,
|
|
|
|
&backingbuf[(i + j) * 24], width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rect.x = x;
|
|
|
|
rect.y = y;
|
|
|
|
rect.width = width;
|
|
|
|
rect.height = height << repshift;
|
|
|
|
rect.next = NULL;
|
|
|
|
|
2021-07-11 04:30:52 +00:00
|
|
|
win_sw_context->update (win_sw_context, &rect);
|
2022-03-24 03:22:27 +00:00
|
|
|
#endif
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_shutdown (void *data)
|
|
|
|
{
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "VID_shutdown\n");
|
2021-03-27 11:09:37 +00:00
|
|
|
Win_CloseDisplay ();
|
|
|
|
}
|
|
|
|
|
2022-11-14 10:39:55 +00:00
|
|
|
static v oid
|
|
|
|
Win_VID_SetPalette (byte *palette, byte *colormap)
|
|
|
|
{
|
|
|
|
viddef.colormap8 = colormap;
|
|
|
|
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
|
|
|
if (vid_internal.set_colormap) {
|
|
|
|
vid_internal.set_colormap (vid_internal.data, colormap);
|
|
|
|
}
|
|
|
|
|
|
|
|
VID_InitGamma (palette);
|
|
|
|
viddef.vid_internal->set_palette (win_sw_context, palette);
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
static void
|
|
|
|
Win_VID_Init (byte *palette, byte *colormap)
|
2021-03-27 11:09:37 +00:00
|
|
|
{
|
|
|
|
Sys_RegisterShutdown (VID_shutdown, 0);
|
|
|
|
|
|
|
|
vid_internal.gl_context = Win_GL_Context;
|
|
|
|
vid_internal.sw_context = Win_SW_Context;
|
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
vid_internal.vulkan_context = Win_Vulkan_Context;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
R_LoadModule (&vid_internal);
|
|
|
|
|
|
|
|
viddef.numpages = 1;
|
|
|
|
|
|
|
|
VID_GetWindowSize (640, 480);
|
|
|
|
Win_OpenDisplay ();
|
2021-07-11 04:30:52 +00:00
|
|
|
vid_internal.choose_visual (win_sw_context);
|
2021-03-31 06:50:10 +00:00
|
|
|
Win_SetVidMode (viddef.width, viddef.height);
|
|
|
|
Win_CreateWindow (viddef.width, viddef.height);
|
2021-07-11 04:30:52 +00:00
|
|
|
vid_internal.create_context (win_sw_context);
|
2021-03-27 11:09:37 +00:00
|
|
|
|
2022-11-14 10:39:55 +00:00
|
|
|
Win_VID_SetPalette (palette, colormap);
|
2021-03-27 11:09:37 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
2021-03-27 11:09:37 +00:00
|
|
|
viddef.width, viddef.height);
|
|
|
|
|
|
|
|
viddef.initialized = true;
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
static void
|
|
|
|
Win_VID_Init_Cvars (void)
|
2021-03-27 11:09:37 +00:00
|
|
|
{
|
|
|
|
Win_Init_Cvars ();
|
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
Win_Vulkan_Init_Cvars ();
|
|
|
|
#endif
|
|
|
|
Win_GL_Init_Cvars ();
|
2022-03-09 11:00:59 +00:00
|
|
|
Win_SW_Init_Cvars ();
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
vid_system_t vid_system = {
|
|
|
|
.init = Win_VID_Init,
|
2022-11-14 10:39:55 +00:00
|
|
|
.set_palette = Win_VID_SetPalette,
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
.init_cvars = Win_VID_Init_Cvars,
|
|
|
|
};
|
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
void
|
|
|
|
VID_SetCaption (const char *text)
|
|
|
|
{
|
|
|
|
if (text && *text) {
|
|
|
|
char *temp = strdup (text);
|
|
|
|
|
|
|
|
Win_SetCaption (va (0, "%s: %s", PACKAGE_STRING, temp));
|
|
|
|
free (temp);
|
|
|
|
} else {
|
|
|
|
Win_SetCaption (va (0, "%s", PACKAGE_STRING));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean
|
|
|
|
VID_SetGamma (double gamma)
|
|
|
|
{
|
|
|
|
return Win_SetGamma (gamma);
|
2013-01-24 03:33:39 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 12:11:33 +00:00
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
#if 0
|
2013-01-24 03:33:39 +00:00
|
|
|
void
|
|
|
|
VID_Update (vrect_t *rects)
|
|
|
|
{
|
2013-01-24 12:11:33 +00:00
|
|
|
vrect_t rect;
|
|
|
|
RECT trect;
|
|
|
|
|
|
|
|
if (firstupdate) {
|
|
|
|
if (modestate == MS_WINDOWED) {
|
2021-03-27 11:09:37 +00:00
|
|
|
GetWindowRect (win_mainwindow, &trect);
|
2013-01-24 12:11:33 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if ((trect.left != vid_window_x) ||
|
|
|
|
(trect.top != vid_window_y)) {
|
2013-01-24 12:11:33 +00:00
|
|
|
if (COM_CheckParm ("-resetwinpos")) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
vid_window_x = 0.0;
|
|
|
|
vid_window_y = 0.0;
|
2013-01-24 12:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VID_CheckWindowXY ();
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
SetWindowPos (win_mainwindow, NULL, vid_window_x,
|
|
|
|
vid_window_y, 0, 0,
|
2013-01-24 12:11:33 +00:00
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW |
|
|
|
|
SWP_DRAWFRAME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if ((_vid_default_mode_win != vid_default) &&
|
2013-01-24 12:11:33 +00:00
|
|
|
(!startwindowed
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
|| (_vid_default_mode_win < MODE_FULLSCREEN_DEFAULT))) {
|
2013-01-24 12:11:33 +00:00
|
|
|
firstupdate = 0;
|
|
|
|
|
|
|
|
if (COM_CheckParm ("-resetwinpos")) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
vid_window_x = 0.0;
|
|
|
|
vid_window_y = 0.0;
|
2013-01-24 12:11:33 +00:00
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if ((_vid_default_mode_win < 0) ||
|
|
|
|
(_vid_default_mode_win >= nummodes)) {
|
|
|
|
_vid_default_mode_win = windowed_default;
|
2013-01-24 12:11:33 +00:00
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
vid_mode = _vid_default_mode_win;
|
2013-01-24 12:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// We've drawn the frame; copy it to the screen
|
|
|
|
FlipScreen (rects);
|
|
|
|
|
|
|
|
// check for a driver change
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if ((vid_ddraw && !vid_usingddraw)
|
|
|
|
|| (!vid_ddraw && vid_usingddraw)) {
|
2013-01-24 12:11:33 +00:00
|
|
|
// reset the mode
|
|
|
|
force_mode_set = true;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
VID_SetMode (vid_mode, vid_curpal);
|
2013-01-24 12:11:33 +00:00
|
|
|
force_mode_set = false;
|
|
|
|
|
|
|
|
// store back
|
|
|
|
if (vid_usingddraw)
|
|
|
|
Sys_Printf ("loaded DirectDraw driver\n");
|
|
|
|
else
|
|
|
|
Sys_Printf ("loaded GDI driver\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vid_testingmode) {
|
|
|
|
if (Sys_DoubleTime () >= vid_testendtime) {
|
|
|
|
VID_SetMode (vid_realmode, vid_curpal);
|
|
|
|
vid_testingmode = 0;
|
|
|
|
}
|
|
|
|
} else {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (vid_mode != vid_realmode) {
|
|
|
|
VID_SetMode (vid_mode, vid_curpal);
|
|
|
|
vid_mode = vid_modenum;
|
2013-01-24 12:11:33 +00:00
|
|
|
// so if mode set fails, we don't keep on
|
|
|
|
// trying to set that mode
|
|
|
|
vid_realmode = vid_modenum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle the mouse state when windowed if that's changed
|
|
|
|
if (modestate == MS_WINDOWED) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (_windowed_mouse != windowed_mouse) {
|
|
|
|
if (_windowed_mouse) {
|
2013-01-24 12:11:33 +00:00
|
|
|
IN_ActivateMouse ();
|
|
|
|
IN_HideMouse ();
|
|
|
|
} else {
|
|
|
|
IN_DeactivateMouse ();
|
|
|
|
IN_ShowMouse ();
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
windowed_mouse = _windowed_mouse;
|
2013-01-24 12:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-08-13 18:17:30 +00:00
|
|
|
#endif
|