Commit graph

1737 commits

Author SHA1 Message Date
Yamagi
61e7ec9697 Port ref_gl3 to SDL 3.
Not many changes here. `make ref_gl3` now builds a library and it works
with the proof of concept port of the client.
2024-04-07 11:01:44 +02:00
Yamagi
9a1990ecc4 Port ref_gl1 to SDL 3.
Not many changes here. `make ref_gl1` now builds a library and it works
with the proof of concept port of the client.

SDL3 dropped support for hardware gamma, so `vid_gamma` will be ignored
until we can come up with something else. If we can, gamma without
shaders is hard to impossible :/

SDL3 TODOs will be marked with 'TODO SDL3:'.
2024-04-07 11:01:44 +02:00
Yamagi
9b0c95daaa Fork the clients SDL 2 backends into SDL 3 versions.
At this time they are just copies. The actual porting will be done in
upcoming commits.
2024-04-07 11:01:44 +02:00
Yamagi
126c2ea10b Add SDL 3 support to the Makefile.
This is hidden behind WITH_SDL3, which is disabled by default.

Additionally rename the SDL sources files in the client to represent the
SDL major version they are supporting. They will be forked for SDL 3.
That isn't optimal, because it forces us to support two variants of the
same code. However the changes between SDL 2 and 3 are too big to work
with #ifdef and something like function pointer magic is even more
confusing.
2024-04-07 11:01:44 +02:00
Yamagi
34d2ddc2a9
Merge pull request #1100 from dkoreshkov/master
Some improvements to the SW renderer
2024-04-06 16:26:13 +02:00
Denis
784f35faed move ifdef into function 2024-04-01 20:49:40 +03:00
Yamagi
5a642c4205
Merge pull request #1099 from BjossiAlfreds/cvar-cl_laseralpha
Added cvar cl_laseralpha and documentation in cvarlist
2024-04-01 09:12:03 +02:00
Yamagi
48a4e5397c
Merge pull request #1094 from 0lvin/light_code_style
Rename functions r_dlightframecount parameter to lightframecount
2024-04-01 08:58:35 +02:00
Denis
6d1ac97a77 cleanup alias scan conversion 2024-03-31 22:45:30 +03:00
Denis
85b7ae87ef fix bmodel clipping 2024-03-31 22:40:29 +03:00
Denis
d5c26f28d6 free for real 2024-03-31 22:39:50 +03:00
BjossiAlfreds
c134d0127d Added cvar cl_laseralpha and documentation in cvarlist 2024-03-31 10:45:31 +00:00
BraXi
764c977106 Rename functions r_dlightframecount parameter to lightframecount
Renders has global variable with such name that used as parameters
for R_MarkLights shared function.

Fixes:
 * https://github.com/yquake2/yquake2remaster/issues/17
 * https://github.com/yquake2/yquake2/issues/1093
2024-03-23 23:11:13 +02:00
Yamagi
9569f41c3c
Merge pull request #1091 from apartfromtime/Texture-filter-menu-option
Texture filtering options for OpenGL and Software video modes
2024-03-19 19:24:41 +01:00
Yamagi
6c21caa55d
Merge pull request #1088 from ConHuevosGuey/master
Added a player speed display that prints the players speed and ground speed at the top right corner. The function can be toggled on using cl_showspeed 1.
2024-03-19 19:17:12 +01:00
apartfromtime
26194c76cf Fix software dithering
Rounding view angles to degrees fixes undefined software texture filter behaviour.
2024-03-18 12:19:35 +11:00
apartfromtime
72de1d45f8 Texture filtering options for OpenGL and Software video modes
Add renderer specific menu options.
2024-03-18 11:11:47 +11:00
Yamagi
823998d87f
Merge pull request #1085 from apartfromtime/Texture-filter-menu-option
Texture filtering option
2024-03-16 11:37:43 +01:00
Feels Duck Man
cf5b3687f2 Added an option to draw speed under the crosshair with cl_showspeed 2, fixed drawing the speedometer when the game wasn't playing. 2024-03-10 10:26:53 -05:00
Feels Duck Man
9cff22b55c Removed 'Speed' label for speedometer when being displayed 2024-03-02 13:54:43 -06:00
Feels Duck Man
cfece2f55d Added a speedometer that displays the player's speed in QU/s. Wasn't quite sure how to implement it without adding GetPlayerSpeed() to pmove.c. Unsure if there is a cleaner way to do this while keeping it inside cl_screen.c 2024-03-01 14:05:36 -06:00
apartfromtime
292bc0f632 Texture filtering option
Adds texture filtering option to the video menu.

