Commit graph

1785 commits

Author SHA1 Message Date
Jaime Moreira
303a627d10 Rumble workaround for SDL audio backend
Cache length is different from OpenAL, it must be greatly reduced for
a proper length to be used as the duration of the rumble effect.
2022-10-23 12:06:55 -03:00
Jaime Moreira
5a22720735 Controller Rumble / force feedback
Replaces classic "haptic" implementation, no longer available for
game controllers as of SDL 2.0.14.
2022-10-23 12:05:06 -03:00
Jaime Moreira
5c560039d8 Pause when controller is disconnected
Controller battery warnings added
2022-10-23 11:48:07 -03:00
Yamagi
1a450ef23d Add some more alignement to the video menu.
It looks better this way and is more in line with the other menus.
2022-10-23 14:56:04 +02:00
Yamagi
eab0f90289
Merge pull request #915 from devnexen/renderer_new_options
gl3/gl3es renderer display intensity/colorlight sub options.
2022-10-23 14:54:44 +02:00
Yamagi
871292934d Work around wrong palette after skiping cinematic whith developer 1.
Quake II has two palettes. One static palette used for the world and one
dynamic palette used by cinematics. Switching from the cinematic back to
the world palette is handled by putting up the loading plaque. Since a
cinematic always ends with loading somehting else this generally works.

Unfortunatly setting `developer 1` skips the loading plaque. The palette
never gets reset and the world looks like a bad LSD trip. ;) A correct
fix is complicated, because the loading plaque logic is messed up and
working by luck. Reworking the logic has a high propability breaking
corner cased exploited by mods.

Therefor take the easy route and uncoditionally switch to the world
palette when bringing up the loading plaque with `developer 1`.

Closes #925.
2022-10-23 14:50:47 +02:00
David Carlier
1a8f05b3ca gl3/gl3es renderer display intensity/colorlight sub options. 2022-10-22 21:19:28 +01:00
Daniel Gibson
690e46512e Restore stair step smoothing code for step sizes != 16
commit 93e9633382 "Port step smoothing code from r1q2." ported
r1q2 stair step smoothing for ranges that are equivalent to 8, 12 and 16
units/step.
Later in commit 7f996cc "Don't smooth half height steps" we removed
step sizes 8 and 12, because it appeared to make an elevator in hangar2
(over the water, after jump'n'run sequency) stutter.
However, in reality what made them stutter was the broken comparison
for velocity with an illegal cast, that we later fixed in
e30f82494 "Don't cast the array itself but it's content."

So now restore the smoothing for step sizes 8 and 12, which hopefully
fixes bug #923, and definitely does *not* break the elevater in hangar2.
2022-10-22 17:09:49 +02:00
Denis Pauk
b628fa9133 Share Mod_ReLoadSkins for reload images on model load 2022-10-17 22:43:40 +03:00
Denis Pauk
b2e8fbb086 Use quake style for types naming 2022-10-17 22:43:40 +03:00
Denis Pauk
f6e4f17c0a Mod_Load*: use pointer to image find 2022-10-17 22:43:40 +03:00
Denis Pauk
1dc617dee6 Mod_LoadMD2: Set max/min 2022-10-17 22:43:39 +03:00
Denis Pauk
e01e5273f8 {gl1,gl3,soft}_model.c fix const parameters 2022-10-17 22:43:39 +03:00
Denis Pauk
ae13c7e034 Share MD2/SP2 files 2022-10-17 22:43:39 +03:00
Yamagi
caab3864c6
Merge pull request #921 from BjossiAlfreds/ogg
Fixed ignoretrack0 and ogg menu option bugs
2022-10-16 18:57:35 +02:00
Jaime Moreira
f0d985dfb9 Deleted unneeded string terminators
Redundant after the usage of Q_strlcpy
2022-10-15 10:41:38 -03:00
Jaime Moreira
cc45e20bac Replaced strncpy with Q_strlcpy 2022-10-12 14:53:33 -03:00
BjossiAlfreds
e1efbecc82 Fixed ignoretrack0 and ogg menu option bugs 2022-10-12 13:42:48 +00:00
Jaime Moreira
7ca0ba4c11 Allows controller to select skin in menu 2022-10-11 17:13:26 -03:00
Jaime Moreira
b96734b9ee Skin names can have a length of 32 total
Fixes crash when entering "multiplayer" -> "player setup" menu with a skin name len > 16
Fixes "playermodels" cmd, which showed "(null)" as a final skin for every model
2022-10-11 16:58:44 -03:00
Jaime Moreira
5c7bf732df Player skins in menu sorted alphabetically
Mods in menu are now ordered: baseq2, xatrix, rogue, ctf, the rest
2022-10-08 17:21:50 -03:00
Yamagi
746f5ad21e
Merge pull request #913 from devnexen/sdl_windowmin_pause
pause the game when window is minimized.
2022-10-08 19:44:24 +02:00
David Carlier
9298c3abc8 pause the game when window is minimized.
closes #911
2022-10-08 18:03:03 +01:00
Yamagi
3222270df6
Merge pull request #900 from protocultor/delete_save
Quicksaves can be deleted from menu
2022-10-08 15:16:06 +02:00
Yamagi
294c4d1175
Merge pull request #896 from protocultor/gyro_invert
Options to invert gyro axes
2022-10-08 15:08:14 +02:00
David Carlier
f9d9577e9c fix some unitialized vars and clarify signedness on a handful of bitshift ops. 2022-10-08 15:07:02 +02:00
Jaime Moreira
654c145e29 Quicksaves can be deleted from menu
Also, avoids asking for deletion in "<empty>" savegames
2022-09-23 17:57:01 -03:00
Jaime Moreira
9de55c603d Classic cvar 'in_initjoy' resurrected
Added myself to credits
2022-09-19 11:36:23 -03:00
Jaime Moreira
da31490684 "Invert gyro" spincontrols 2022-09-19 11:27:47 -03:00
Jaime Moreira
54eb9e441d Sliders can ignore cvar value's sign, if needed
Gyro sensitivity sliders need this, since their values can be negative
to invert pitch and yaw.
2022-09-19 11:24:06 -03:00
Denis Pauk
61f4540617 Fix documentation for model preview.
All default players models have 84-94 frames for salute.
So value will be same for `cyborg`/`female`/`male`.
2022-09-18 12:39:50 +03:00
Denis Pauk
3b583a7143 Bumb game version value
New code has exported monster footsteps sounds function.

Fixes typos.
2022-09-18 12:39:50 +03:00
Denis Pauk
4946400260 sound: reverb logic cleanup 2022-09-18 12:39:50 +03:00
Denis Pauk
93c6c76b0e sound: cleanup reverb code 2022-09-18 12:39:50 +03:00
Denis Pauk
983f1db185 audio: Update autopick reverb magic 2022-09-18 12:39:50 +03:00
Denis Pauk
eb640a0033 sound: Little bit simplify reverb 2022-09-18 12:39:50 +03:00
SkacikPL
f0d6db5d4a Improved reverb behavior and presets
Adjusted presets and their ranges. Occluded sounds no longer have reverb.

Cherrypick of 66927bff72
2022-09-18 12:39:50 +03:00
SkacikPL
93812df488 Added reverb sound effect
Enabled by default, can be disabled via s_reverb 0. Also by default
picks preset automatically out of 7 presets based on surrounding
size, this function can be disabled via s_reverb_preset_autopick 0.
Presets can be set manually via s_reverb_preset (0-113).

Cherrypick of ac7be51e94
2022-09-18 12:39:50 +03:00
SkacikPL
66f1bc9a33 Add simple sound occusion based on YQ2 AL EFX code
Can be disabled via s_occlusion 0, strength is modified
via s_occlusion_strength (higher values are actually less occlusion).

