2021-03-27 11:09:37 +00:00
|
|
|
/*
|
|
|
|
vid_win.c
|
|
|
|
|
|
|
|
Win32 vid component
|
|
|
|
|
|
|
|
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 "winquake.h"
|
|
|
|
#include <ddraw.h>
|
|
|
|
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
#include "QF/vid.h"
|
|
|
|
|
|
|
|
#include "context_win.h"
|
|
|
|
#include "r_shared.h"
|
|
|
|
#include "vid_internal.h"
|
|
|
|
#include "vid_sw.h"
|
|
|
|
|
|
|
|
HWND win_mainwindow;
|
|
|
|
HDC win_maindc;
|
|
|
|
int win_palettized;
|
2021-03-31 01:36:30 +00:00
|
|
|
int win_minimized;
|
2021-03-27 11:09:37 +00:00
|
|
|
int win_canalttab = 0;
|
|
|
|
sw_ctx_t *win_sw_context;
|
|
|
|
|
|
|
|
#define MODE_WINDOWED 0
|
|
|
|
#define MODE_SETTABLE_WINDOW 2
|
|
|
|
#define NO_MODE (MODE_WINDOWED - 1)
|
|
|
|
#define MODE_FULLSCREEN_DEFAULT (MODE_WINDOWED + 3)
|
|
|
|
|
[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
|
|
|
int vid_ddraw;
|
|
|
|
static cvar_t vid_ddraw_cvar = {
|
|
|
|
.name = "vid_ddraw",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_ddraw },
|
|
|
|
};
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
// Note that 0 is MODE_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
|
|
|
static int vid_mode;
|
|
|
|
static cvar_t vid_mode_cvar = {
|
|
|
|
.name = "vid_mode",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_mode },
|
|
|
|
};
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
// Note that 0 is MODE_WINDOWED
|
2022-04-24 11:04:06 +00:00
|
|
|
int _vid_default_mode;
|
[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 cvar_t _vid_default_mode_cvar = {
|
|
|
|
.name = "_vid_default_mode",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &_vid_default_mode },
|
[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
|
|
|
};
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
// Note that 3 is MODE_FULLSCREEN_DEFAULT
|
[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 int _vid_default_mode_win;
|
|
|
|
static cvar_t _vid_default_mode_win_cvar = {
|
|
|
|
.name = "_vid_default_mode_win",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "3",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &_vid_default_mode_win },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int vid_wait;
|
[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 cvar_t vid_wait_cvar = {
|
|
|
|
.name = "vid_wait",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &vid_wait },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int vid_nopageflip;
|
[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 cvar_t vid_nopageflip_cvar = {
|
|
|
|
.name = "vid_nopageflip",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &vid_nopageflip },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int _vid_wait_override;
|
[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 cvar_t _vid_wait_override_cvar = {
|
|
|
|
.name = "_vid_wait_override",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &_vid_wait_override },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int vid_config_x;
|
[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 cvar_t vid_config_x_cvar = {
|
|
|
|
.name = "vid_config_x",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "800",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &vid_config_x },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int vid_config_y;
|
[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 cvar_t vid_config_y_cvar = {
|
|
|
|
.name = "vid_config_y",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "600",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &vid_config_y },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int vid_stretch_by_2;
|
[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 cvar_t vid_stretch_by_2_cvar = {
|
|
|
|
.name = "vid_stretch_by_2",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &vid_stretch_by_2 },
|
[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 int _windowed_mouse;
|
|
|
|
static cvar_t _windowed_mouse_cvar = {
|
|
|
|
.name = "_windowed_mouse",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &_windowed_mouse },
|
|
|
|
};
|
|
|
|
static int vid_fullscreen_mode;
|
|
|
|
static cvar_t vid_fullscreen_mode_cvar = {
|
|
|
|
.name = "vid_fullscreen_mode",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "3",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_fullscreen_mode },
|
|
|
|
};
|
|
|
|
static int vid_windowed_mode;
|
|
|
|
static cvar_t vid_windowed_mode_cvar = {
|
|
|
|
.name = "vid_windowed_mode",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_windowed_mode },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int block_switch;
|
[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 cvar_t block_switch_cvar = {
|
|
|
|
.name = "block_switch",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &block_switch },
|
[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 int vid_window_x;
|
|
|
|
static cvar_t vid_window_x_cvar = {
|
|
|
|
.name = "vid_window_x",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_window_x },
|
|
|
|
};
|
|
|
|
static int vid_window_y;
|
|
|
|
static cvar_t vid_window_y_cvar = {
|
|
|
|
.name = "vid_window_y",
|
|
|
|
.description =
|
|
|
|
"",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_window_y },
|
|
|
|
};
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
//FIXME?int yeahimconsoled;
|
|
|
|
|
|
|
|
#define MAX_MODE_LIST 36
|
|
|
|
#define VID_ROW_SIZE 3
|
|
|
|
|
2021-03-31 01:36:30 +00:00
|
|
|
static DWORD WindowStyle, ExWindowStyle;
|
2021-03-27 11:09:37 +00:00
|
|
|
|
2021-03-31 04:32:17 +00:00
|
|
|
int win_center_x, win_center_y;
|
|
|
|
RECT win_rect;
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
DEVMODE win_gdevmode;
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool startwindowed = 0;
|
|
|
|
//static bool windowed_mode_set;
|
2021-03-31 06:50:10 +00:00
|
|
|
//static int vid_fulldib_on_focus_mode;
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool force_minimized;
|
|
|
|
static bool force_mode_set;
|
|
|
|
static bool vid_mode_set;
|
2021-03-31 06:50:10 +00:00
|
|
|
//static HICON hIcon;
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
int vid_modenum = NO_MODE;
|
|
|
|
int vid_testingmode, vid_realmode;
|
|
|
|
double vid_testendtime;
|
|
|
|
int vid_default = MODE_WINDOWED;
|
|
|
|
static int windowed_default;
|
|
|
|
|
|
|
|
modestate_t modestate = MS_UNINIT;
|
|
|
|
|
|
|
|
byte vid_curpal[256 * 3];
|
|
|
|
|
|
|
|
int mode;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
modestate_t type;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int modenum;
|
|
|
|
int fullscreen;
|
|
|
|
char modedesc[13];
|
|
|
|
} vmode_t;
|
|
|
|
|
2021-03-31 04:32:17 +00:00
|
|
|
static vmode_t modelist[MAX_MODE_LIST] = {
|
|
|
|
{
|
|
|
|
.type = MS_WINDOWED,
|
|
|
|
.width = 320,
|
|
|
|
.height = 240,
|
|
|
|
.modedesc = "320x240",
|
|
|
|
.modenum = MODE_WINDOWED,
|
|
|
|
.fullscreen = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = MS_WINDOWED,
|
|
|
|
.width = 640,
|
|
|
|
.height = 480,
|
|
|
|
.modedesc = "640x480",
|
|
|
|
.modenum = MODE_WINDOWED + 1,
|
|
|
|
.fullscreen = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = MS_WINDOWED,
|
|
|
|
.width = 800,
|
|
|
|
.height = 600,
|
|
|
|
.modedesc = "800x600",
|
|
|
|
.modenum = MODE_WINDOWED + 2,
|
|
|
|
.fullscreen = 0,
|
|
|
|
}
|
|
|
|
};
|
2021-03-27 11:09:37 +00:00
|
|
|
static int nummodes;
|
|
|
|
|
|
|
|
int aPage; // Current active display page
|
|
|
|
int vPage; // Current visible display page
|
|
|
|
int waitVRT = true; // True to wait for retrace on flip
|
|
|
|
|
2021-03-30 11:09:13 +00:00
|
|
|
static vmode_t badmode = {
|
|
|
|
.modedesc = "Bad mode",
|
|
|
|
};
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
static int VID_SetMode (int modenum, const byte *palette);
|
|
|
|
|
|
|
|
static void __attribute__ ((used))
|
|
|
|
VID_RememberWindowPos (void)
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
if (GetWindowRect (win_mainwindow, &rect)) {
|
|
|
|
if ((rect.left < GetSystemMetrics (SM_CXSCREEN)) &&
|
|
|
|
(rect.top < GetSystemMetrics (SM_CYSCREEN)) &&
|
|
|
|
(rect.right > 0) && (rect.bottom > 0)) {
|
[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 = rect.left;
|
|
|
|
vid_window_y = rect.top;
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-31 06:50:10 +00:00
|
|
|
#if 0
|
2021-03-27 11:09:37 +00:00
|
|
|
static void
|
|
|
|
VID_CheckWindowXY (void)
|
|
|
|
{
|
[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_window_x > (GetSystemMetrics (SM_CXSCREEN) - 160)) ||
|
|
|
|
(vid_window_y > (GetSystemMetrics (SM_CYSCREEN) - 120)) ||
|
|
|
|
(vid_window_x < 0) || (vid_window_y < 0)) {
|
|
|
|
vid_window_x = 0.0;
|
|
|
|
vid_window_y = 0.0;
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-31 06:50:10 +00:00
|
|
|
#endif
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Win_UpdateWindowStatus (int window_x, int window_y)
|
|
|
|
{
|
2021-03-31 04:32:17 +00:00
|
|
|
win_rect.left = window_x;
|
|
|
|
win_rect.top = window_y;
|
|
|
|
win_rect.right = window_x + viddef.width;
|
|
|
|
win_rect.bottom = window_y + viddef.height;
|
|
|
|
win_center_x = (win_rect.left + win_rect.right) / 2;
|
|
|
|
win_center_y = (win_rect.top + win_rect.bottom) / 2;
|
2021-03-27 11:09:37 +00:00
|
|
|
IN_UpdateClipCursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool
|
2021-03-27 11:09:37 +00:00
|
|
|
VID_CheckAdequateMem (int width, int height)
|
|
|
|
{
|
|
|
|
// there will always be enough ;)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_InitModes (HINSTANCE hInstance)
|
|
|
|
{
|
|
|
|
WNDCLASS wc;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
//FIXME hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON2));
|
|
|
|
|
|
|
|
/* Register the frame class */
|
|
|
|
wc.style = CS_OWNDC;
|
|
|
|
wc.lpfnWndProc = (WNDPROC) MainWndProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = hInstance;
|
|
|
|
wc.hIcon = 0;
|
|
|
|
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
|
|
|
wc.hbrBackground = NULL;
|
|
|
|
wc.lpszMenuName = 0;
|
|
|
|
wc.lpszClassName = "WinQuake";
|
|
|
|
|
|
|
|
if (!RegisterClass (&wc))
|
|
|
|
Sys_Error ("Couldn't register window class");
|
|
|
|
|
|
|
|
// automatically stretch the default mode up if > 640x480 desktop
|
|
|
|
// resolution
|
|
|
|
hdc = GetDC (NULL);
|
|
|
|
|
|
|
|
if ((GetDeviceCaps (hdc, HORZRES) > 800)
|
|
|
|
&& !COM_CheckParm ("-noautostretch")) {
|
|
|
|
vid_default = MODE_WINDOWED + 2;
|
|
|
|
} else if ((GetDeviceCaps (hdc, HORZRES) > 640)
|
|
|
|
&& !COM_CheckParm ("-noautostretch")) {
|
|
|
|
vid_default = MODE_WINDOWED + 1;
|
|
|
|
} else {
|
|
|
|
vid_default = MODE_WINDOWED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// always start at the lowest mode then switch to the higher one if
|
|
|
|
// selected
|
|
|
|
vid_default = MODE_WINDOWED;
|
|
|
|
|
|
|
|
windowed_default = vid_default;
|
|
|
|
ReleaseDC (NULL, hdc);
|
|
|
|
nummodes = 3; // reserve space for windowed mode
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_GetDisplayModes (void)
|
|
|
|
{
|
|
|
|
DEVMODE devmode;
|
|
|
|
int i, modenum, existingmode, originalnummodes, lowestres;
|
|
|
|
BOOL stat;
|
|
|
|
|
|
|
|
// enumerate > 8 bpp modes
|
|
|
|
originalnummodes = nummodes;
|
|
|
|
modenum = 0;
|
|
|
|
lowestres = 99999;
|
|
|
|
|
|
|
|
do {
|
|
|
|
stat = EnumDisplaySettings (NULL, modenum, &devmode);
|
|
|
|
|
|
|
|
if ((devmode.dmPelsWidth <= MAXWIDTH)
|
|
|
|
&& (devmode.dmPelsHeight <= MAXHEIGHT)
|
|
|
|
&& (devmode.dmPelsWidth >= 320)
|
|
|
|
&& (devmode.dmPelsHeight >= 240)
|
|
|
|
&& (nummodes < MAX_MODE_LIST)) {
|
|
|
|
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
|
|
|
|
|
if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) ==
|
|
|
|
DISP_CHANGE_SUCCESSFUL) {
|
|
|
|
modelist[nummodes].type = MS_FULLDIB;
|
|
|
|
modelist[nummodes].width = devmode.dmPelsWidth;
|
|
|
|
modelist[nummodes].height = devmode.dmPelsHeight;
|
|
|
|
modelist[nummodes].modenum = 0;
|
|
|
|
modelist[nummodes].fullscreen = 1;
|
|
|
|
sprintf (modelist[nummodes].modedesc, "%dx%d",
|
|
|
|
(int) devmode.dmPelsWidth,
|
|
|
|
(int) devmode.dmPelsHeight);
|
|
|
|
|
|
|
|
// see is the mode already there
|
|
|
|
// (same dimensions but different refresh rate)
|
|
|
|
for (i = originalnummodes, existingmode = 0;
|
|
|
|
i < nummodes; i++) {
|
|
|
|
if ((modelist[nummodes].width == modelist[i].width)
|
|
|
|
&& (modelist[nummodes].height == modelist[i].height)) {
|
|
|
|
existingmode = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if it's not add it to the list
|
|
|
|
if (!existingmode) {
|
|
|
|
if (modelist[nummodes].width < lowestres)
|
|
|
|
lowestres = modelist[nummodes].width;
|
|
|
|
|
|
|
|
nummodes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
modenum++;
|
|
|
|
} while (stat);
|
|
|
|
|
|
|
|
if (nummodes != originalnummodes)
|
|
|
|
vid_default = MODE_FULLSCREEN_DEFAULT;
|
|
|
|
else
|
|
|
|
Sys_Printf ("No fullscreen DIB modes found\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Win_OpenDisplay (void)
|
|
|
|
{
|
|
|
|
VID_InitModes (global_hInstance);
|
|
|
|
VID_GetDisplayModes ();
|
|
|
|
|
|
|
|
vid_testingmode = 0;
|
|
|
|
|
|
|
|
// if (COM_CheckParm("-startwindowed"))
|
|
|
|
{
|
|
|
|
startwindowed = 1;
|
|
|
|
vid_default = windowed_default;
|
|
|
|
}
|
|
|
|
|
2021-03-31 06:50:10 +00:00
|
|
|
#ifdef SPLASH_SCREEN
|
|
|
|
if (hwnd_dialog)
|
|
|
|
DestroyWindow (hwnd_dialog);
|
|
|
|
#endif
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Win_CloseDisplay (void)
|
|
|
|
{
|
|
|
|
if (viddef.initialized) {
|
|
|
|
if (modestate == MS_FULLDIB) {
|
|
|
|
ChangeDisplaySettings (NULL, CDS_FULLSCREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
PostMessage (HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM) win_mainwindow,
|
|
|
|
(LPARAM) 0);
|
|
|
|
PostMessage (HWND_BROADCAST, WM_SYSCOLORCHANGE, (WPARAM) 0, (LPARAM) 0);
|
2021-03-31 01:36:30 +00:00
|
|
|
Win_Activate (false, false);
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
//FIXME? if (hwnd_dialog) DestroyWindow (hwnd_dialog);
|
|
|
|
if (win_mainwindow)
|
|
|
|
DestroyWindow (win_mainwindow);
|
|
|
|
|
|
|
|
vid_testingmode = 0;
|
|
|
|
viddef.initialized = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-03-31 06:50:10 +00:00
|
|
|
Win_SetVidMode (int width, int height)
|
2021-03-27 11:09:37 +00:00
|
|
|
{
|
|
|
|
//FIXME SCR_StretchInit();
|
|
|
|
|
|
|
|
force_mode_set = true;
|
2021-03-31 06:50:10 +00:00
|
|
|
//VID_SetMode (vid_default, palette);
|
2021-03-27 11:09:37 +00:00
|
|
|
force_mode_set = false;
|
|
|
|
vid_realmode = vid_modenum;
|
|
|
|
}
|
2021-03-31 06:50:10 +00:00
|
|
|
#if 0
|
2021-03-27 11:09:37 +00:00
|
|
|
static void
|
|
|
|
VID_DestroyWindow (void)
|
|
|
|
{
|
|
|
|
if (modestate == MS_FULLDIB)
|
|
|
|
ChangeDisplaySettings (NULL, CDS_FULLSCREEN);
|
|
|
|
|
|
|
|
Win_UnloadAllDrivers ();
|
|
|
|
}
|
2021-03-31 06:50:10 +00:00
|
|
|
#endif
|
2021-03-27 11:09:37 +00:00
|
|
|
static void
|
|
|
|
VID_CheckModedescFixup (int mode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool
|
2021-03-27 11:09:37 +00:00
|
|
|
VID_SetWindowedMode (int modenum)
|
|
|
|
{
|
2021-03-31 06:50:10 +00:00
|
|
|
#if 0
|
2021-03-27 11:09:37 +00:00
|
|
|
if (!windowed_mode_set) {
|
|
|
|
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;
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
windowed_mode_set = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
VID_CheckModedescFixup (modenum);
|
|
|
|
VID_DestroyWindow ();
|
|
|
|
|
|
|
|
DIBWidth = modelist[modenum].width;
|
|
|
|
DIBHeight = modelist[modenum].height;
|
|
|
|
|
|
|
|
WindowStyle = WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX |
|
|
|
|
WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS |
|
|
|
|
WS_CLIPCHILDREN | WS_THICKFRAME;
|
|
|
|
|
|
|
|
// WindowStyle = WS_OVERLAPPEDWINDOW|WS_VISIBLE;
|
|
|
|
ExWindowStyle = 0;
|
|
|
|
|
|
|
|
// the first time we're called to set the mode, create the window we'll use
|
|
|
|
// for the rest of the session
|
|
|
|
if (!vid_mode_set) {
|
|
|
|
} else {
|
|
|
|
SetWindowLong (win_mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE);
|
|
|
|
SetWindowLong (win_mainwindow, GWL_EXSTYLE, ExWindowStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetWindowPos (win_mainwindow,
|
|
|
|
NULL,
|
|
|
|
0, 0,
|
|
|
|
WindowRect.right - WindowRect.left,
|
|
|
|
WindowRect.bottom - WindowRect.top,
|
|
|
|
SWP_NOCOPYBITS | SWP_NOZORDER | SWP_HIDEWINDOW)) {
|
|
|
|
Sys_Error ("Couldn't resize DIB window");
|
|
|
|
}
|
|
|
|
|
|
|
|
// position and show the DIB window
|
|
|
|
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,
|
2021-03-27 11:09:37 +00:00
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME);
|
|
|
|
|
|
|
|
if (force_minimized)
|
|
|
|
ShowWindow (win_mainwindow, SW_MINIMIZE);
|
|
|
|
else
|
|
|
|
ShowWindow (win_mainwindow, SW_SHOWDEFAULT);
|
|
|
|
|
|
|
|
UpdateWindow (win_mainwindow);
|
|
|
|
modestate = MS_WINDOWED;
|
|
|
|
vid_fulldib_on_focus_mode = 0;
|
|
|
|
|
|
|
|
viddef.numpages = 1;
|
|
|
|
|
|
|
|
// viddef.height = viddef.conheight = DIBHeight;
|
|
|
|
// viddef.width = viddef.conwidth = DIBWidth;
|
|
|
|
|
|
|
|
viddef.height = viddef.conheight = DIBHeight;
|
|
|
|
viddef.width = viddef.conwidth = DIBWidth;
|
|
|
|
//FIXME? if (!yeahimconsoled){
|
|
|
|
//FIXME? viddef.vconheight = DIBHeight;
|
|
|
|
//FIXME? viddef.vconwidth = DIBWidth;
|
|
|
|
//FIXME? }
|
|
|
|
SendMessage (win_mainwindow, WM_SETICON, (WPARAM) TRUE, (LPARAM) hIcon);
|
|
|
|
SendMessage (win_mainwindow, WM_SETICON, (WPARAM) FALSE, (LPARAM) hIcon);
|
2021-03-31 06:50:10 +00:00
|
|
|
#endif
|
2021-03-27 11:09:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool
|
2021-03-27 11:09:37 +00:00
|
|
|
VID_SetFullDIBMode (int modenum)
|
|
|
|
{
|
2021-03-31 06:50:10 +00:00
|
|
|
#if 0
|
2021-03-27 11:09:37 +00:00
|
|
|
VID_DestroyWindow ();
|
|
|
|
|
|
|
|
win_gdevmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
|
win_gdevmode.dmPelsWidth = modelist[modenum].width;
|
|
|
|
win_gdevmode.dmPelsHeight = modelist[modenum].height;
|
|
|
|
win_gdevmode.dmSize = sizeof (win_gdevmode);
|
|
|
|
|
|
|
|
if (ChangeDisplaySettings (&win_gdevmode, CDS_FULLSCREEN) !=
|
|
|
|
DISP_CHANGE_SUCCESSFUL)
|
|
|
|
Sys_Error ("Couldn't set fullscreen DIB mode");
|
|
|
|
|
|
|
|
modestate = MS_FULLDIB;
|
|
|
|
vid_fulldib_on_focus_mode = modenum;
|
|
|
|
|
2021-03-31 06:50:10 +00:00
|
|
|
WindowRect.top = WindowRect.left = 0;
|
2021-03-27 11:09:37 +00:00
|
|
|
WindowRect.right = modelist[modenum].width;
|
|
|
|
WindowRect.bottom = modelist[modenum].height;
|
|
|
|
|
|
|
|
DIBWidth = modelist[modenum].width;
|
|
|
|
DIBHeight = modelist[modenum].height;
|
|
|
|
|
|
|
|
WindowStyle = WS_POPUP | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
|
|
|
ExWindowStyle = 0;
|
|
|
|
|
|
|
|
AdjustWindowRectEx (&WindowRect, WindowStyle, FALSE, 0);
|
|
|
|
|
|
|
|
SetWindowLong (win_mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE);
|
|
|
|
SetWindowLong (win_mainwindow, GWL_EXSTYLE, ExWindowStyle);
|
|
|
|
|
|
|
|
if (!SetWindowPos (win_mainwindow,
|
|
|
|
NULL,
|
|
|
|
0, 0,
|
|
|
|
WindowRect.right - WindowRect.left,
|
|
|
|
WindowRect.bottom - WindowRect.top,
|
|
|
|
SWP_NOCOPYBITS | SWP_NOZORDER)) {
|
|
|
|
Sys_Error ("Couldn't resize DIB window");
|
|
|
|
}
|
|
|
|
// position and show the DIB window
|
|
|
|
SetWindowPos (win_mainwindow, HWND_TOPMOST, 0, 0, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_SHOWWINDOW | SWP_DRAWFRAME);
|
|
|
|
ShowWindow (win_mainwindow, SW_SHOWDEFAULT);
|
|
|
|
UpdateWindow (win_mainwindow);
|
|
|
|
|
|
|
|
viddef.numpages = 1;
|
|
|
|
|
|
|
|
#ifdef SCALED2D
|
|
|
|
viddef.height = viddef.conheight = DIBHeight;
|
|
|
|
viddef.width = viddef.conwidth = DIBWidth;
|
|
|
|
// viddef.vconwidth = 320;
|
|
|
|
// viddef.vconheight = 200;
|
|
|
|
//FIXME? if (!yeahimconsoled){
|
|
|
|
//FIXME? viddef.vconheight = DIBHeight;
|
|
|
|
//FIXME? viddef.vconwidth = DIBWidth;
|
|
|
|
//FIXME? }
|
|
|
|
#else
|
|
|
|
viddef.height = viddef.conheight = DIBHeight;
|
|
|
|
viddef.width = viddef.conwidth = DIBWidth;
|
|
|
|
#endif
|
2021-03-31 06:50:10 +00:00
|
|
|
#endif
|
2021-03-27 11:09:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_RestoreOldMode (int original_mode)
|
|
|
|
{
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool inerror = false;
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
if (inerror)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inerror = true;
|
|
|
|
// make sure mode set happens (video mode changes)
|
|
|
|
vid_modenum = original_mode - 1;
|
|
|
|
|
|
|
|
if (!VID_SetMode (original_mode, vid_curpal)) {
|
|
|
|
vid_modenum = MODE_WINDOWED - 1;
|
|
|
|
|
|
|
|
if (!VID_SetMode (windowed_default, vid_curpal))
|
|
|
|
Sys_Error ("Can't set any video mode");
|
|
|
|
}
|
|
|
|
|
|
|
|
inerror = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void __attribute__ ((used))
|
|
|
|
VID_SetDefaultMode (void)
|
|
|
|
{
|
|
|
|
if (viddef.initialized)
|
|
|
|
VID_SetMode (0, vid_curpal);
|
|
|
|
|
|
|
|
IN_DeactivateMouse ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static vmode_t *
|
|
|
|
VID_GetModePtr (int modenum)
|
|
|
|
{
|
|
|
|
if ((modenum >= 0) && (modenum < nummodes))
|
|
|
|
return &modelist[modenum];
|
|
|
|
else
|
|
|
|
return &badmode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
VID_GetModeDescription (int mode)
|
|
|
|
{
|
|
|
|
char *pinfo;
|
|
|
|
vmode_t *pv;
|
|
|
|
|
|
|
|
if ((mode < 0) || (mode >= nummodes))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
VID_CheckModedescFixup (mode);
|
|
|
|
pv = VID_GetModePtr (mode);
|
|
|
|
pinfo = pv->modedesc;
|
|
|
|
return pinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
VID_SetMode (int modenum, const byte *palette)
|
|
|
|
{
|
|
|
|
int original_mode; // FIXME, temp;
|
2023-06-13 09:06:11 +00:00
|
|
|
bool stat;
|
2021-03-27 11:09:37 +00:00
|
|
|
MSG msg;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
while ((modenum >= nummodes) || (modenum < 0)) {
|
|
|
|
if (vid_modenum == NO_MODE) {
|
|
|
|
if (modenum == vid_default) {
|
|
|
|
modenum = windowed_default;
|
|
|
|
} else {
|
|
|
|
modenum = vid_default;
|
|
|
|
}
|
|
|
|
|
[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 = modenum;
|
2021-03-27 11:09:37 +00:00
|
|
|
} 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
|
|
|
vid_mode = vid_modenum;
|
2021-03-27 11:09:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!force_mode_set && (modenum == vid_modenum))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
//FIXME CDAudio_Pause ();
|
|
|
|
//FIXME S_ClearBuffer ();
|
|
|
|
|
|
|
|
if (vid_modenum == NO_MODE)
|
|
|
|
original_mode = windowed_default;
|
|
|
|
else
|
|
|
|
original_mode = vid_modenum;
|
|
|
|
|
|
|
|
// Set either the fullscreen or windowed mode
|
|
|
|
if (modelist[modenum].type == 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) {
|
2021-03-27 11:09:37 +00:00
|
|
|
stat = VID_SetWindowedMode (modenum);
|
|
|
|
IN_ActivateMouse ();
|
|
|
|
IN_HideMouse ();
|
|
|
|
} else {
|
|
|
|
IN_DeactivateMouse ();
|
|
|
|
IN_ShowMouse ();
|
|
|
|
stat = VID_SetWindowedMode (modenum);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
stat = VID_SetFullDIBMode (modenum);
|
|
|
|
IN_ActivateMouse ();
|
|
|
|
IN_HideMouse ();
|
|
|
|
}
|
|
|
|
|
|
|
|
Win_UpdateWindowStatus (0, 0); // FIXME right numbers?
|
|
|
|
//FIXME CDAudio_Resume ();
|
|
|
|
|
|
|
|
if (!stat) {
|
|
|
|
VID_RestoreOldMode (original_mode);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// now we try to make sure we get the focus on the mode switch, because
|
|
|
|
// sometimes in some systems we don't. We grab the foreground, then
|
|
|
|
// finish setting up, pump all our messages, and sleep for a little while
|
|
|
|
// to let messages finish bouncing around the system, then we put
|
|
|
|
// ourselves at the top of the z order, then grab the foreground again,
|
|
|
|
// Who knows if it helps, but it probably doesn't hurt
|
|
|
|
if (!force_minimized)
|
|
|
|
SetForegroundWindow (win_mainwindow);
|
|
|
|
|
|
|
|
hdc = GetDC (NULL);
|
2021-03-30 11:09:13 +00:00
|
|
|
if (GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE) {
|
2021-03-31 01:36:30 +00:00
|
|
|
win_palettized = true;
|
2021-03-30 11:09:13 +00:00
|
|
|
} else {
|
2021-03-31 01:36:30 +00:00
|
|
|
win_palettized = false;
|
2021-03-30 11:09:13 +00:00
|
|
|
}
|
2021-03-27 11:09:37 +00:00
|
|
|
ReleaseDC (NULL, hdc);
|
2021-03-30 11:09:13 +00:00
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
vid_modenum = modenum;
|
[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_modenum;
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
|
|
|
|
TranslateMessage (&msg);
|
|
|
|
DispatchMessage (&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
Sleep (100);
|
|
|
|
|
|
|
|
if (!force_minimized) {
|
|
|
|
SetWindowPos (win_mainwindow, HWND_TOP, 0, 0, 0, 0,
|
|
|
|
SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW |
|
|
|
|
SWP_NOCOPYBITS);
|
|
|
|
|
|
|
|
SetForegroundWindow (win_mainwindow);
|
|
|
|
}
|
|
|
|
// fix the leftover Alt from any Alt-Tab or the like that switched us away
|
2021-11-19 04:52:40 +00:00
|
|
|
IN_ClearStates ();
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
Sys_Printf ("%s\n", VID_GetModeDescription (vid_modenum));
|
|
|
|
|
|
|
|
viddef.recalc_refdef = 1;
|
|
|
|
|
|
|
|
//FIXME SCR_StretchInit();
|
|
|
|
//FIXME SCR_StretchRefresh();
|
|
|
|
//FIXME SCR_CvarCheck();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-31 06:50:10 +00:00
|
|
|
void
|
|
|
|
Win_CreateWindow (int width, int height)
|
|
|
|
{
|
|
|
|
RECT rect = {
|
|
|
|
.top = 0,
|
|
|
|
.left = 0,
|
|
|
|
.right = width,
|
|
|
|
.bottom = height,
|
|
|
|
};
|
|
|
|
AdjustWindowRectEx (&rect, WindowStyle, FALSE, 0);
|
|
|
|
// sound initialization has to go here, preceded by a windowed mode set,
|
|
|
|
// so there's a window for DirectSound to work with but we're not yet
|
|
|
|
// fullscreen so the "hardware already in use" dialog is visible if it
|
|
|
|
// gets displayed
|
|
|
|
// keep the window minimized until we're ready for the first real mode set
|
|
|
|
win_mainwindow = CreateWindowEx (ExWindowStyle,
|
|
|
|
"WinQuake",
|
|
|
|
"WinQuake",
|
|
|
|
WindowStyle,
|
|
|
|
0, 0,
|
|
|
|
rect.right - rect.left,
|
|
|
|
rect.bottom - rect.top,
|
|
|
|
NULL, NULL, global_hInstance, NULL);
|
|
|
|
|
|
|
|
if (!win_mainwindow)
|
|
|
|
Sys_Error ("Couldn't create DIB window");
|
|
|
|
|
|
|
|
// done
|
|
|
|
vid_mode_set = true;
|
|
|
|
//FIXME if (firsttime) S_Init ();
|
|
|
|
Win_UpdateWindowStatus (0, 0); // FIXME right numbers?
|
|
|
|
|
|
|
|
HDC hdc = GetDC (NULL);
|
|
|
|
if (GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE) {
|
|
|
|
win_palettized = true;
|
|
|
|
} else {
|
|
|
|
win_palettized = false;
|
|
|
|
}
|
|
|
|
ReleaseDC (NULL, hdc);
|
|
|
|
|
|
|
|
//vid_modenum = modenum;
|
|
|
|
//Cvar_SetValue (vid_mode, (float) vid_modenum);
|
|
|
|
|
|
|
|
MSG msg;
|
|
|
|
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
|
|
|
|
TranslateMessage (&msg);
|
|
|
|
DispatchMessage (&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
Sleep (100);
|
|
|
|
|
|
|
|
if (!force_minimized) {
|
|
|
|
SetWindowPos (win_mainwindow, HWND_TOP, 0, 0, 0, 0,
|
|
|
|
SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW |
|
|
|
|
SWP_NOCOPYBITS);
|
|
|
|
|
|
|
|
SetForegroundWindow (win_mainwindow);
|
|
|
|
}
|
|
|
|
// fix the leftover Alt from any Alt-Tab or the like that switched us away
|
2021-11-19 04:52:40 +00:00
|
|
|
IN_ClearStates ();
|
2021-03-31 06:50:10 +00:00
|
|
|
|
|
|
|
Sys_Printf ("%s\n", VID_GetModeDescription (vid_modenum));
|
|
|
|
|
|
|
|
viddef.recalc_refdef = 1;
|
|
|
|
}
|
|
|
|
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
VID_HandlePause
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
static void __attribute__ ((used))
|
2023-06-13 09:06:11 +00:00
|
|
|
VID_HandlePause (bool pause)
|
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
|
|
|
if ((modestate == MS_WINDOWED) && _windowed_mouse) {
|
2021-03-27 11:09:37 +00:00
|
|
|
if (pause) {
|
|
|
|
IN_DeactivateMouse ();
|
|
|
|
IN_ShowMouse ();
|
|
|
|
} else {
|
|
|
|
IN_ActivateMouse ();
|
|
|
|
IN_HideMouse ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================================================================
|
|
|
|
|
|
|
|
MAIN WINDOW
|
|
|
|
|
|
|
|
===================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int modenum;
|
|
|
|
char *desc;
|
|
|
|
int iscur;
|
|
|
|
int width;
|
|
|
|
} modedesc_t;
|
|
|
|
|
|
|
|
#define MAX_COLUMN_SIZE 5
|
|
|
|
#define MODE_AREA_HEIGHT (MAX_COLUMN_SIZE + 6)
|
|
|
|
#define MAX_MODEDESCS (MAX_COLUMN_SIZE*3)
|
|
|
|
|
|
|
|
//static modedesc_t modedescs[MAX_MODEDESCS];
|
|
|
|
|
|
|
|
static int
|
|
|
|
VID_NumModes (void)
|
|
|
|
{
|
|
|
|
return nummodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char * __attribute__((used))
|
|
|
|
VID_GetModeDescriptionMemCheck (int mode)
|
|
|
|
{
|
|
|
|
char *pinfo;
|
|
|
|
vmode_t *pv;
|
|
|
|
|
|
|
|
if ((mode < 0) || (mode >= nummodes))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
VID_CheckModedescFixup (mode);
|
|
|
|
pv = VID_GetModePtr (mode);
|
|
|
|
pinfo = pv->modedesc;
|
|
|
|
|
|
|
|
if (VID_CheckAdequateMem (pv->width, pv->height)) {
|
|
|
|
return pinfo;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Tacks on "windowed" or "fullscreen"
|
2021-03-30 11:09:13 +00:00
|
|
|
static const char * __attribute__((used))
|
2021-03-27 11:09:37 +00:00
|
|
|
VID_GetModeDescription2 (int mode)
|
|
|
|
{
|
|
|
|
vmode_t *pv;
|
|
|
|
|
|
|
|
if ((mode < 0) || (mode >= nummodes))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
VID_CheckModedescFixup (mode);
|
|
|
|
pv = VID_GetModePtr (mode);
|
|
|
|
|
|
|
|
if (modelist[mode].type == MS_FULLSCREEN) {
|
2021-03-30 11:09:13 +00:00
|
|
|
return va (0, "%s fullscreen", pv->modedesc);
|
2021-03-27 11:09:37 +00:00
|
|
|
} else if (modelist[mode].type == MS_FULLDIB) {
|
2021-03-30 11:09:13 +00:00
|
|
|
return va (0, "%s fullscreen", pv->modedesc);
|
2021-03-27 11:09:37 +00:00
|
|
|
} else {
|
2021-03-30 11:09:13 +00:00
|
|
|
return va (0, "%s windowed", pv->modedesc);
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// KJB: Added this to return the mode driver name in description for console
|
|
|
|
static char *
|
|
|
|
VID_GetExtModeDescription (int mode)
|
|
|
|
{
|
|
|
|
static char pinfo[40];
|
|
|
|
vmode_t *pv;
|
|
|
|
|
|
|
|
if ((mode < 0) || (mode >= nummodes))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
VID_CheckModedescFixup (mode);
|
|
|
|
pv = VID_GetModePtr (mode);
|
|
|
|
|
|
|
|
if (modelist[mode].type == MS_FULLDIB) {
|
|
|
|
sprintf (pinfo, "%s fullscreen", pv->modedesc);
|
|
|
|
} else {
|
|
|
|
sprintf (pinfo, "%s windowed", pv->modedesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pinfo;
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
VID_DescribeCurrentMode_f (void)
|
|
|
|
{
|
|
|
|
Sys_Printf ("%s\n", VID_GetExtModeDescription (vid_modenum));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_NumModes_f (void)
|
|
|
|
{
|
|
|
|
if (nummodes == 1)
|
|
|
|
Sys_Printf ("%d video mode is available\n", nummodes);
|
|
|
|
else
|
|
|
|
Sys_Printf ("%d video modes are available\n", nummodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_DescribeMode_f (void)
|
|
|
|
{
|
|
|
|
int modenum;
|
|
|
|
|
|
|
|
modenum = atoi (Cmd_Argv (1));
|
|
|
|
Sys_Printf ("%s\n", VID_GetExtModeDescription (modenum));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_DescribeModes_f (void)
|
|
|
|
{
|
|
|
|
int i, lnummodes;
|
|
|
|
char *pinfo;
|
2023-06-13 09:06:11 +00:00
|
|
|
bool na;
|
2021-03-27 11:09:37 +00:00
|
|
|
vmode_t *pv;
|
|
|
|
|
|
|
|
na = false;
|
|
|
|
lnummodes = VID_NumModes ();
|
|
|
|
|
|
|
|
for (i = 0; i < lnummodes; i++) {
|
|
|
|
pv = VID_GetModePtr (i);
|
|
|
|
pinfo = VID_GetExtModeDescription (i);
|
|
|
|
|
|
|
|
if (VID_CheckAdequateMem (pv->width, pv->height)) {
|
|
|
|
Sys_Printf ("%2d: %s\n", i, pinfo);
|
|
|
|
} else {
|
|
|
|
Sys_Printf ("**: %s\n", pinfo);
|
|
|
|
na = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (na) {
|
|
|
|
Sys_Printf ("\n[**: not enough system RAM for mode]\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_TestMode_f (void)
|
|
|
|
{
|
|
|
|
int modenum;
|
|
|
|
double testduration;
|
|
|
|
|
|
|
|
if (!vid_testingmode) {
|
|
|
|
modenum = atoi (Cmd_Argv (1));
|
|
|
|
|
|
|
|
if (VID_SetMode (modenum, vid_curpal)) {
|
|
|
|
vid_testingmode = 1;
|
|
|
|
testduration = atof (Cmd_Argv (2));
|
|
|
|
|
|
|
|
if (testduration == 0)
|
|
|
|
testduration = 5.0;
|
|
|
|
|
|
|
|
vid_testendtime = Sys_DoubleTime () + testduration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_Windowed_f (void)
|
|
|
|
{
|
[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_windowed_mode, vid_curpal);
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_Fullscreen_f (void)
|
|
|
|
{
|
[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_fullscreen_mode, vid_curpal);
|
2021-03-27 11:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_Minimize_f (void)
|
|
|
|
{
|
|
|
|
// we only support minimizing windows; if you're fullscreen,
|
|
|
|
// switch to windowed first
|
|
|
|
if (modestate == MS_WINDOWED)
|
|
|
|
ShowWindow (win_mainwindow, SW_MINIMIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_ForceMode_f (void)
|
|
|
|
{
|
|
|
|
int modenum;
|
|
|
|
|
|
|
|
if (!vid_testingmode) {
|
|
|
|
modenum = atoi (Cmd_Argv (1));
|
|
|
|
force_mode_set = 1;
|
|
|
|
VID_SetMode (modenum, vid_curpal);
|
|
|
|
force_mode_set = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Win_SetCaption (const char *text)
|
|
|
|
{
|
|
|
|
if (win_mainwindow) {
|
|
|
|
SetWindowText (win_mainwindow, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//static WORD systemgammaramps[3][256];
|
|
|
|
static WORD currentgammaramps[3][256];
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
bool
|
2021-03-27 11:09:37 +00:00
|
|
|
Win_SetGamma (double gamma)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
HDC hdc = GetDC (NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
currentgammaramps[2][i] = currentgammaramps[1][i] =
|
|
|
|
currentgammaramps[0][i] = viddef.gammatable[i] * 256;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = SetDeviceGammaRamp (hdc, ¤tgammaramps[0][0]);
|
|
|
|
ReleaseDC (NULL, hdc);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Win_Init_Cvars (void)
|
|
|
|
{
|
[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
|
|
|
Cvar_Register (&vid_ddraw_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_mode_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_wait_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_nopageflip_cvar, 0, 0);
|
|
|
|
Cvar_Register (&_vid_wait_override_cvar, 0, 0);
|
|
|
|
Cvar_Register (&_vid_default_mode_cvar, 0, 0);
|
|
|
|
Cvar_Register (&_vid_default_mode_win_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_config_x_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_config_y_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_stretch_by_2_cvar, 0, 0);
|
|
|
|
Cvar_Register (&_windowed_mouse_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_fullscreen_mode_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_windowed_mode_cvar, 0, 0);
|
|
|
|
Cvar_Register (&block_switch_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_window_x_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_window_y_cvar, 0, 0);
|
2021-03-27 11:09:37 +00:00
|
|
|
|
|
|
|
Cmd_AddCommand ("vid_testmode", VID_TestMode_f, "");
|
|
|
|
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, "");
|
|
|
|
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f, "");
|
|
|
|
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f, "");
|
|
|
|
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f, "");
|
|
|
|
Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f, "");
|
|
|
|
Cmd_AddCommand ("vid_windowed", VID_Windowed_f, "");
|
|
|
|
Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f, "");
|
|
|
|
Cmd_AddCommand ("vid_minimize", VID_Minimize_f, "");
|
|
|
|
}
|
2021-09-28 03:48:47 +00:00
|
|
|
|
|
|
|
extern int win_force_link;
|
|
|
|
static __attribute__((used)) int *context_win_force_link = &win_force_link;
|