Closes #753
2024-02-26 18:08:18 +11:00
Yamagi
e72ef48ae7 Add gl4 to the video menu renderer list.
GL4 is community maintained variant of GL3 using somewhat more up to
date OpenGL APIs. Requsted in #1045.
2024-02-03 16:18:06 +01:00
apartfromtime
8beb3d8a2e Case insensitive sort for player skins
Case insensitive compare in quicksort compare function for player names.

Closes #1082
2024-02-02 21:33:14 +11:00
Jaime Moreira
adf638d1f4 Controller buttons read more succinctly 2024-01-06 13:35:48 -03:00
Jaime Moreira
fb46007bc3 Fixed gl1_overbrightbits limiter, for real now
Allowed values are 0, 1, 2 and 4 only.
Updated documentation, again.
2024-01-06 13:32:48 -03:00
Jaime Moreira
9f9c212648 OpenGL 1 errors are visible now
Needs DEBUG=1 to enable
2024-01-06 13:29:13 -03:00
Yamagi
e40f5d1480
Merge pull request #1077 from apartfromtime/Fix-duplicate-entries
Fix duplicate menu key keyboard entries
2023-12-19 18:33:39 +01:00
apartfromtime
87ae381ed2 Attempt to fix indentation 2023-12-18 09:27:57 +11:00
apartfromtime
1570baee4d Remove superfluous switch statement 2023-12-18 08:52:35 +11:00
apartfromtime
089a1cd53f Fix duplicate menu key keyboard entries
Fixes a bug where duplicate keyboard entries would occur in menu fields when using the keypad keys with num-lock on.

Adds `IN_NumpadIsOn` function returning the state of the numpad key.
2023-12-17 09:55:58 +11:00
apartfromtime
ef456964e3 Revert "Fix duplicate menu key keyboard entries"
This reverts commit 2180ca6c40.
2023-12-17 08:18:38 +11:00
apartfromtime
2180ca6c40 Fix duplicate menu key keyboard entries
Fixes a bug where duplicate keyboard entries would occur in menu fields when using the keypad keys with num-lock on.
Menu fields now mirror behaviour of the console field.
Removed keypad left arrow case from console key ignore list.
2023-12-12 14:29:52 +11:00
apartfromtime
71570bb2ef Revert changes to shaders
Uses min/max from shader language.
2023-12-09 12:28:30 +11:00
apartfromtime
f0d2c5afaa More min\max function renaming
Missed function renaming.
2023-12-04 22:59:31 +11:00
apartfromtime
9ac19de4ac Rename min\max to avoid conflict with c-plus plus
While trying to compile the yquake2 rebased heretic2 source from 0lvin, a name conflict with min\max of different parameter counts included by a std::cpp library occurred.
2023-12-01 11:58:21 +11:00
Yamagi
90402c3f85 Move miniz into a subdirectory.
An upcoming update will add several files, having miniz in it's own
subdirectory makes it clear what belongs to it an whit to unzip.
2023-11-23 18:21:44 +01:00
David Carlier
a5192af173 fix curl uaf previous fix. 2023-10-25 18:46:03 +01:00
Jaime Moreira
36bf9de5a8 Typos 2023-10-18 20:37:49 -03:00
Jaime Moreira
fa218c9f4c Fixed gl1_overbrightbits limiter
Allows values between 0 and 4. Updated documentation.
2023-10-18 20:35:51 -03:00
Yamagi
5c642b6a5b
Merge pull request #1061 from DanielGibson/curl-uaf-fix
Fix use-after-free bugs in htttp download code
2023-10-15 18:09:25 +02:00
Yamagi
73c3afd47e
Merge pull request #1060 from devnexen/constify_it
"constifying" where underlying C calls expect compile time constants.
2023-09-16 18:14:17 +02:00
David CARLIER
3b8053edae "constifying" where underlying C calls expect compile time constants. 2023-09-16 16:20:21 +01:00
Daniel Gibson
3c8f087bb5 Fix use-after-free bugs in htttp download code
CL_RemoveFromQueue(qdlqueue_t *entry) free()s that entry, so the loops
that call q->next after CL_RemoveFromQueue(q) are accessing free'd
memory. Fix that by getting a pointer to the next entry before calling
CL_RemoveFromQueue().