Cherrypick of b557494e14
2022-09-18 12:39:50 +03:00
Denis Pauk
90b14fca24 game: make mframe static and export footstep functions 2022-09-18 12:39:50 +03:00
Yamagi
5a3163a7e4 Merge remote-tracking branch 'ui/ui' 2022-09-18 09:43:49 +02:00
Ted Thompson
7e7cda4487 Added brackets around mod names in menu 2022-09-17 17:30:17 +02:00
Yamagi
1053b5dfb1
Merge pull request #871 from 0lvin/new_commands
Add new cheats spawn commands
2022-09-17 17:17:02 +02:00
Yamagi
e705b48a8e
Merge pull request #883 from protocultor/thumbsticks_fs
Improved controller thumbsticks precision + Flick Stick
2022-09-17 16:13:57 +02:00
apartfromtime
f63b5914f6 Include guard pointers
Spincontrol checks for null itemnames, which could cause undefined behaviour (menu disappears or crashes) in some instances.
2022-09-10 09:05:36 +10:00
Denis Pauk
5cddd2110c client: add multiplayer model preview animation 2022-09-04 23:40:55 +03:00
Denis Pauk
cf110b5ea0 game: Add spawn on start point
It could be used for spawn weapon or opponnent for coop at spawn point.
2022-09-04 23:40:55 +03:00
Denis Pauk
2a8a2f390a game: add spawn entity by coordinates 2022-09-04 23:40:55 +03:00
Yamagi
ac9c09694a Don't try to draw particles if there aren't any.
This fixes a VLA getting allocated with length 0 which is undefined
behavior. Additionally it may yield a small performance gain in some
situations.
2022-09-04 18:45:07 +02:00
Yamagi
a4edbb979f
Merge pull request #866 from apartfromtime/ui
Make skin icon bitmap part of the player setup menu
2022-09-04 18:37:46 +02:00
Yamagi
a44de1596d Fix spin controls getting applied multiple times.
When a spin control is at min or max value, pressing the arrow key to
switch to the next nonexiting value executes the callback function. That
is confusing.

Example: 'freelook' is set to 'no'. The user presses left arrow,
switching to the nonexiting value before no. The code handles the
case and resets the current value drom -1 to 0. Nevertheless the
callback is executed and switches 'freelook' from no to yes...

Fix that by not executing the callback when we're at min or max value.

Closes #884.
2022-09-04 18:18:58 +02:00
Jaime Moreira
2ee5d7b479 IN_MapRange slight optimization 2022-08-25 21:07:53 -04:00
Jaime Moreira
c6dd713c89 Smooth rotation for Flick Stick
Added cvar to change maximum rotation angle that will be smoothed
2022-08-24 19:37:25 -04:00
Jaime Moreira
748909fd96 "Flick Stick" controller layout implementation
With southpaw version added to "sticks layout" menu
Cvar for length of stick to be considered a flick or rotation
Lacks rotation smoothing
2022-08-24 19:02:21 -04:00
Jaime Moreira
0417bc1023 Sloped axial deadzone added
2 cvars to change it, 1 per stick
Provides the "snap-to-axis" feeling of the previous axial deadzone
2022-08-24 17:48:33 -04:00
Jaime Moreira
f3fcf3fc24 Joystick handling refactored for precision
Changed 6 cvars for stick layout to 1; includes menu option
Axial deadzone replaced with radial one, 6 cvars to 2
Expo different for each thumbstick (1 cvar to 2); sliders included
Expo applied to full joystick vector magnitude, instead of per axis
Deleted "joystick_up" ("updown" function) and its sensitivity
2022-08-24 12:30:39 -04:00
Jaime Moreira
301a2ce735 Disable gyro when game is paused
Changed text on controller menu for lower resolutions
Appropiate data type for updates_countdown
2022-08-23 18:36:33 -04:00
apartfromtime
45f4e1860c Check for null and free correct number of directories
Potential errors.
2022-08-21 11:31:09 +10:00
apartfromtime
4c7ab467f8 Dangling pointer on free
Won't need the guard pointer.
2022-08-19 16:05:21 +10:00
apartfromtime
73427b77a2 Convert model info from AOS to SOA
Converted model info from AOS to SOA
All strings allocated dynamically at run-time
New command "playermodels" prints valid models to console
Fixes any bugs that may have existed in the directory search

The issue still exists of undefined behavior if a directory name for a
model exceeds the predefined limits.
2022-08-19 15:22:22 +10:00
apartfromtime
acea0c54d9 Remove player skin box bounds check introduced in #866
Failure produces black screen.
2022-08-13 10:09:05 +10:00
apartfromtime
e87f025d13 Merge branch 'master' into ui 2022-08-13 10:08:02 +10:00
apartfromtime
de051f248c Make skin icon bitmap part of the player setup menu
Adding menu bitmaps makes this possible.
Bounds check on skin box current value.
2022-08-06 13:20:21 +10:00
Jaime Moreira
5f59b752c0 Scope fixed for some cvars
Old sliders required some of their associated cvars to be "extern" so
their current value could be read. That's no longer needed, so they are
"static" now.
2022-07-30 14:29:38 -04:00
Jaime Moreira
6c4866995b Enhanced sliders for menus
"menuslider_s" types, used to create sliders in menus, now are directly
associated to a cvar. That makes possible for them to get their
currently selected value from the cvar, and express their min and max
values in terms of the real values of the cvar.
The rhythm at how they change can be overridden with s->slidestep.
The new sliders also present visually their current value to the user,
making them more useful than before.
2022-07-30 14:23:33 -04:00
Yamagi
90eb2f394d
Merge pull request #862 from devnexen/glrenderer_drawparticles_sig
R_DrawParticles2 signature slight change fixing build warning.
2022-07-22 10:14:37 +02:00
Yamagi
2cb98b7a1d
Merge pull request #857 from protocultor/gyro_bluetooth
Gyro aiming through Bluetooth for PS4 & PS5 controllers
2022-07-22 09:53:00 +02:00
David Carlier
136222d4d7 R_DrawParticles2 signature slight change fixing build warning. 2022-07-20 22:54:42 +01:00
Yamagi
aaffcf81b0
Merge pull request #861 from devnexen/client_pingserverfix
client ping server fix unitialized field.
2022-07-17 12:24:35 +02:00
Yamagi
91fd76ca5d
Merge pull request #860 from apartfromtime/ui
UI code maintenance
2022-07-17 12:24:20 +02:00
David Carlier
024d065f80 client ping server fix unitialized field. 2022-07-16 19:44:30 +01:00
apartfromtime
affea5aef3 Remove menu number of slots property
Remove unused and dead code.
2022-07-15 12:51:01 +10:00
apartfromtime
c0bad27f43 Pre-calculate x, y offsets
Make code easier to read.
2022-07-15 12:47:41 +10:00
Jaime Moreira
0bb2bf0cea Increased sensitivity range for controllers on menu 2022-07-07 23:43:02 -04:00
Jaime Moreira
1fa432f695 Gyro aiming through Bluetooth for PS4 & PS5 controllers 2022-07-05 19:15:10 -04:00
Yamagi
95eabefec9
Merge pull request #856 from apartfromtime/ui
Iterate once through menu item list
2022-06-25 17:28:40 +02:00
apartfromtime
c03f4fd094 Iterate once through menu item list
Avoids any infinite loop cases.
2022-06-25 14:17:58 +10:00
David Carlier
a635721c50 client download, sets a sane connection timeout, the default being way to high. 2022-06-24 20:49:23 +01:00
Yamagi
c6f6a17176
Merge pull request #849 from protocultor/gyro_aiming
Gyro aiming
2022-06-17 13:07:25 +02:00
Jaime Moreira
35495fb6f2 Readability improved for gyro calibration & controller hotplug code
"init_delay" was renamed to "updates_countdown", since it's now a "general
purpose" countdown, having also to count the inputs left for gyro calibration,
besides controller initialization.
Reason for the countdown is now explicit, not having to depend if
"gyro_calibration" was true or not to select what was the purpose of the
countdown.
Explanation comment added for gyro initialization on Linux & Mac.
REMINDER: see if SDL2 will keep the difference of gyro readings between Windows
and Linux/Mac for the Switch controllers.
2022-06-14 16:16:47 -04:00
Yamagi
ca70f8e679
Merge pull request #851 from devnexen/download_limits
client download, adding two new cvar to have the ability to set
2022-06-13 08:08:52 +02:00
Daniel Gibson
86811a4c24 Fix fallback when window couldn't be created because renderer is unsupported
For example, on Windows with AMDs drivers, GLES3 isn't supported,
so CreateSDLWindow() will fail. We should just try the regular GL3
renderer then instead of exiting with Com_Error()

