Commit graph

3769 commits

Author SHA1 Message Date
Yamagi
2d2c6787bb
Merge pull request #1109 from starfrost013/master
Fix potential memory corruption issue where cl_numparticles is 0 and CL_ClearParticles is called
2024-06-08 18:32:43 +02:00
Jaime Moreira
c842ab806f Remove fruitless glBindTexture() calls
...when there are no SURF_DRAWTURB surfaces to draw.
2024-06-06 18:23:26 -04:00
Jaime Moreira
c4271848df gl1_multitexture doc update 2024-06-04 16:21:10 -04:00
Jaime Moreira
24b03b61f8 Gyro tightening
A practical way to avoid a noisy gyro signal, or shaky hands.
Unlike a deadzone, inputs below the threshold are "squeezed towards
zero", so they are not completely ignored. Source:
http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-1:the-gyro-is-a-mouse#toc9
2024-06-04 15:48:42 -04:00
Jaime Moreira
0e63bad7d9 Sliders and gamepad buttons refactor
Same logic with less code.
2024-06-04 15:18:37 -04:00
Jaime Moreira
d2b0ebd522 Correct OpenGL boolean flags. 2024-06-04 15:10:41 -04:00
Jaime Moreira
6869d7dddd GL1 multitexture combine removed
Applied too many OpenGL calls for an effect that could not be told
apart from normal GL_MODULATE; explains its absence from Q3A code.
Also, removed calls to glPixelStorei when no dynamic lights present.
2024-06-04 14:59:05 -04:00
Jaime Moreira
c68ffec274 GL1 multitexture bugfix
With "hand 2" and no "alias" models in player sight, sometimes only
lightmap was visible. Now forcing disabled multitexture when needed.
Another bugfix: "gl_showbbox 1" no longer produces OpenGL errors.
2024-06-04 14:53:25 -04:00
starfrost013
e160691fec Fix potential memory corruption issue where cl_numparticles is 0 and CL_ClearParticles is called. 2024-05-29 15:41:12 +01:00
Yamagi
7ffcd990c4
Merge pull request #1108 from protocultor/gl1_biglightmaps
GL1 big lightmaps and scrap
2024-05-25 16:03:38 +02:00
Jaime Moreira
0f307cc9c1 GL1 scrap/atlas configurable size
Controlled by gl1_biglightmaps cvar, works like new lightmaps.
Max size is 384x384; a bigger size is not justified.
Added a transparent border so colors from one picture don't bleed
into the next.
2024-05-11 18:20:13 -04:00
Jaime Moreira
81fd2c1027 Increased lightmap size in GL1
Controlled by new cvar, gl1_biglightmaps.
Size is now up to 512x512, for a max quantity of 8 lightmaps.
Should reduce rebinding of them, and reduce the number of calls
to glTexSubImage2D(), although it may increase data transfer on
each call.
2024-05-11 18:18:28 -04:00
Jaime Moreira
a8824972db Fixed potential game crash at shutdown
Only happens in Windows. A cvar was being queried just after
all cvars were freed, in Qcommon_Shutdown().
GL_GENERATE_MIPMAP definition relocated.
scrap_uploads counter deleted, it wasn't being read anywhere.
2024-05-11 18:16:38 -04:00
Yamagi
b401846ce6
Merge pull request #1103 from protocultor/gl1_multitexture
GL1 multitexture
2024-05-11 16:28:39 +02:00
Yamagi
d50408ff0b Bump SDL 3 support to the latest preview, SDL 3.1.2.
SDL 3.1.1 -> 3.1.2 brings another round of API changes. Only one of them
is relevant for us: the SDL_RENDERER_ACCELERATED flag was removed.
2024-05-05 09:37:36 +02:00
Jaime Moreira
b81e910929 GL1 multitexture, refactored memory allocation
It was missing error checking and cleanup at shutdown.
Also, reset state when needed. Fixes "death by laser" in boss1 map.
2024-04-29 14:39:48 -04:00
Jaime Moreira
ba71af2af8 GL1 multitexture: fast dynamic lighting
Using MH's solution, which is keeping all lightmaps in memory
to modify and upload them as a batch when possible.
lightmap_buffer is now an array; index 0 is used as the legacy
lightmap buffer (when no mtex), and the rest of the indexes are
to store the different lightmaps (only when using mtex).
2024-04-23 12:26:44 -04:00
Jaime Moreira
86528d7812 GL1 multitexture, first version
Unlike the old, buggy one, this implementation follows the
texture chain, just like the standard execution path. It also
avoids doing the lightmap chains, since it has already done it
in the second TMU; there's no duplicated work for lightmaps.
No errors appear in the lava on the "boss1" map either.
It's still slow when having an overdraw of dynamic lights.
Further work is needed.
2024-04-23 12:25:38 -04:00
Jaime Moreira
3faa3db167 GL1 multitexture, initialization
While it is based on the old, buggy multitexture implementation
(removed in 68a12d4e & 8fe8f832), rework will be done to make it
function as intended this time.
For this commit, just init and function declarations.
2024-04-23 12:24:20 -04:00
Jaime Moreira
79bb13d3a7 Updated OpenGL definitions in qgl.h
Using GL 1.4 declarations in code, although 'point parameters' will
use legacy extensions if they're the only ones found.
Moved stuff out of local.h; better to have definitions in one place.
Extracted from <glext.h>.
2024-04-23 12:23:00 -04:00
Jaime Moreira
3dde0d5859 Texture chains working properly
Somehow, R_TextureAnimation() returns different results for the same
surface when called consecutively. We force it to be called once, so
the chains in R_DrawTextureChains() are getting respected now.
2024-04-23 12:21:40 -04:00
Yamagi
e5ee2a74a5
Merge pull request #1102 from 0lvin/gles
client: fix gles3 name
2024-04-07 18:06:39 +02:00
Denis Pauk
c1920e3ec4 client: fix gles3 name
Fix regression introduced in e61d9444c