Also did a tiny non-functional change to CL_RemoveFromQueue() to
make it easier to understand.
2023-09-16 16:59:31 +02:00
Yamagi
43e2a67f12 Fix indention problems introduced in the last commits. 2023-09-16 16:33:13 +02:00
Yamagi
49d4f2ce1f Merge remote-tracking branch 'menu/oss' 2023-09-16 16:30:04 +02:00
Yamagi
4afcd900cc
Merge pull request #1049 from protocultor/g_swap_speed_fix
Fix for g_swap_speed behaviour with extreme values
2023-09-14 21:01:42 +02:00
Jaime Moreira
9821c4b0a2 Show correct replacement for gl_lightmap cvar
Typos corrected
2023-08-26 19:18:24 -04:00
Jaime Moreira
c2ab0f61d7 Fixed Zoid Kirsch's name in credits 2023-08-26 19:10:26 -04:00
Johan Mattsson
9c929ab463
Fix potential index out of bounds 2023-08-13 18:04:04 +02:00
Denis Pauk
63d990487a models: ignore sprites/skins bigger than MAX_MD2SKINS 2023-07-02 00:30:21 +03:00
Denis Pauk
5c0883594f cl_cin: Support of RGBA png/jpg image with r_retexturing as cinematic 2023-07-02 00:03:18 +03:00
Denis Pauk
86dd7e6d2d Remove redudant rserr_invalid_fullscreen check 2023-07-01 23:17:17 +03:00
Yamagi
cb317f2cd3
Merge pull request #1031 from protocultor/g_swap_speed
Cheat to speed up "weapon change" animations
2023-07-01 16:21:42 +02:00
Yamagi
8855d650c6
Merge pull request #1030 from devnexen/compile_time_checks
adding compile time assertion support whenever possible
2023-07-01 16:10:34 +02:00
Jaime Moreira
c5e2d51fd7 Cheat cvar "g_swap_speed" implemented
Allows to skip frames of "putting down weapon" and
"raising weapon" animations, speeding them up.
2023-06-28 15:28:40 -04:00
David Carlier
ce3e9136a8 adding compile time assertion support whenever possible
and convert some runtime which deserve to be evaluated earlier.
2023-06-17 16:37:29 +01:00
David CARLIER
1ce09d7ef9 R_SetFrustum micro optimisation. 2023-06-16 13:06:05 +01:00
Yamagi
9212ded546
Merge pull request #1011 from devnexen/cl_setenv_overflow_fix
fix potential overflow on env vars settings.
2023-06-05 19:15:56 +02:00
Rykita
cd351a0602 Fixed vid_pauseonfocuslost, final. 2023-05-25 23:59:26 +02:00
apartfromtime
be1e6e1743 Fix pause/un-pause on window focus gained or lost
Fixed pause/un-pause on window focus gained or lost in pull request #1017.
Fixed ogg playback when switching video options, missed in #1004.
Fixed ogg playback when the last menu closed, misplaced in #1004.
2023-05-25 15:33:12 +10:00
Rykita
8cbbfaae9e Pause on Minimized/Focus Lost is now in the options menu 2023-05-24 16:42:36 +02:00
Daniel Gibson
218ac53ce9 GL3: Add hack to make lava glow, fix #1014
Normal warping surfaces (SURF_DRAWTURB) with water etc should use
brightness 0.5*intensity (like they did before), but those with lava
should be brighter, so use 1.0*intensity in the shader.
The reason that intensity needs to be scaled down is that these surfaces
have no lightmaps, so they'd be rendered fullbright otherwise.