Also make (Windows') Sys_Error() print to stdout (in addition to stderr),
so errors end up in stdout.txt as well (like all other messages).
2022-06-11 17:57:29 +02:00
Yamagi
a1dddaede3
Merge pull request #846 from devnexen/vla_0_fix
GL1 renderer fix VLA with no size cases,
2022-06-11 16:40:48 +02:00
Yamagi
a8ae79c6ab Remove twi unsused declarations. 2022-06-11 16:40:15 +02:00
David CARLIER
a01309235b client download, adding two new cvar to have the ability to set
a threshold to abort the download if a certain transfer rate is too low.
Disabled by default.
2022-06-11 13:41:24 +01:00
Jaime Moreira
df399576a2 Gyro normalization value in Windows improved
SDL2 provides different gyro readings between Windows and Linux/Mac for
the Switch Pro Controller. To keep the natural sensitivity scale intact
(in-game turn = controller turn), the normalization factor is handled
differently by platform, at least for now.
Also, now giving info when there's no gyro sensor available/detected.
And green light for the DualShock 4, because why not :)
2022-06-10 22:31:24 -04:00
apartfromtime
353295d0c7 Infinite loop in bind menu fix
Bug introduced in #841.
Added QMF_INACTIVE.
QMF_INACTIVE menu items are skipped.
2022-06-11 09:17:49 +10:00
Jaime Moreira
077d861a57 Gyro aiming menu options
"Gyro mode", "axis to turn" and "sensitivity" grouped with calibration.
2022-06-07 09:49:47 -04:00
Jaime Moreira
f12b759feb Gyro aiming configuration cvars
Cvar to choose between "yaw" (0) or "roll" (1) axis of the controller
to turn (change your yaw) in-game.
Cvars to change pitch and yaw gyro sensitivities.
Updated cvar documentation with new section "Game Controller".
2022-06-07 09:34:45 -04:00
Jaime Moreira
d3da95cfc8 Gyro aiming implementation
SDL 2.0.16 and a controller with a gyroscope required to make it work.
Manual calibration of the gyro sensor is needed to avoid "drifting"; a menu
option to do it is included.
New cvar 'gyro_mode' for mode of operation, and to assign action to the new
"+gyroaction" button: disable or enable the gyro.
2022-06-07 09:24:08 -04:00
Yamagi
a80f5b6cd7
Merge pull request #844 from protocultor/inventory
Inventory screen keys/buttons display fix
2022-06-07 14:22:23 +02:00
Yamagi
1cd347beb7
Merge pull request #843 from devnexen/fbsd_build_warnings
freebsd/clang and server only warnings build fix
2022-06-07 14:20:59 +02:00
Yamagi
82a280bc40
Merge pull request #841 from apartfromtime/ui
Add menu bitmap support
2022-06-07 14:19:26 +02:00
apartfromtime
42e85a207a Cache cursor frames
Bug fix. Missed bringing this over from my other failed pull request.
2022-06-05 13:28:58 +10:00
David Carlier
4a60ba634c GL1 renderer fix VLA with no size cases, 2022-05-29 14:43:28 +01:00
Yamagi
ba2fc77ee8 Enforce a minimal render (dsiplay) time for dlights of 32 milliseconds.
Several effects use dlights which are rendered for only one frame.
Muzzle flashes are an example. While this worked on 1997th computers,
todays hardware renders way too many frames for these dlights to be
visible at all. Work around that by enforcing a minimal display time
of 32 milliseconds for each dlight.

Fixes part of #815.
2022-05-28 16:44:29 +02:00
Jaime Moreira
0419cd7931 Inventory screen keys/buttons display fix
When a key/button name is too long, and its bound to an inventory element, its
display in the inventory screen misaligns the item it is bound to, even pushing
it out of the inventory frame.

This commit limits its display to the maximum of 6 characters the inventory
screen allows.
2022-05-21 22:59:02 -04:00
apartfromtime
7e1bc6911b Code style changes
Tabs to white-space.
BSD style.
2022-05-22 05:52:25 +10:00
David CARLIER
aaf6489d21 freebsd/clang and server only warnings build fix 2022-05-21 20:19:04 +01:00
apartfromtime
809588798e De-align apply action
Draw the "apply" action string from right to left, with no alignment.
2022-05-21 22:22:10 +10:00
apartfromtime
07fc65f9c5 Add menu bitmap support
Adds menu bitmap struct, drawing of a menu bitmap and highlighting if bitmap menu item is in focus.
Allows items that are gray (inactive) to be skipped when adjusting the menu cursor.
Removed switch case from Menu_SelectItem, all items either do or do not call their callback functions.
2022-05-21 22:21:29 +10:00
Yamagi
12c7fddfaa
Merge pull request #827 from protocultor/sdlcontroller
Full transition to SDL_GameController for gamepad usage
2022-05-17 19:42:19 +02:00
Daniel Gibson
7cf1392765 Qcommon_Frame(): Improve max framerate handling when vsync is enabled
When setting rfps based on GLimp_GetRefreshRate() and vid_maxfps,
take into account that GLimp_GetRefreshRate() might return a value
that's slightly too low (like 58 or 59 when it's 59.95 and should be 60)

