Commit graph

149 commits

Author SHA1 Message Date
Daniel Gibson
9e3acf4b38 Update stb_image and stb_vorbis
from unofficial forks that are quicker to merge security fixes

stb_image.h:
 https://github.com/NBickford-NV/stb/tree/neilbickford/all-fixes
 commit 66e4fb617ad697c62ebe2814804881fe127cb232 from Jan 30, 2024

stb_vorbis.c: https://github.com/sezero/stb/tree/stb_vorbis-sezero
 commit 3ba957b34a949413886c9b8eb1842bdbd3957093 from Dec 12, 2023
2024-02-04 04:41:05 +01:00
Daniel Gibson
e63b63fcff Turn assertion in idRenderWorldLocal::BoundsInAreas() into Warning
apparently this happens sometimes, but not often enough to reproduce
properly?

also some small changes (mostly formatting) to Configuration.md

refs #540
2024-02-03 15:43:59 +01:00
fgsfds
37b0551ba8
Added 21:9 and 32:9 resolutions (#532)
* added 21:9 and 32:9 resolutions
2023-11-18 06:27:44 +01:00
Daniel Gibson
ba986a2dc5 Merge branch 'eezstreet-screenshot-formats'
added some comments, renamed WriteScreenshot()
to WriteScreenshotForSTBIW() and made it static
2023-06-26 02:03:04 +02:00
Nick Whitlock
d468e91d29 Made compress_for_stbiw static 2023-05-24 12:01:11 -04:00
Nick Whitlock
e74e8f5d7c Solution for not breaking SDK ABI 2023-05-24 01:40:18 -04:00
Nick Whitlock
619c5d43f8 Optimization for screenshot flipping 2023-05-24 01:28:46 -04:00
Nick Whitlock
b880e8625b Use zlib for compression of png screenshots 2023-05-23 01:29:17 -04:00
Nick Whitlock
c86cb9a982 Use TGA in specific places 2023-05-22 21:45:34 -04:00
Nick Whitlock
df4e8405b0 Introduced cvar: 'r_screenshotPngCompression' 2023-05-22 21:34:49 -04:00
Nick Whitlock
7ea3e91474 Added new screenshot formats.
Added the ability to change the screenshot format with a new CVar:
r_screenshotFormat. This has four options: 0 (TGA), 1 (BMP), 2 (PNG),
and 3 (JPG). JPG quality can be selected with a new CVar:
r_screenshotJpgQuality. TGA is the default to preserve original behavior
from DOOM 3.

A new dependency on stb_image_write has been added. It has been
included. No additional configuration with CMake is required.
2023-05-22 09:40:11 -04:00
Daniel Gibson
03fccc6220 R_IssueEntityDefCallback() fix bounds check
in the "Work around false positive GCC -W(maybe-)uninitialized warnings"
commit I changed that code.. but my change made it nonsensical,
of course we must get oldBounds before calling the callback which
changes the bounds, otherwise comparing the "oldbounds" with the
current bounds just compares them with themselves..
2023-03-28 19:18:55 +02:00
Daniel Gibson
95d8d75ae0 Update Changelog, another small MD3 fix 2023-01-29 02:46:34 +01:00
Daniel Gibson
604dc7c44d Fix MD3 model support (esp. on 64bit)
.. but even on 32bit it didn't work reliably due to
an uninitialized value
2023-01-29 01:10:41 +01:00
Daniel Gibson
996947eec6 Fix -Wmismatched-new-delete warnings
totally valid, how didn't we find them yet (ok, maybe because those
functions aren't called much)
2023-01-05 07:56:16 +01:00
Daniel Gibson
6730ddcb29 Work around false positive GCC -W(maybe-)uninitialized warnings
shouldn't hurt too much, and the R_IssueEntityDefCallback() code
even is a bit better now
2023-01-05 07:54:41 +01:00
Daniel Gibson
279a40a981 Fix -Wformat-security warnings - thanks James Addison!
This is based on https://github.com/dhewm/dhewm3/pull/500
by https://github.com/jayaddison

See also https://github.com/blendogames/quadrilateralcowboy/pull/4
2023-01-05 04:45:34 +01:00
Daniel Gibson
2a85b73110 Fix some ubsan warnings 2022-11-06 03:09:05 +01:00
Daniel Gibson
b88b99fadb Fix assertion when switching to mod via menu, #458
The assertion that triggered was "assert(iconvDesc == (SDL_iconv_t)-1);"
in Sys_InitInput() - because when loading a mod the window is recreated,
calling Com_ReloadEngine_f() -> idCommonLocal::InitGame()
 -> idCommonLocal::InitRenderSystem() -> idCommonLocal::InitOpenGL()
 -> R_InitOpenGL() -> Sys_InitInput()

Before that Com_ReloadEngine_f() calls commonLocal.ShutdownGame( true );
which calls the equivalent Shutdown() functions - except so far no one
called Sys_ShutdownInput() (which closes iconvDesc and resets it to -1).
Fixed that by making idRenderSystemLocal::ShutdownOpenGL() call it.
2022-05-24 03:33:13 +02:00
Daniel Gibson
699779e9ca Make window alpha chan opaque on Wayland, fix #426
For some reason Wayland thought it would be clever to be the only
windowing system that (non-optionally) uses the alpha chan of the
window's default OpenGL framebuffer for window transparency.
This always caused glitches with dhewm3, as Doom3 uses that alpha-chan
for blending tricks (with GL_DST_ALPHA) - especially visible in the main
menu or when the flashlight is on.
So far the workaround has been r_waylandcompat which requests an OpenGL
context/visual without alpha chan (0 alpha bits), but that also causes
glitches.
There's an EGL extension that's supposed to fix this issue
(EGL_EXT_present_opaque), and newer SDL2 versions use it (when using
the wayland backend) - but unfortunately the Mesa implementation is
broken (seems to provide a visual without alpha channel even if one was
requested), see https://gitlab.freedesktop.org/mesa/mesa/-/issues/5886
and https://github.com/libsdl-org/SDL/pull/4306#issuecomment-1014770600
for the corresponding SDL2 discussion

To work around this issue, dhewm3 now disables the use of that EGL
extension and (optionally) makes sure the alpha channel is opaque at
the end of the frame.
This behavior is controlled with the r_fillWindowAlphaChan CVar:
If it's 1, this always is done (regardless if wayland is used or not),
if it's 0 it's not done (even on wayland),
if it's -1 (the default) it's only done if the SDL "video driver" is
  wayland (this could be easily enhanced later in case other windowing
  systems have the same issue)

r_waylandcompat has been removed (it never worked properly anyway),
so now the window always has an alpha chan
2022-02-05 16:34:34 +01:00
Daniel Gibson
ae63021d00 Add absolute mouse mode and refactor mouse grabbing code
There were lots of places in the code that called Sys_GrabInput(),
some of them each frame.
Most of this is unified in events.cpp now, in handleMouseGrab() which
is called once per frame by Sys_GenerateEvents() - this makes reasoning
about when the mouse is grabbed and when not a lot easier.
Sys_GrabInput(false) still is called in a few places, before operations
that tend to take long (like loading a map or vid_restart), but
(hopefully) not regularly anymore.

The other big change is that the game now uses SDLs absolute mouse mode
for fullscreen menus (except the PDA which is an ugly hack), so the
ingame cursor is at the same position as the system cursor, which
especially helps when debugging with `in_nograb 1` and should also help
if someone wants to integrate an additional GUI toolkit like Dear ImGui.
2022-01-10 00:46:32 +01:00
Daniel Gibson
ea781c577e Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination
2022-01-08 16:58:48 +01:00
Daniel Gibson
4b97bbca00 Update stb_vorbis to v1.22 and stb_image to v2.27
.. the latest releases.
Fixes sound issues on macOS/intel

While I was at it, updated stb_image as well
2021-10-31 06:14:59 +01:00
Daniel Gibson
ad327d34d1 Add support for GL_ATI_separate_stencil
glStencilOpSeparateATI() should behave exactly the same as
glStencilOpSeparate() so supporting it is easy enough and might help
some people with hardware or drivers that don't support OpenGL 2.0,
like the Mac OSX versions for PPC.
2021-10-12 19:32:32 +02:00
SiliconExarch
4f0c54f63f Fix compatibility with Mac OSX 10.4 and 10.5
- Fix build with SDL <=2.0.3
  SDL_GetGlobalMouseState was introduced in 2.0.4
  (which doesn't support OSX 10.5 or older)
- Don't include execinfo.h on Mac OS X 10.4
  This file isn't included in the 10.4 SDK
- Use custom typedef for PFNGLSTENCILOPSEPARATEPROC on OSX 10.4/10.5
  because the system OpenGL headers for those versions don't have it
2021-10-12 19:07:41 +02:00
Daniel Gibson
78eef43d50 Fix rendering of mars globe in main menu with some drivers
The problem was that negative values (from dhewm3tmpres.xyz) were passed
to POW, and POW doesn't have to support negative bases, according to
ARB_fragment_program.txt, and Intels Linux drive apparently doesn't,
see also https://gitlab.freedesktop.org/mesa/mesa/-/issues/5131

Using MUL_SAT instead of MUL to clamp the value that gets passed to POW
afterwards to [0, 1] fixes the problem without any disadvantages.
2021-08-17 19:43:01 +02:00
Daniel Gibson
981863788f Update Changelog
and fix a typo in a comment in the shader gamma injection code
2021-07-19 17:09:36 +02:00
Daniel Gibson
6dbcf6523e Shader Gamma: support "OUTPUT bla = result.color;" in frag. shaders
so far the code assumed that "result.color" is always used directly,
but the ARB shaders allow creating an alias with the aforementioned
syntax. So turn that into an variable-alias for dhewm3tmpres.
2021-07-19 05:26:22 +02:00
Daniel Gibson
5e4e1d61be Merge branch 'debugger' 2021-07-16 02:21:16 +02:00
Daniel Gibson
277dbf89f1 Make sure shaders are only loaded once at startup, fix #386
this *shouldn't* matter, but due to some Mesa bug is does:
If the shaders have been loaded already (with R_LoadARBProgram()),
then loading them again (like from the `reloadARBprograms` console cmd
or as it happens if the `r_gammaInShader` has been modified) will
cause glitches with the open source radeonsi driver (maybe also with
others? at least the open source intel driver seems unaffected).
As r_gammaInShader was marked as modified at startup (before the shaders
were even loaded) they were loaded twice: First as expected when OpenGL
is initialized, then again in R_CheckCvars() which is executed each
frame. Marking as at not modified in R_InitOpenGL() prevents this and
thus works around the bug.
However this means that changing r_gammaInShader at runtime will still
trigger this bug (while with non-broken drivers it switches seamlessly
between gamma in shader and gamma in hardware without a vid_restart).
2021-06-24 18:37:14 +02:00
Daniel Gibson
dc42bdc873 Do gamma correction (r_gamma, r_brightness) in shaders
by injecting code to do it into fragment shaders.

Can be disabled with r_gammaInShaders 0

refs #385
2021-06-20 03:36:39 +02:00
Daniel Gibson
0b644a1648 Fix crashes on shutdown
idCommonLocal::VPrintf() wanted to call session->UpdateScreen() even though
the renderer was in the process of being shut down and that caused crashes
2021-06-19 21:30:26 +02:00
Daniel Gibson
c212148d41 Remove R_LockSurfaceScene(), clean up temporary changes
R_LockSurfaceScene() isn't used anymore, surface locking is implemented
differently (so it actually works now :-p)
2021-06-15 03:27:52 +02:00
Daniel Gibson
a11b2d352c r_lockSurfaces: Make mirrors look only a bit broken
it's still not great, but at least they don't float around anymore
2021-06-15 03:27:52 +02:00
Daniel Gibson
633ce814ca r_lockSurfaces: Cleaner handling of view matrix creation etc 2021-06-15 03:27:52 +02:00
Daniel Gibson
907fc5771b Disable r_useScissor when r_lockSurfaces is active 2021-06-15 03:27:52 +02:00
Daniel Gibson
d17fa6b2b6 Fix rendering of ingame GUIs with r_lockSurfaces 1 2021-06-15 03:27:52 +02:00
Daniel Gibson
dcb933efb5 Fix rendering HUD with r_lockSurfaces 1
only override cmd->viewDef in RB_DrawView() if we're drawing the
primary view (which for several calculations before actual drawing
was set to the saved/locked render view)

Note that r_lockSurfaces is more useful with r_useScissor 0 (otherwise
there's black bars over the screen when moving) and r_shadows 0 (otherwise
areas that weren't visible when locking are black because the lights
there are skipped)

remaining bug: gui surfaces move around the screen when looking around
2021-06-15 03:27:52 +02:00
Daniel Gibson
1a6998781b Make r_locksurfaces kinda work
refs #357
2021-06-15 03:26:44 +02:00
Daniel Gibson
0b28322500 Fix loading .ASE models with no materials
The "A Place of Malice" custom map has such a model which caused a crash
(models/z13sp2/temple/pushable_collision_box.ASE), see #382
2021-05-19 02:48:31 +02:00
Daniel Gibson
b054261a0e Make MFC Tools work with MSAA enabled
The problem was that the editors called ChoosePixelFormat() instead of
wglChoosePixelFormatARB() - and the normal ChoosePixelFormat() has no
attribute for MSAA, so if MSAA is enabled (by SDL2 which calls the wgl
variant), ChoosePixelFormat() will return an incomaptible format and
the editors don't get a working OpenGL context.
So I wrote a wrapper around ChoosePixelFormat() that calls the wgl variant
if available, and all the necessary plumbing around that.

While at it, removed the unused qwgl*PixelFormat function pointers and
supressed the "inconsistent dll linkage" warnings for the gl stubs
2021-05-11 00:39:00 +02:00
Daniel Gibson
409dd8e3d9 Fix crash if both image_useCache and image_downSize are 1
the commented out code clamped the loaded filesize of affected .dds
images (crash observed with dds/guis/assets/splash/pdtempa.dds) to
200KB - but then later tries to load it and skip the first mipmap,
resuling in reading invalid memory (> 200KB into the file).
No idea what this was supposed to achieve, but it's disabled now
and the crash (at startup) is gone.

fixes #374
2021-04-28 00:04:24 +02:00
Daniel Gibson
b0e0883f6e Replace libjpeg with stb_image.h
libjpeg is a pain in the ass, especially due to Ubuntu shipping
libjpeg-turbo in jpeg8 mode as their default libjpeg, while every other
distro I checked (including debian!) ships libjpeg-turbo in jpeg6.2 mode

Thankfully stb_image.h exists - just a single header and it even
has a (much!) friendlier API.

It's not like Doom3 (or any of the mods I checked) actually use JPEGs,
but I'm sure if I'd drop support completely, someone would complain
(perhaps rightfully so).
2021-04-27 20:08:59 +02:00
Daniel Gibson
bb7346579e GLimp_Init() Print actually received color/alpha/stencil/depth bits
to help debugging #368 and #348
2021-04-24 20:27:16 +02:00
Turo Lamminen
9c6b835f16 Fix uninitialized members of drawInteraction_t in RB_CreateSingleDrawInteractions 2021-04-12 19:13:39 +02:00
Turo Lamminen
7aee2af217 Silence misleading indentation warnings 2021-03-15 13:02:45 +02:00
Daniel Gibson
9a83b3def4 Add r_fullscreenDesktop CVar for "desktop"/windowed fullscreen mode
.. that doesn't switch the display resolution, but creates a borderless
fullscreen window at current desktop resolution.
SDL2-only (SDL_WINDOW_FULLSCREEN_DESKTOP).

Doing this with an additional CVar instead of r_fullscreen 2 or similar
has the advantage that it works properly with Alt-Enter
2021-01-15 18:24:48 +01:00
Daniel Gibson
d1b0073582 Try to enforce selected fullscreen resolution
SDL has a bug (at least on Windows) where SDL_CreateWindow() with
SDL_WINDOW_FULLSCREEN doesn't use the configured resolution (if it's
higher than the current desktop resolution).
Try to work around that - based on Yamagi Quake II code.

Also, if GLimp_Init() fails, the "safe mode" fallback is now in
windowed mode instead of fullscreen mode.
2021-01-15 18:24:48 +01:00
Tobias Frost
8c699cd030 s/referneces/references 2021-01-15 18:00:25 +01:00
Daniel Gibson
7297ebcaf6 Fix fonts on Big Endian systems, fixes #148
The code used #ifdef __ppc__, probably a leftover from old Mac support,
which apparently doesn't work on all PPC systems (maybe not 64bit PPC).

Now using the LittleFloat() function instead which exists for
exactly this purpose and already handles endianess properly.
2021-01-14 12:25:22 +01:00