I'm using the simple heuristic of texturename contains "lava" to
detect lava textures.
2023-05-20 21:07:16 +02:00
Yamagi
51cdc80525 Fix game with older SDL versions.
The window `flags` must be returned always, otherwise there won't be
usable Window flags and the game doesn't start.
2023-05-20 16:26:02 +02:00
David CARLIER
07553f0980 fix potential overflow on env vars settings.
changing a bit Q_strlcpy flow as it can report wrong bytes copied
if src > buffer size.
2023-05-14 19:16:18 +01:00
Yamagi
5f03705c5d Update stb_image.h to v2.28. 2023-05-14 10:01:04 +02:00
Yamagi
dbc0fa12ec Update glad-gles3 to it's latest version. 2023-05-14 09:57:45 +02:00
Yamagi
83fd0d092e Update glad-gl3 to it's latest version. 2023-05-14 09:55:37 +02:00
Yamagi
a5560ff3a2 Implement high dpi awareness into the client and all renderers.
Over the last years high dpi displays became increasingly popular. We
already implemented very basic high dpi support for Windows several
years ago by setting the "please don't scale us" option. Linux (and
all other unixoid platforms) hadn't a real understandig of high dpi
and everything involved until the advent of Wayland and finally the
*fractional-scale-v1* protocol last autumn.

Since then SDL (even bevore the protocol was finalized) and all three
common Wayland compositors (Gnome, KDE and wlroots) have grown support
for the protocol and are now high dpi aware. In a high dpi aware world
the choice is scale yourself or get scaled by the compositor. The later
option isn't so good for fast paced games like Quake II, it introduces
blur and slugishness. Therefore implement hig dpi awareness through SDL.

This isn't perfect right now:
* SDL is still getting high dpi awareness fixes with every release. High
  dpi awareness in YQ2 is currently limited to at least SDL 2.26 and we
  may rise the required version even more if necessary.
* There are stll bugs in the compositors. For example Gnome 44.1 has a
  tedency to misscalculate the space occupied by the fullscreen window,
  the game ends up wit a white bar on top. sway even misscalculates
  some scaling factors: https://github.com/swaywm/sway/issues/7463
* SDL hasn't got a reliable way to get the real non scales desktop
  resolution.

Because of this:
* High dpi awareness is currently restricted to Wayland. Let's get one
  platform right before we implement it for everything else.
* It's hidden behind `vid_highdpiawareness` and disabled by default.

High dpi awareness is implemented by setting `SDL_WINDOW_ALLOW_HIGHDPI`
on the window. After the window and rendering context are created
`SDL_GL_GetDrawableSize()` or `SDL_GetRendererOutputSize()` are used
to query the actual drawable size and the internal representation is
overwritten with it.

This would scale the fullscreen window over the full screen, no matter
what resolution was selected. Some work arounds are implemented to
(mostly) keep the old behaviour were resoltions lower than the desktop
resolution weren't scaled. There is one inconsistency: While the non
high dpi aware soft renderer always scaled over the full screen, the
high dpi aware variant doesn't. This is a restriction by SDL Renderer.

Setting native fullscreen was broken before when running on high dpi
displays and it's not fixed. This is caused by SDL being unable to
determine the real resolution (or whatever the compositor thinks the
real resolution is). Depending on the compositor or if the client is
high dpi aware the correct resolution must be set by hand **or** auto
setting with `r_mode -2` must be used. Resolution detection was switched
to `SDL_GetCurrentDisplayMode()` because it's somewhat less problematic
than `SDL_GetCDesktopDisplayMode()`.

