Commit graph

3840 commits

Author SHA1 Message Date
Yamagi
a675b654c6 Update to SDL 3.1.1 API.
Changes are:
* SDL_SetWindowGrab() was renamed to SDL_SetWindowMouseGrab().
* SDL doesn't give precalculated battery states anymore. Use the same
  scale as SDL 3.1.0, 20% is low and 1% is empty.
2024-04-07 11:01:45 +02:00
Yamagi
af82cfe978 Switch the default for vid_highdpiaware to 1 when build against SDL3.
With SDL3 the high dpi support is in much better shape than with SDL2.
And for Wayland the experience on high dpi displays is generally better
when the application is high dpi aware.
2024-04-07 11:01:45 +02:00
Yamagi
218829f031 Port the SDL audio backend to SDL 3.
Reimplement `SDL_BackendInit()` and `SDL_BackendShutdown()` for SDL 3.
Hide now unnecessary locking calls behind !USE_SDL3. To minimize code
duplication `SDL_Callback()` is hidden behind a wrapper function.
2024-04-07 11:01:45 +02:00
Yamagi
74ac473447 Remove support for older SDL version in the SDL 3 input backend.
SDL 3 is a fresh start, no need to support older versions.
2024-04-07 11:01:45 +02:00
Yamagi
40e1830885 Port joystick and controller handling to SDL 3. 2024-04-07 11:01:45 +02:00
Yamagi
d315f02a7b Port window event handling to SDL3. 2024-04-07 11:01:45 +02:00
Yamagi
a81b065893 Apply Coccinelle to input/sdl3.c.
Again this isn't enough to get the file compiling, but it's a start.
2024-04-07 11:01:45 +02:00
Yamagi
adfd7362b5 Explicitly shutdown the SDL_INIT_EVENTS subsystem.
SDL_INIT_VIDEO includes SDL_INIT_EVENTS when initialized through
SDL_Init(), but not when shutdown to SDL_Quit(). Handle the shutdown
in the input subsystem. This closes some memory leaks in SDL.
2024-04-07 11:01:44 +02:00
Yamagi
5a21397761 Refactor refreshrate handling from int to float.
With SDL 2 the refreshrate handling was rather limited by SDL 2 only
supporting integer refreshrates, making it impossible to represent the
common 59.95hz and other non-integer refreshrates. Quake II works around
this by assuming a refreshrate of 2hz higher than returned by SDL.

SDL 3 finally supports float refreshrates. Refactor the internal API to
also use floats.

This should be a no-op since the 'refreshrate * 1.02' logic stayes in
place for the time being. This can be reevaluated at a later time for
the SDL 3 build, but needs testing.

As a nice side effect fix the `vid_displayrefreshrate` cvar. It was
broken in both SDL 2 and 3 since it was always overwritten with the
actual display refresh rate.
2024-04-07 11:01:44 +02:00
Yamagi
5d30c5913b Query the primary display with SDL_GetPrimaryDisplay().
Everything else doesn't work reliable and is depended on the display
server. X11 uses it's display IDs, Wayland some UUIDs...
2024-04-07 11:01:44 +02:00
Yamagi
bcbeb81198 Several fixes in detection of the window position.
In SDL 2 the first display was 0 and the error code -1. In SDL 3 this
changed to 1 as the first display and 0 for the error code. While at
it implement error handling and fallbacks for all cases.
2024-04-07 11:01:44 +02:00
Yamagi
8a2336a375 Fix displaying the list of supported modes at startup.
While here limit the number of decimals of the real mode to 2.
2024-04-07 11:01:44 +02:00
Yamagi
bb8c6eac44 Refactor the fullscreen modes into an enum. 2024-04-07 11:01:44 +02:00
Yamagi
3c5dccb4d0 Port remaining parts of glimp_sdl3.c to SDL 3.
These are semantic changes to several functions which Coccinelle didn't
translate properly and some now superfluous SDL version checks.
2024-04-07 11:01:44 +02:00
Yamagi
cbc46009fd Port PrintDisplayModes() to SDL 3. 2024-04-07 11:01:44 +02:00
Yamagi
55a1e38717 Port GetWindowSize() to SDL 3. 2024-04-07 11:01:44 +02:00
Yamagi
6f0da6c247 Port fullscreen handling to SDL 3.
SDL 3 has a new approach to fullscreen handling, which is way better
than the old fiddling with several window flags. In SDL 3:

* The SDL_FULLSCREEN_FLAG puts the window in fullscreen window mode.
* For exclusive fullscreen a fullscreen mode must be requested and set.
* Applying the mode to the window is asynchronous, the mode change may
  occure at any later time. The window can be synchronized to force the
  mode change.

This is - of course - totaly untested, since the client doesn't build
yet with SDL 3. There will likely be bugs and shortcomings.

And the code is still ugly, it can be refactored somewhat more.
2024-04-07 11:01:44 +02:00
Yamagi
2877f1c391 Remove workaround for SDL bug #4700 from glimp_sdl3.c.
It has been fixed since SDL 2.22, all SDL 3 versions will have the fix.
2024-04-07 11:01:44 +02:00
Yamagi
2c624d0207 Port window creation to SDL 3.
Window properties and flags are now passed in an SDL_PropertiesID object
and no longer als parameters to `SDL_CreateWindow()`.
2024-04-07 11:01:44 +02:00
Yamagi
a33285bdd4 Apply Coccinelle to glimp_sdl3.c.
This isn't eneugh to get it compiling and some changes are looking fishy
but it's a start.
2024-04-07 11:01:44 +02:00
Yamagi
aaf917e28e Port ref_soft SDL 3. 2024-04-07 11:01:44 +02:00
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
aa259a5d5f
Merge pull request #1096 from devnexen/unroll_dis
VectorLength reduces complexity.
2024-04-01 09:07:59 +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
David Carlier
3e64b2c1f9 VectorLength reduces complexity. 2024-03-25 06:29:23 +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
Feels Duck Man
086084b507 Added documentation for 'cl_showspeed' in 040_cvarlist.md 2024-03-18 21:21:59 -05: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
Yamagi
cc176da74e
Merge pull request #1083 from apartfromtime/Case-insensitive-sort-on-player-skin-names
Case insensitive sort for player skins
2024-02-03 16:03:32 +01:00
Yamagi
5933b64f77 Sort the mod list case insensitive. 2024-02-03 16:00:30 +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