https://github.com/yquake2/yquake2/issues/1097
2024-04-07 18:50:01 +03:00
Yamagi
8d04ed0bbf Mention SDL 3 as alternative to SDL 2. 2024-04-07 11:01:45 +02:00
Yamagi
8a9e31ab86 Clearify vid_gamma in the GL1 renderer. 2024-04-07 11:01:45 +02:00
Yamagi
e61d9444c9 Bump default renderer to GL3...
...and alter the render finding and fallback sequences to include GLES3
as the first fallback. This should have been done years ago, when GL3
became the clear better option above GL1.
2024-04-07 11:01:45 +02:00
Yamagi
23f60d25b1 Pass SDL major version between ref and client, bump ref API version.
SDL major versions must not be combined in one process, otherwise bad
things will happen. In the best case the game crashes, in the worst case
strange bugs will occure. To prevent that:

* Add a new field `framework_version` to the renderer API and use it to
  pass the SDL major version from the renderer to client. Don't load the
  renderer if it and the client were build with different SDL major
  versions.
* Bump the renderer API version to 7. This could have been implemented
  by assuming `framework_version == 0` (not filled by renderer) as SDL
  2, but let's keep things clean and bump the version.

While here fix a long standing bug with printing the error when not
loading a renderer lib. The message must be generated before shutting
down the renderer, otherwise the API version will alsways be 0. The
struct is zeroed at renderer shutdown.
2024-04-07 11:01:45 +02:00
Yamagi
78c951d620 Implement SDL3 into the CMakeLists.txt. 2024-04-07 11:01:45 +02:00
Yamagi
8cedbb0694 Port the Windows platform backend including Makefile support to SDL3.
This also fixes a long standing bug with the Windows part of the
Makefile linking -lSDL2 into q2ded.exe.
2024-04-07 11:01:45 +02:00
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