The renderer API was extended by one function pointer `*GetDrawableSize`
used to communicate the actual drawable size between renderer and
client. The API version was bumped to 6. I'll fix ref_vk before pushing
this change to master.
2023-05-14 09:44:23 +02:00
Yamagi
a241fd50e4
Merge pull request #999 from devnexen/gcc13_build_fixes
addressing few gcc 13 analyser warnings.
2023-05-08 21:16:55 +02:00
David Carlier
571f3f6fec addressing few gcc 13 analyser warnings. 2023-05-08 18:07:27 +01:00
Yamagi
9816ff7712
Merge pull request #1004 from apartfromtime/ogg-pause-music-when-pause-game
Sound backend and ogg pause features
2023-05-08 18:06:22 +02:00
apartfromtime
bc5926be4f Sound backend and ogg pause features
Playback features outlined in issue #715 .

Reintroduce activate\deactivate sound backend when window focus in changed.
Added "windowed_pauseonfocuslost" cvar to allowing user control of pause when the window changes focus.
Added "ogg_pausewithgame" cvar to allow user control of ogg playback whenever the game is paused.
Introduced ogg playback command "mute" as an additional playback option for the console, command buffer and key binds.

If the window focus is changed all sound playback will stop and resume as expected.
Setting "window_pauseonfocuslost" to 1 will force the game to pause when the window focus is lost, "cl_paused" is ignored in multiplayer.
Setting "ogg_pausewithgame" to 1 will force ogg playback to pause whenever the game is paused.
Toggling ogg mute through "ogg mute" sets the volume to 0 while playback resumes.
2023-04-29 13:27:38 +10:00
apartfromtime
0960984c91 Revert previous changes in 7d4cfd4acd
Implement @protocultors fix.
2023-04-23 17:52:45 +10:00
apartfromtime
7d4cfd4acd Fix implicit declaration of SDL_GameControllerGetSensorDataRate available since SDL 2.0.16 not 2.0.14 2023-04-23 14:31:53 +10:00
Yamagi
f67b65c00a
Merge pull request #993 from devnexen/clang16_attr_fnptr
fix clang 16 build as C11 _NoReturn/noreturn attributes conflict.
2023-04-16 11:24:16 +02:00
Yamagi
cbe3ef4c76 Fix several whitespace errors introduced in the last merge. 2023-04-16 11:20:52 +02:00
Yamagi
51f3810fb7
Merge pull request #986 from apartfromtime/playback-features
Ogg Playback Features
2023-04-16 11:18:29 +02:00
Yamagi
a04809a66e Ensure that new empty console line are really empty.
This fixes a corner case: When the client is in state `ca_disconnected`
and the user presses repeatedly return, there is a chance that a older
line is erroneously printed again. This is caused by spinning through
the console history buffer, when an old line is the current line a the
frame were the console refreshs it's printed. Work around that by
clearing every line as soon as it becomes the current line.

Closes #987.
2023-04-16 10:26:07 +02:00
David CARLIER
5b895615a4 fix clang 16 build as C11 _NoReturn/noreturn attributes conflict.
And remove a handful of unused vars.
2023-04-16 08:19:33 +01:00
Yamagi
11bea2a68b
Merge pull request #990 from protocultor/old_sdl_gyro_switch
Gyro aiming for Switch controllers with SDL < 2.0.14
2023-04-15 18:23:28 +02:00
Jaime Moreira
9a18b39114 Simplified definition of NATIVE_SDL_GYRO
It is being used as a "boolean" anyway; the code only checks its
existence.
2023-04-14 18:16:16 -04:00
Denis Pauk
538aadb9dc Fix sound characteristics calculations
Ogg file has incorrectly calculated size and samples as
result calculation of volume and timings have used
incorrect test samples for sterio sound.

Checked with compare ogg and wav samples from 25th
Anniversary mod:
```
ffmpeg -i 25acu/sound/world/goreshit.wav 25acu/sound/world/goreshit-ogg.wav
```

Soundlist:
```
]/soundlist
 (16b)  1404340(2 ch) world/goreshit.wav -11.7 dB 351.1s:15.0..0.3..1.1..2.0
 (16b)  1404340(2 ch) world/goreshit-ogg.wav -11.5 dB 351.1s:15.0..18.4..1.4..2.0
```