The 20% tolerance that, in case of vsync enabled, used to be handled
with `packetdelta < 0.8 * 1000000/pfps` (and the same for rfps) is now
instead added to rfps (and thus implicitly pfps, if it's >= refreshrate)
2022-05-09 01:43:08 +02:00
Jaime Moreira
422715cee2 Hot plugging / hot swapping of game controller(s)
May be unreliable on some devices, e.g. Nintendo Switch Pro Controller.
Works great on others, e.g. DualShock 4.

Delay added to gamepad initialization on hotplug, gives time to the OS to
recognize the device.
2022-05-08 01:05:07 -04:00
Jaime Moreira
20542420ef New controller alt buttons menu option
Allows to bind buttons that only will work with "+joyaltselector" active.
The definition of another "scope" of keys was needed, to identify ALT bindings.
2022-05-08 00:24:52 -04:00
Jaime Moreira
0aa44afa13 New customize controller buttons menu option
Handles game controller button bindings exclusively.
Classic "customize controls" option now handles only keyboard / mouse bindings.
This separation is achieved with the new order of QKEYS in keyboard.h, and
binding functions in menus (especially "MenuKey" functions) now take into
account the "scope" where they operate: keyboard/mouse only, controller only,
or both.
2022-05-07 23:55:00 -04:00
Jaime Moreira
d4100f7113 Menu inputs standardised
Streamlined menu inputs by making most "*_MenuKey(key)" functions to use
Key_GetMenuKey(). "Backspace" is not a special case anymore, so any menus
that have a "delete" option can already handle any input expected, like the
backspace or delete keys, or the "Y" button of the controller, to run it.

Also, fixed a bug where changing the key for "team chat" also changes the one
for "chat" in the "multiplayer" -> "customize controls" menu.
2022-05-07 22:45:44 -04:00
Jaime Moreira
2bb1b33d7e Full transition to use only SDL_GameController for gamepad
This removes the usage of SDL_Joystick for joystick buttons and hat, and
relies exclusively on SDL_GameController for input. This allows to identify
buttons in a consistent manner across multiple types of controllers, which
in turn allows to assign specific tasks to them without worrying of breaking
usability, like having "A" to accept and "B" to cancel in menus.

Init and Shutdown logic of game controller have been separated from main SDL
Init and Shutdown functions.

Old style button names "JOYx" have been removed.

If your gamepad has paddles or other extra buttons, you'll need at least
SDL version 2.0.14 to use them.
2022-05-07 21:26:50 -04:00
Yamagi
e294fc94e5
Merge pull request #822 from DanielGibson/gles3-rb
OpenGL ES 3.0 support
2022-05-07 09:45:30 +02:00
David Carlier
c34071d05c curl client show progress only when there actually some 2022-05-07 07:03:40 +01:00
Daniel Gibson
56e1b9bc1e Add gles3 renderer to videomenu 2022-04-27 00:33:46 +02:00
Daniel Gibson
0881a63b1e GLES3: Explicitly don't handle gl_drawbuffer
GLES can't render to the front-buffer
2022-04-27 00:33:46 +02:00
Daniel Gibson
a195305592 GL3: Fix particles on RPi4
tested V3D 4.2; OpenGL ES 3.1 Mesa 20.3.5
2022-04-26 04:10:57 +02:00
Daniel Gibson
89f63915a3 GLES3: Make newer shaders work with OpenGL ES 2022-04-26 04:09:38 +02:00
Daniel Gibson
c936e43420 GL3: Use one projection-view matrix in shaders
instead of separate projection and view matrices - this way there is
one less mat4 multiplication in the 3D vertex shaders.
2022-04-26 04:09:38 +02:00
Daniel Gibson
1eabde6b55 GL3: Make GLES3 work on Raspberry Pi 4B
(older Raspberry Pi versions don't support OpenGL ES 3.0, only 2.0)
2022-04-26 04:09:38 +02:00
Daniel Gibson
8737ce64fc GL3: Support OpenGL ES3.0 (compile time option GL3_GLES=yes)
the option defaults to no, of course.
2022-04-26 04:09:38 +02:00
Daniel Gibson
c6145b4e6a GL3: Only use FBO if under water
because on some systems (like RPi4 with my experimental GLES3 branch)
the overhead of a FBO is really noticeable, so no reason to pay for it
when it's not needed
2022-04-26 04:08:21 +02:00
Daniel Gibson
3d619a1441 GL3: Implement underwater postprocess effect using framebuffer object
Can be disabled with gl3_usefbo 0.
Mostly this adds an underwater warping effect, like the soft-renderer,
and also like the vulkan renderer (the shader is based on the vk one).
When this is enabled, the v_blend effect (for fullscreen overlay with
one color, like when hit or to make the screen white-ish when under
water) is now applied in the shader used for rendering the FBO instead
of rendering a fullscreen quad in blendmode.
2022-04-25 17:44:51 +02:00
Yamagi
4db6534ab3 Implement damage tracking for the framecounter.
This fixes the framecounter in the soft renderer when `viewsize` is set
to something smaller than 100. This requires the renerer to rerender
bigger parts of the borders which has a measurable speed impact. About
5 frames less with the framecounter enabled on my system. No impact with
`viewsize 100`.
2022-04-24 00:17:48 +02:00
Yamagi
be3e0cc695 Fix viewsize not working correctly with the GL renderers.
The GL renderers require that the borders are redrawn after every
glClear() call, the damage tracking doesn't take that into account.
Since the speedup by the damage tracking is neglibiable in the GL
renderers, don't use it. Just redraw everything when we're running
with everthing which isn't the soft renderer.
2022-04-24 00:01:14 +02:00
Yamagi
a9a0c35a98 Rename the nightmare menu entry to hard+.
I think this looks ugly, I always called it nightmare and it was one of
the first changes I've made to Quake II. But for the sake of peace and
quiet change it to be standard conformant. Closes #809.
2022-04-23 16:35:27 +02:00
Yamagi
aa5d6636d6
Merge pull request #814 from protocultor/gamecontrollerdb
Load gamecontrollerdb.txt for SDL2 joy mappings
2022-04-23 16:21:09 +02:00
Denis Pauk
b2500d6aed soft: revert to use colormap
Apply light uses colormap for each color components with colorlights.
2022-04-17 23:25:22 +03:00
Denis Pauk
afc892001d soft: move light code to separate function 2022-04-17 23:07:38 +03:00
Denis Pauk
a58fb0ed01 soft: fix colors 2022-04-17 23:07:38 +03:00
Denis Pauk
96a78c41c8 soft: speedup apply grey light to wall 2022-04-17 23:07:38 +03:00
Denis Pauk
e1d5bad4db soft: fix grey light with fix c20c47b0 2022-04-17 23:07:38 +03:00
Jaime Moreira
45d8228dff Corrected silly string concatenation 2022-04-16 11:53:22 -04:00
Jaime Moreira
db0e643419 Load gamecontrollerdb.txt for SDL2 joy mappings 2022-04-16 01:37:15 -04:00
Jaime Moreira
fadb281ec9 Added cvar to define SDL gamepad's 'Back' button 2022-04-06 22:15:14 -04:00
Yamagi
9d451faca5
Merge pull request #808 from devnexen/sw_useq
S/W last instance of strncpy usage.
2022-04-03 17:46:58 +02:00
David Carlier
2425082a04 S/W last instance of strncpy usage. 2022-04-03 14:58:04 +01:00
Denis Pauk
ccb22843bf soft: use float for medium light 2022-03-29 22:29:28 +03:00
Denis Pauk
e650eff100 soft: preshift values in lightmap 2022-03-29 22:29:28 +03:00
Denis Pauk
020ce27109 soft: speedup colorlight=0
colorlight>0 is regressed little bit.
2022-03-29 22:29:28 +03:00
Denis Pauk
a0da1717cc soft: use max light in blocklights (colorlight=0) 2022-03-29 22:29:28 +03:00
Denis Pauk
3b825670ba soft: fix lightmap mask 2022-03-29 22:29:28 +03:00
Denis Pauk
c20c47b06f soft: skip light apply on wall's 2022-03-29 22:29:28 +03:00
Denis Pauk
ff1814922e soft: use vid_lightthreshold for skip apply light 2022-03-29 22:29:28 +03:00
Denis Pauk
c73eac63b3 soft: rename r_colorlight -> sw_colorlight 2022-03-29 22:29:28 +03:00
Denis Pauk
b5d45d0371 soft: use lightmap convert table 2022-03-29 22:29:28 +03:00
Denis Pauk
6af5dc1d98 soft: more use of light3_t 2022-03-29 22:29:28 +03:00
Denis Pauk
5eed0ca5d9 soft: reuse R_Alias_clip_scale 2022-03-29 22:29:28 +03:00
Denis Pauk
5fcf0a3afc soft: resuse compact vert_t 2022-03-29 22:29:28 +03:00
Denis Pauk
3f33522977 soft: use separate light3_t 2022-03-29 22:29:28 +03:00
Denis Pauk
480f278045 soft: directly copy r_ambientlight 2022-03-29 22:29:28 +03:00
Denis Pauk
6c80d9b987 soft: add full color light 2022-03-29 22:29:28 +03:00
Denis Pauk
a6839bc584 soft: add fullcolor light apply 2022-03-29 22:29:28 +03:00
Denis Pauk
15553b9971 soft: use plightvec directly 2022-03-29 22:29:28 +03:00
Denis Pauk
36542e737c soft: make pointcolor local 2022-03-29 22:29:28 +03:00
Denis Pauk
65f8c171c5 soft: use named struct vert_t instead array 2022-03-29 22:29:28 +03:00
Denis Pauk
f8cac738dc soft: sw_light: make variables local 2022-03-29 22:29:28 +03:00
Denis Pauk
512e128c5a soft: save full rgb light in model 2022-03-29 22:29:28 +03:00
Denis Pauk
7c31fd9de2 soft: sync model light calculation 2022-03-29 22:29:28 +03:00
Daniel Gibson
5535773521 GL1: Fix setting gl1_particle_square, fixes #805
both if GL pointparameters are used or not
(though depending on driver and hardware the pointparameters-based
 particles *might* be always square or always round, regardless of
 gl1_particle_square - that's driver-bugs which we can't fix, disable
 pointparameters with `gl1_pointparameters 0` to work around it, or
 just use the GL3 renderer)
2022-03-29 20:30:00 +02:00
Daniel Gibson
f7386eb296 Fix bug in (no)lerp logic in GL1
refs #805
2022-03-26 23:40:05 +01:00
Daniel Gibson
cc0eabffed Implement gl3_colorlight, when set to 0, render lights without color
like the (original) software renderer. defaults to 1, of course
2022-03-26 19:48:11 +01:00
Daniel Gibson
6eb9ca0f65 Add r_lerp_list and r_videos_unfiltered CVars, fix #800
r_lerp_list is to allow exceptions to r_2D_unfiltered (like for having
pixely UI in general, but filtered console background).

r_videos_unfiltered controls whether videos should be filtered or not

I also made r_nolerp_list CVAR_ARCHIVE, like users probably expect it.
2022-03-20 12:16:15 +01:00
Daniel Gibson
09ede9cf47 Make basename() fully compliant and simplify it a bit 2022-03-12 17:01:37 +01:00
Daniel Gibson
4a02c790e9 MSVC: Don't use YQ2_VLA() in loops
because on MSVC it uses alloca() (or _malloca()) which mustn't be called
in loops, as the memory is only freed when returning from the function,
not when leaving the scope (or before the next loop iteration).

Instead do one "dry-run" iteration to figure out how big the array must
be at most, and then allocate it once before the loop with that size.
2022-03-12 17:01:37 +01:00
Daniel Gibson
37b1b708c6 Fix some legitimate warnings from MSVC
MultiByteToWideChar() and other functions handlings WCHAR strings usually
expect length-like arguments in number of WCHARs, not in size in bytes
2022-03-12 17:01:37 +01:00
Daniel Gibson
ed918cf423 CMake: Make the game build with Visual Studio (2019 16.8 or newer)
The easiest way to build this is to check out the dhewm3-libs project
(https://github.com/dhewm/dhewm3-libs/) to provide the dependencies
(SDL2, OpenAL, cURL) and set YQUAKE2LIBS accordingly, by passing
-DYQUAKE2LIBS=c:/path/to/dhewm3-libs/i686-w64-mingw32 to cmake.

I wouldn't really recommend building with MSVC - I just somehow made it
work and ignored all the warnings and I have no idea how portable the
resulting binaries are etc. For binaries you actually want to use, please
continue using MinGW-w64. Especially my workaround for VLAs (C99 variable
length arrays) is kinda fishy, particularly if those arrays are allocated
in a loop (that's inly done in ref_gl1.dll's code).

The only reason I did this is that I had to debug on Windows and, at least
for my specific bug, gdb didn't really work with binaries produced by
MingGW-w64 and MSVC's debugger works well with binaries produced by MSVC.

Currently requires VS 2019 16.8 or newer with C11 (/std:c11) because I
couldn't get YQ2_ALIGNAS_TYPE() to work with MSVC without _Alignas().
If we can get this to work, VS2015 or newer might suffice (but not older
versions, because their so called C standardlib didn't provide exotic
functions like snprintf()).

# Conflicts:
#	CMakeLists.txt
2022-03-12 16:55:55 +01:00
Yamagi
fca041c3ea
Merge pull request #792 from devnexen/cl_parse_overflow_fix
CL_ParseEntityBits overflow warning fix
2022-02-26 16:19:17 +01:00
David Carlier
ff3315d5d6 Haiku doc update, little code style fixes. 2022-02-26 08:35:10 +00:00
David Carlier
ca4e5ef935 CL_ParseEntityBits overflow warning fix 2022-02-21 08:39:08 +00:00
Yamagi
e7df0977b0
Merge pull request #789 from apartfromtime/dev
Confirm delete save game through status bar update
2022-02-13 09:44:01 +01:00
apartfromtime
a7b90aaa24 Amend white-space error 2022-02-13 09:30:48 +11:00
Yamagi
b92165a0e1 Fix two unused var warnings introduced by #788. 2022-02-12 17:01:12 +01:00
apartfromtime
298a411b87 Confirm delete save game through status bar update 2022-02-12 14:56:08 +11:00
Denis Pauk
138fce15ea gl1,gl3: sync model light calculation 2022-02-05 18:54:38 +02:00
Denis Pauk
b4fb6db4fc gl1,gl3: rename gl_lightmap->r_lightmap 2022-02-05 18:54:38 +02:00
Denis Pauk
f1ac7cafbf soft: add r_lightmap implementation 2022-02-05 18:54:38 +02:00
Denis Pauk
eb979d73ed soft: resuse image load code for wal 2022-02-05 18:54:38 +02:00
Denis Pauk
0c2bf1f65d soft: use pixel_t in skin and load lightmap 2022-02-05 18:54:38 +02:00
Yamagi
896bb48d36
Merge pull request #780 from devnexen/m_main_draw_fix
menu code unused var warning fix.
2022-01-22 10:54:27 +01:00
Denis Pauk
a48c7e1850 gl3: Scale 3x for nolerp 8bit textures 2022-01-18 00:02:54 +02:00
Denis Pauk
dcdc37ea35 gl1: Scale 3x for nolerp 8bit textures 2022-01-18 00:02:26 +02:00
David CARLIER
62fba5a29d menu code unused var warning fix. 2022-01-15 15:57:11 +00:00
Denis Pauk
f49235d28a disable sound effect debug prints 2022-01-13 22:54:21 +02:00
Denis Pauk
da4bbd64d6 soft: add const to functions parameters 2022-01-12 22:11:18 +02:00
Denis Pauk
68ad03aac9 sound: fix local variable 'ogg_file' shadows outer variable 2022-01-12 21:55:56 +02:00
Yamagi
6bec90bbdd Use Windows compatible format specifiers. 2022-01-08 18:05:36 +01:00
David Carlier
80ce342557 client curl update.
displaying download progress based on a new cvar, 0 by default.
2021-12-16 14:55:58 +00:00
apartfromtime
aa0ad74e06 Multiplayer\Co-op menu customize controls 2021-11-24 18:42:18 +01:00
BjossiAlfreds
37cfb61b1f Gamemode management improvements
Restored original gamemode prioritization to dm > coop > sp, fixed a bug where server start menu did not clear singleplayer cvar, and rewrote how server init manages gamemode cvars
2021-11-13 11:41:29 +01:00
Yamagi
a05508240f Disable the thread local stuff in stb_image.h, int breaks Windows.
The code is building fine but at startup the rendere library cannot by
loaded: "LoadLibrary returned 126" Disable thread local as a band-aid
fix, it might be worth to have a deeper look and figure out what exactly
goes wrong.

Closes #762.
2021-11-05 15:14:02 +01:00
Yamagi
8bb845b037 Fix potential memory leak in R_Upload8() in GL1.
This is a corner case, next to unlikely that anyone would have ever hit
it. That's why my tests with asan didn't find the leak. The if case are
paletted textures which must be enabled by setting `gl1_palettedtexture`
to 1 and requires an GPU with support for `GL_EXT_paletted_texture`.
Nvidia dropped support for that in 2005. Additionally a sky texture
must be uploaded.
2021-11-01 18:42:40 +01:00
Yamagi
76b501b64b Update stb_vobis.h to af1a5bc.
This brings several small bugfixes and more robust handling of files
without comment / tag header. It's not mentioned in the changelog,
but at least for dhewm3 updating to this latest version fixed some
problems with missdecoded files on MacOS when running on the M1 aarch64
CPUs.
2021-11-01 16:49:47 +01:00
Yamagi
67f22cce17 Update std_image and stb_image_resize to af1a5bc.
This brings a lot of bugfixes, most of them are irrelevant for us. At
least as long as the game is run with standard assets...
2021-11-01 16:41:22 +01:00
Yamagi
8dde5b8539 Replace hard coded array with malloc() to prevent stack overflow.
This was an issue an Windows with it's small stack. It didn't trigger on
Linux. While at it make the code a little bit more robust by allocating
exactly the amount of data we need and not some arbitrary guess.
2021-10-31 17:08:30 +01:00
Daniel Gibson
3873c76e12 Add r_2D_unfiltered CVar, improve r_nolerp_list handling
Setting r_2D_unfiltered to 1 (0 is default), 2D elements (GUI, menu,
console) are rendered without texture filtering in GL1 and GL3, while
everything else is still rendered with whatever is set in gl_texturemode

This setting (and now also gl_nolerp_list) is applied immediately,
so no vid_restart is needed.

refs #752
2021-10-30 20:42:43 +02:00
Denis Pauk
1e0d75857b Use separate r_scale8bittextures for image scale
Rename {sw,gl}_retexturing variables to r_retexturing in code.
2021-10-17 11:11:05 +03:00
Denis Pauk
c280c408b1 dont collect statistics with cl_showfps=0 2021-10-16 23:27:56 +03:00
Denis Pauk
11bb96401f soft: set current frame before use worldentity 2021-10-16 12:35:22 +03:00
Denis Pauk
7576d2d300 gl3: make currententity local 2021-10-16 12:35:04 +03:00
Denis Pauk
46c654b379 gl1: use local currentmodel 2021-10-16 12:34:32 +03:00
Denis Pauk
93ab5896e9 gl3: port submodel load code from vk render(8bd39ad5) 2021-10-16 12:34:23 +03:00
Denis Pauk
84773d7d79 gl3: use local model on load(35d598bc) 2021-10-16 12:34:15 +03:00
Denis Pauk
423c3fa299 gl3: preserve cache on free slots in image and models list(aa6032f0) 2021-10-16 12:33:51 +03:00
Denis Pauk
330830fc38 gl1: preserve cache on free slots in image and models list(aa6032f0) 2021-10-16 12:33:13 +03:00
Denis Pauk
e3a83c6b32 add const to Mod_ClusterPVS 2021-10-16 12:32:04 +03:00
Denis Pauk
f3f8c9a1f6 soft: make r_worldentity local 2021-10-15 23:39:34 +03:00
Denis Pauk
083cfca305 gl1: make currententity local 2021-10-15 23:37:56 +03:00
Denis Pauk
2d1a090feb gl: use local currentmodel 2021-10-15 23:37:56 +03:00
Denis Pauk
2c942d83f1 gl: use local model on load(35d598bc) 2021-10-15 23:37:56 +03:00
Denis Pauk
d8eb64cdcd gl1: port submodel load code from vk render(8bd39ad5) 2021-10-15 23:37:53 +03:00
Denis Pauk
34fb8d45b0 soft: Use common RadiusFromBounds 2021-10-15 23:30:56 +03:00
Denis Pauk
a9d6939297 gl: use lower MSAA value on error 2021-10-15 23:30:56 +03:00
Denis Pauk
0bbd65ebac gl1: Scale 8bit images with retexturing=2 2021-10-15 23:30:56 +03:00
Denis Pauk
58af4c84ff gl3: Scale 8bit images with retexturing=2 2021-10-15 23:30:56 +03:00
David Carlier
6cb2981c9c sw/gl1 client Mod_PointInLeaf sig mismatch. 2021-10-08 21:38:34 +01:00
Yamagi
f4f61c1f27 Add g_machinegun_norecoil to the list of cheat proteced cvars. 2021-09-28 18:37:56 +02:00
apartfromtime
a737500f89 Consistent naming 2021-09-21 14:18:25 +10:00
Denis Pauk
ea272241a4 soft: Use SmoothColorImage as r_anisotropic 2021-08-08 23:34:47 +03:00
Denis Pauk
aa6032f00f soft: preserve cache on free slots in image and models list 2021-08-08 17:43:14 +03:00
Denis Pauk
35d598bce6 soft: use local model on load 2021-08-07 23:03:48 +03:00
Denis Pauk
8bd39ad5dd soft: port submodel load code from vk render 2021-08-07 17:24:39 +03:00
Denis Pauk
a8b02d4725 Sound: unload only on run of slots 2021-08-07 10:38:02 +03:00
Yamagi
e2e2bddfa3 Fix demo loop after changing the game through the menu.
Injecting the demo loop right after the `game` cvar was changed cannot
work: The demo loop is implemented through aliases, aliases are expended
as soon as they're added to the command buffer. However, the game isn't
changed as soon as the cvar is set, but the next time when the control
flow enters the file system. Therefor the aliases get expanded to the
wrong game and the demo loops breaks.

This closes #719.
2021-07-25 09:45:51 +02:00
Denis Pauk
7f1fd069f4 use LittleShort in S_GetStatistics and S_GetVolume 2021-06-26 15:23:07 +03:00
Denis Pauk
c4526bac51 Sync haptic effect to sound track 2021-06-26 15:23:07 +03:00
Yamagi
d9d5552662
Merge pull request #717 from 0lvin/ogg_sound
Add ogg/vorbis sound for effects
2021-06-25 10:18:41 +02:00
Yamagi
21483dc1bd
Merge pull request #718 from Spirrwell/master
Fix some leaks
2021-06-19 08:48:54 +02:00
Denis Pauk
408e7d9a99 Scale down model preview icon is too big 2021-06-13 15:52:48 +03:00
Denis Pauk
7be959894b fix line duplication 2021-06-13 15:46:16 +03:00
Denis Pauk
d554b89730 sound: cleanup ogg to wav code 2021-06-13 15:46:16 +03:00
Denis Pauk
fbde7b753f fclose is not required with close_on_free=true 2021-06-13 15:46:16 +03:00
Denis Pauk
bf286dc952 Add ogg/vorbis sound for effects 2021-06-13 15:46:16 +03:00
Daniel Gibson
dc7ad65bb0 Fix crash in soft renderer
RE_Draw_StretchPicImplementation() would write up to
height+picupscale-1 lines.
That overflows the buffer so make sure it doesn't.
2021-06-04 13:38:14 +02:00
Spirrwell
b9129f2fa8 Fix some leaks
Most of these are probably "harmless", but I could definitely see the missing/improper SDL_Quit/SDL_QuitSubsystem causing headaches later.
2021-06-02 19:45:34 -04:00
Yamagi
8f6a085434 Remove ref_vk, the Vulkan renderer ported from vkQuake2.
While having a Vulkan renderer in Yamagi Quake II sounded like a good
idea, especially for cheap hardware with broken OpenGL drivers, the last
weeks showed that the code is not ready for primetime. Some examples
for critical problems:

 * Render glitches when using non-standard assets. Everything with more
   polygons and texture resultion than baseq2 seems to be broken.
 * The startup and shutdown code is a mess. While I fixes the most
   critical bug, there're a lot of cases left. Startup and shutdown
   mostly works by luck.
 * At least one memory leak in the model code.

And neither @DanielGibson nor myself have deeper knowledge about Vulkan.
We don't have the time and the motivation to learn it. While some
community members did excellent work on ref_vk (especially @0lvin and
@rg3), the community maintenance promised in the initial pull request
never really materialized. Therefor we risk ending up with a renderer
that we can't and won't maintain by ourself.

Vulkan is not gone. The code will be recommitted in a separate
repository at: https://github.com/yquake2/ref_vk

We're willing to give community members commit access to that
repository. Send a substantial pull request and ask for it.
2021-05-28 09:33:46 +02:00
Yamagi
84312ae8b7 Check if renderer lib exists before loading it.
This is a noop change, we're just bailing out somewhat earlier.
2021-05-28 09:32:42 +02:00
Yamagi
496985eb90 'Unknown renderer' as upper entry point to the fallback magic.
This is next to no functional change, the only difference to before is,
that the Vulkan renderer is treated as an unknown renderer. gl3 is the
first regular fallback.
2021-05-28 09:32:42 +02:00
Yamagi
ffddd0f7c9 Unify renderer lib path generation.
This makes sure that all users of the renderer lib have the same world
view.
2021-05-28 09:32:42 +02:00
Yamagi
6822da851e Move renderer availability check into vid.c, rename to VID_HasRenderer. 2021-05-28 09:32:42 +02:00
Yamagi
ddce6691e2 Let the video menu skip over non existent renderer libs.
Unitl now the video menu showed all known renderer libs (gl1, gl3, vk
and soft), regardless if the lib was available or not. Rework the
renderer selection logic to skip over non existent renderer libs:
Generate an array combining the menu string and cvar string of all
available renderer libs, use this array instead of the hardcoded array.
While at it simplify the code a little bit.
2021-05-28 09:32:42 +02:00
Yamagi
968cd4248d Bump max number of OGG/Vorbis files to 128.
Requested in #714, closes #714.
2021-05-12 18:11:26 +02:00
Daniel Gibson
002498c33d framerate-independent turning of player-model in multiplayer menu
fixes #701
2021-05-08 18:59:52 +02:00
Daniel Gibson
ea51d5f924 Add r_listmodes, change one comment and a message
r_listmodes does the same as vid_listmodes, but is more consistent with
r_mode

the rest is cosmetical
2021-05-08 18:58:24 +02:00
Yamagi
2e8e6088b3 Add logic to prevent Vulkan restart loops.
So far I haven't seen a restart loop, but at least in theory they'e
possible. Because its hard to break out of such loop, especially on
Windows were interaction with the taskmanager is required, play save
and restart max. 3 times in a row.
2021-04-30 13:14:29 +02:00
Yamagi
950ec0d67e Lower vkAcquireNextImageKHR() timeout to 500 milliseconds.
The timeout specifies how long Vulkan waits for the next frame becoming
available. On the one hand we need to take the vsync or the possibility
that we get scheduled away for longer times into account. On the other
hand we don't want to wait for too long, the game may run into the
timeout after its windows was minimized, etc. 500 milliseconds sounds
like a good compromise.
2021-04-30 13:14:29 +02:00
Yamagi
7ea425ee25 Handle VK_TIMEOUT, may lead to restart loops. 2021-04-30 13:14:29 +02:00
Yamagi
c543d3cc05 Work around maximal extent size of 0x0 when the game is minimized.
Some GPU drivers set a maximal extent size of 0x0 when the window gets
minimized. One example is Intel on Windows. A swapchain with extent
size of 0x0 is invalid, so we cannot reinitialize the renderer... Work
around that by postponing the restart as long as the maxmimal extent
size stays 0x0.

This could should be done in the client (don't call into th renderer
when the window is minimized), but it would need a lot of changes
to the client <-> renderer interactions. So take the easy route.
2021-04-30 13:14:29 +02:00
Yamagi
dd80702913 Add a function QVk_CheckExtent() to query the extent state.
This will be used to detect if we've got an extent size of 0x0 because
the window has been maximized.
2021-04-30 13:14:29 +02:00
Yamagi
0ccf1e8ef8 Make current frame as not started after vk init / shutdown.
The client might call into the renderer after it was shut down by
`VID_ShutdownRenderer()` or initialized `VID_LoadRenderer()`. This
is arguably a client bug, but hard to fix on client side and not
a problem for all other renderers. Work around it by marking the
current frame as 'not started' at Vulkan shutdown and init.
2021-04-30 13:14:29 +02:00
Yamagi
a38084c621 Move QVk_Postinit() from render init to context init.
This is more in line with the rest of the code. Reinitializing the
internal state when building a new context is saver than relying on
Vulkan telling us that something is wrong an reacting to that.
2021-04-30 13:14:29 +02:00
Yamagi
1f4082c419 Call QVk_WaitAndShutdownAll() on context shutdown.
Just calling `QVk_Shutdown()` is wrong. It doesn't wait for Vulkan to
finish, which can cause crashes. And it leaks some ressources which
makes the GPU driver unhappy.
2021-04-30 13:14:29 +02:00
Yamagi
3cf786e158 Ensure that the vk renderer isn't init or shutdown twice.
The ref_vk renderer was written for vkQ2 which has differend renderer
<-> client semantics. In YQ2 we can end up initializing or shutting the
renderer down several times. Not by the client, but by the client not
knowing of the renderer has already initialized / shutdown it's internal
state. This is fatal, leading to ressource leaks, crashes and other fun.

Introduce a new global variable `vk_initialize` and use it to track if
we're initialized or not.
2021-04-30 13:14:29 +02:00
Yamagi
c88c299172 Fix playback of OGG/Vorbis files with != 2 channels.
This was a stupid bug and the code worked just by luck, but only with
stereo files. Because sizeof(short) == 2 and ogg_file->channels.
2021-04-24 17:48:28 +02:00
Yamagi
ef248cbe6a Port the vk renderer to the new ref restart API.
Since `vid_fullscreen` isn't special anymore, it's completely handled by
`Vid_Restart_f()`, which in turn simplifies the spaghetti code in the vk
renderer. If I understand that glibberish correctly the only we need to
handle is the partial restart in `QVk_Restart()`.
2021-04-11 11:23:45 +02:00
Yamagi
fa30a41c5e Port the soft renderer to the new ref restart API. 2021-04-11 11:23:45 +02:00
Yamagi
01fa2cfc1c Port the gl1 renderer to the new ref restart API. 2021-04-11 11:23:44 +02:00
Yamagi
27a021eb7c Port the client to the new restart API.
This fixes the video menu and alt-tab when running a renderer that uses
the new API.
2021-04-11 11:23:44 +02:00
Yamagi
a5102f47dd Port the gl3 renderer to the new ref restart API. 2021-04-11 11:23:44 +02:00
Yamagi
09d645ab4b Extend the ref import API with Vid_RequestRestart().
This function will be used to replace the vid_fullscreen->modified
mechanism used the communicate renderer configuration restarts to the
client with a proper proper API. The implementation is backward
compatible, existing renderers are still working.
2021-04-11 11:23:44 +02:00
Yamagi
886ce1525e Port missing !vk_frameStarted guards from vulkanQ2.
Without these guards draw calls may be emitted without having a working
or sane context, leading to crashes in the Vulkan driver.
2021-04-11 11:17:52 +02:00
Yamagi
4fd0369f47
Merge pull request #697 from 0lvin/for_review
soft: fix m8 image load
2021-04-08 11:05:56 +02:00
Denis Pauk
5cc959e501 soft: fix m8 image 2021-04-07 22:58:46 +03:00
David CARLIER
f66d7a9540 Fix segfault when turning the console before the game is launched
(thus audio backend not yet initialised).
2021-04-07 20:17:27 +01:00
Denis Pauk
68a0605582 sw: support full size retextured it_pic 2021-04-07 00:03:04 +03:00
Denis Pauk
e8105810d7 vk: rework lefthand pipeline logic 2021-04-04 13:36:47 +03:00
Denis Pauk
456acfda05 vk: Reuse TriangledFan logic for TriangleStrip 2021-04-04 12:11:11 +03:00
Denis Pauk
f8708a0f76 vk: rename triangle_{fan}_index_count 2021-04-04 10:46:35 +03:00
Denis Pauk
b2ff95249e vk: fix water on jail1 level 2021-04-03 13:31:21 +03:00
Denis Pauk
ec013874a0 check vert realloc in vk and vert list overflow in model 2021-04-03 13:31:05 +03:00
Denis Pauk
0b821a49c3 ref_vk: Reallocate mesh verts 2021-04-01 00:26:55 +03:00
Denis Pauk
bef9485859 Fix vulkan validation warning
VK_WARNING: Validation Performance Warning: [ UNASSIGNED-BestPractices-vkCreateRenderPass-image-requires-memory ] Object 0: handle = 0x58e7d23ea0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x4003982 | Attachment 2 in the VkRenderPass is a multisampled image with 4 samples, but it uses loadOp/storeOp which requires accessing data from memory. Multisampled images should always be loadOp = CLEAR or DONT_CARE, storeOp = DONT_CARE. This allows the implementation to use lazily allocated memory effectively. (performance)
2021-03-31 22:20:01 +03:00
Yamagi
557668c35e
Merge pull request #680 from rg3/vk_restart_tweaks
Vulkan restart tweaks
2021-03-31 19:36:18 +02:00
Ricardo Garcia
6c3261180b Use vid_renderer instead of vid_refresh to re-register clients 2021-03-29 22:15:28 +02:00
Yamagi
1c8077cf61
Merge pull request #683 from devnexen/mapids_code_simpl
map list/little code changes proposal.
2021-03-28 18:32:00 +02:00
David Carlier
7492fd875d map list/little code changes proposal. 2021-03-27 08:10:15 +00:00
Ricardo Garcia
17c2c94f07 Fix memory leak when restarting the Vulkan renderer
models_known needs to be freed after freeing its contents.
2021-03-21 18:30:06 +01:00
Ricardo Garcia
e362e0280e Restart Vulkan renderer at EndFrame instead of BeginFrame
This brings yquake2 closer to vkQuake2 regarding renderer restarts when
the swapchain is out of date, among other situations that trigger a
Vulkan renderer restart.

Basically, the current behavior has the problem that when the renderer
is restarted at the beginning of the frame, the models are lost and we
end up with "ERROR: Mod_PointInLeaf: bad model" when attempting to
render anything after that restart.

To solve this, we move the restart logic to EndFrame and add a twist to
it: we use a vid_refresh variable to signal the server that the client
needs re-registration before starting the next frame cleanly, which will
trigger the registration logic to prepare the models again.
2021-03-21 18:29:38 +01:00
Ricardo Garcia
8891319bc1 Do not reset r_anisotropic to 1 from GL renderers
r_anisotropic can be zero in Vulkan to indicate anisotropic filtering
needs to be completely disabled, instead of enabled with value 1.0.
2021-03-21 11:08:09 +01:00
Ricardo Garcia
f601ffddfc Use the real anisotropic filtering value in Vulkan
When creating the Vulkan texture samplers, make them have the real
anisotropic filtering value selected by the user. This has two side
effects:

* We no longer need two sets of texture samplers in Vulkan (one with and
  another one without anisotropic filtering).

* The anisotropic filter value in Vulkan is no longer an on/off switch
  and we use the value as chosen by the user.
2021-03-21 11:08:09 +01:00
Ricardo Garcia
6f8949fd95 Apply anisotropic filter only when hitting "Apply"
Making the anisotropic filter value only be applied after hitting Apply
in the video menu will make it more natural for the Vulkan renderer to
restart itself when a new anisotropic value is selected, paving the way
to use the actual anisotropic filtering value in Vulkan.
2021-03-21 02:31:09 +01:00
Yamagi
11bcb785d0 Force SDL to minimize the window when focus is lost.
This was the default until 2.0.12 and is what the expects. It changed
with 2.0.14, casing problems with window ordering under windows and
some X11 window managers like kwin.

Do it unconditionally. So we're shure that we're ending with a minimized
windows, no matter what SDL does.

Fixes part of #647.
2021-03-17 09:21:48 +01:00
Denis Pauk
56a8ab6d4d Fix fullscreen value in hacks (f1b6b827) 2021-03-10 23:25:59 +02:00
Yamagi
18a9827b74 When drawing the renderer list, move vk before soft.
The software renderer should be the last option offered to the user,
because it is the weakest renderer.
2021-03-10 10:45:36 +01:00
Yamagi
f1b6b82721 Pull the major release card and switch the semantics of vid_fullscreen
One of the most common bug reports is, that the fullscreen mode doesn't
behave like users expect. This is caused by `vid_fullscreen 1` setting
desktop fullscreen mode (a fullscreen windows) and not the native
fullscreen mode. This commits switches the semantics:

* 1: Native fullscreen, like Vanilla Quake II.
* 2: Desktop fullscreen.

With this alt-tab reverts to native fullscreen. While at it improve the
documentation, suggest setting `r_mode -2` when using `vid_fullscreen
2`. Change the menu strings to make things clearer, set `r_mode -2` when
selecting 'fullscreen window' in the menu.

I pondered several other options:

* Introducing a second cvar for the desktop fullscreen, like we did in
  dhewm3. This has the problem, that in Quake II vi_fullscreen is
  special and used to communicate changed to the renderer configuration
  between the client and renderer. A second fullscreen cvar would
  complicate this already shaky mechanism even more.
* Setting `r_mode -2` when `vid_fullscreen 2`. This might not be what
  the user wants and causes problems when we're unable to get the
  desktop resolution.
2021-03-10 10:30:21 +01:00
Yamagi
51caf5b85e
Merge pull request #676 from rg3/vk_restart_fixes
Avoid restarting the whole video on VK_ERROR_OUT_OF_DATE_KHR
2021-03-10 10:01:47 +01:00
Yamagi
3c4dfcbba8 Switch the r_fixsurfsky default value to 0.
Switching this back to Vanilla Q2 behavior fixes at least one lightning
problem in the space map in baseq2. It'll break the lighting in some
addon maps, but is more correct from a global standpoint. You can't
have everything...

Closes #677.
2021-03-10 09:49:03 +01:00
Yamagi
e8107b4c64 Add else case missed / not committed in 9a17eb9a. 2021-03-08 21:30:34 +01:00
Ricardo Garcia
6989d22a2e Avoid restarting the whole video on VK_ERROR_OUT_OF_DATE_KHR
If an error is detected in vkAcquireNextImageKHR or vkQueuePresentKHR,
avoid restarting the whole video system and the game window. Instead,
shut down the Vulkan subsystem as gracefully as possible and restart it
without touching the window.

This fixes the problem with infinite video restarts under the Gnome
desktop environment.
2021-03-07 23:11:10 +01:00
Yamagi
80c637b5d6 Clamp scr_conspeed to 0.1f and use Cvar_Set().
Pointed out by @maraakate.
2021-03-05 10:29:46 +01:00
Yamagi
bfa25a13d9 Clamp the console speed to 1 or higher.
Lower values mess up the console rendering. Closes #671.
2021-03-04 07:13:42 +01:00
Yamagi
ae9a248e9e Add a cvar g_footsteps to control the generation of footstep sound.
1: The Vanilla Quake II behaviour, footsteps are generated when the
   player is faster than 255.
0: Footstep sounds are never generated.
2: Footstep sounds are always generated.

Defaults to `1`, cheat protected to `1`.

Closes #666.
2021-03-02 15:08:23 +01:00
Yamagi
d713944681
Merge pull request #658 from rg3/more_vulkan_fixes
More Vulkan fixes
2021-02-26 14:48:00 +01:00
Ricardo Garcia
bdd715ee5c Fix validation errors with unnormalized samplers
When using samplers with unnormalized coordinates in Vulkan, the shaders
must specify the LOD explicitly.
2021-02-23 22:07:32 +01:00
Ricardo Garcia
63f6778910 Only center Vulkan viewport in "keep resolution" mode
When windowed or in "switch resolution" mode, the viewport must be kept
in the top-left corner or it will appear cut while in fullscreen.

Also, make offset and width calculations safe from the point of view of
the swapchain extent, in case there's a mismatch.
2021-02-14 23:01:14 +01:00
Ricardo Garcia
b96b3a8d84 Synchronize color attachment layout transitions with loads
Since we are now loading the world color buffer content before drawing
on them again, we need to make sure the attachment layout transition
from shader-read-optimal to color-attachment-optimal happens before
color attachment read operations.
2021-02-14 00:03:40 +01:00
Ricardo Garcia
e0e52de47f Add a convenience Qvk_MemoryBarrier function 2021-02-14 00:02:08 +01:00
Denis Pauk
791b5e1e13 Save buffer size and use as limit for operations 2021-02-06 23:35:02 +02:00
Denis Pauk
ba173e68b5 rearrange init functions 2021-02-06 22:42:15 +02:00
Denis Pauk
0b79fa99ed #660: convert wrong modeltype to warning 2021-02-03 00:08:10 +02:00
Denis Pauk
1882fc2dbc #661: Use corrected resolution in fullscreen=1 2021-02-01 23:02:51 +02:00
Yamagi
06d183b6db
Merge pull request #655 from 0lvin/stereo_sound
Support of wav stereo sound
2021-01-31 12:18:26 +01:00
Ricardo Garcia
8599cab275 Load framebuffer contents correctly for MSAA
The contents of the previous drawn frame, used to mask geometry glitches
due to geometry sometimes not being watertight, was not being correctly
loaded for MSAA cases.

When MSAA is not used, the single-sample attachment needs to be loaded
and stored. With MSAA enabled, it's the multisample attachment the one
needing to be loaded and stored.
2021-01-31 10:54:03 +01:00
Ricardo Garcia
9661ce0ba0 Make scaled down view borders work with MSAA
The pipeline used to draw a texture quad was only created compatible
with the RP_UI render pass, which has a single-sample color attachment.
This made the pipeline work when MSAA was disabled, but it did not work
properly with it enabled.

To fix the issue, create a set of pipelines, instead of a single one,
with compatibility with the different types of render passes, as the
pipeline is used for both the scaled down view borders as well as UI
elements in the third render pass.
2021-01-31 10:38:59 +01:00