Fixes:
* https://github.com/glhrmfrts/q25_game/issues/8
* https://github.com/yquake2/yquake2/issues/991
2023-04-14 18:22:12 +03:00
Jaime Moreira
61df6a74d5 Gyro aiming for Switch controllers on SDL < 2.0.14
dkms-hid-nintendo can expose the IMU sensors of a Switch controller
as a "second joystick", which makes possible to use gyro aiming on a
system without SDL 2.0.14 available (the minimum required to read
controller sensors like gyro and accelerometer).

This commit makes both "sensor" and "joystick reading" to coexist.
"Sensor" is still the preferred method when available.
2023-03-28 23:06:34 -03:00
apartfromtime
f96deee197 Playback Features
Playback features outlined in issue #729.

Added shuffle playback parameters:

default - Ogg track currently active repeats. This is the quake2 default behaviour.
play once - Ogg track currently active plays once then stops.
sequential - Ogg tracks play in numerical order, from the currently playing track and like default repeats.
random - Ogg tracks play randomly, but never the same track twice.

Ogg tracks can be played from a full-screen console and tracks played will adhere to the shuffle parameter.

Loading a game map the map cd-track takes precedence as the first played track then subsequent playback of tracks will adhere to the shuffle parameter.

Any currently playing track can be overridden from the console with "ogg play <track>" command and subsequent playback of tracks will adhere to the shuffle parameter.

If a sound restart occurs the ogg backend will attempt to save and recover the currently playing track, though some data in the audio queue may be lost in the process.
2023-03-26 14:43:28 +11:00
Daniel Gibson
c2d80c64ee Fix crash in DDays "wake" map, #978
the HunkAlloc size calculated in calTexinfoAndFacesSize() was too
small because that map has a *massive* water poly.
Unfortunately it's not feasible to calculate the correct size
(it depends on the size of the poly, for which I'd need the vertex
coordinates, but to get them I'd have to load them first, which requires
the allocation...), but allocating 5MB extra (instead of 1) made it work
2023-03-25 19:18:35 +01:00
David CARLIER
038848b246 console fix warning build. 2023-03-17 17:17:32 +00:00
David CARLIER
5adf5175c4 CURL client fix on error with CURLMcode. 2023-03-11 15:02:59 +00:00
Denis Pauk
6c9c81e2f7 openal: Fix reverb slot configuration 2023-02-05 16:19:38 +02:00
David Carlier
2e51a9f72f silencing static analysis warnings. 2023-01-31 06:47:04 +00:00
Denis Pauk
16395a15d9 Fix m32 load code 2023-01-21 18:31:18 +02:00
Denis Pauk
0cd2eed28b Share R_CullBox and R_SetFrustum 2023-01-21 18:31:16 +02:00
Denis Pauk
32ab1e1815 Share R_MarkLights 2023-01-21 18:24:55 +02:00
Denis Pauk
d326b1be51 Share R_AreaVisible 2023-01-21 18:24:55 +02:00
Denis Pauk
c17210b34a Share R_TextureAnimation 2023-01-21 18:24:55 +02:00
Denis Pauk
42bfb2014c Share Mod_PointInLeaf 2023-01-21 18:24:55 +02:00
Denis Pauk
442fe10f27 Share Mod_Load* functions 2023-01-21 18:24:55 +02:00
Denis Pauk
4463e1fcd7 Share mnode_t and mleaf_t struct between renders. 2023-01-21 18:24:55 +02:00
Yamagi
6566a2ae7d Handle case that ResizeSTB() failed.
This unlikely, however the compiler printed a warning that `image` may
be used uninitialized.
2023-01-21 16:43:27 +01:00
Yamagi
e17d4f5dc0 Solve warning regarding deprecated curl macros.
These are deprecated since curl 7.31 and 7.50. Even Debian Stretch
(oldoldstable) ships with 7.52.
2023-01-21 16:31:02 +01:00