also changed that logic a bit so FormatMessage() is only called when
actually used
and while at it, fixed the build with mingw-w64 on my system
(somehow an SDL header used strcmp() and that didn't work with
`#define strcmp idStr::Cmp` from Str.h)
When requesting < 1 MB, _alloca16() is used, otherwise Mem_Alloc16().
Furthermore you must pass a bool that will get true assigned if the
memory has been allocated on the stack, else false.
At the end of the function you must call Mem_FreeA( ptr, onStack )
(where onStack is the aforementioned bool), so Mem_Free16() can be
called if it was allocated on the heap.
idInterpreter::Push() is used only for int and (reinterpreted) float
values, not pointers (as far as I can tell), so 32bit values on all
relevant platforms.
It stored its value as intptr_t at `&localstack[ localstackUsed ]` - on
64bit platforms intptr_t is 64bit.
Unfortunately, all code reading from the stack just get got a pointer
to `&localstack[ localstackUsed ]` in the type they want to read
(like `int*` or `float*`) and read that. On Little Endian that happens
to work, on 64bit Big Endian it reads the wrong 4 bytes of the intptr_t,
so it doesn't work.
fixes#625, #472
All that code is kinda obfuscated, but the integer passing was plain
wrong (if sizeof(int) != sizeof(intptr_t), esp. noticeable on
Big Endian).
data[i] is used by Callbacks.cpp, and for everything but floats it's
passed directly as an argument (interpreted as either an integer or
a pointer to idVec3 or whatever).
So storing an int in there with `( *( int * )&data[ i ] ) = int(...)`
only sets the first 4 bytes of that intptr_t, which is 8 bytes on 64bit
machines. On Little Endian that just happens to work, on Big Endian
it's the wrong 4 bytes.
r_fillWindowAlphaChan is a hack to work around an older issue with
Wayland/Mesa, which has been fixed in Mesa 24.1 (and also seems to work
with current NVIDIA drivers). Additionally, in SDL3 the EGL-specific
(and thus mostly only affecting Wayland)
SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY has been replaced with the generic
SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN (that could also affect
other platforms), so it's harder to enable this only for Wayland.
I think most people using SDL3 will use a recent Mesa/driver versions,
so I don't enable it by default for SDL3 (SDL2 behaves like before).
However, with `r_fillWindowAlphaChan 1` the hack can be enabled anyway
(r_fillWindowAlphaChan defaults to "-1" which means "let dhewm3 decide
whether to enable this")
checking if Z_LARGE64 is defined doesn't make much sense because
that is from from zlib which this helps replace..
so on non-windows we always ran into the #define z_off64_t z_off_t
case which doesn't give us a 64bit offset on 32bit systems..
Should work better now.
fixes#622
.. mostly by not making it use SDL_main.h, because it implements its
own SDL main functionality anyway.
However, I have no way to test this code and as long as SDL3 is not in
homebrew testing it in the CI build isn't easy either.
Refactored the pseudo-custom SDL_main code a bit: SDL_win32_main.c
is now only used for SDL1.2, SDL2 and SDL3 have a WinMain() function
in win_main.cpp that works pretty much like the SDL2 SDL_main or SDL3
SDL_RunApp() code - except that the argv[] strings passed to the Doom3
main() function (now renamed to SDL_main()) are encoded in ANSI instead
of UTF-8, so paths passed as commandline arguments, like
dhewm3 +set fs_basepath C:\SüperGämes\Doom3
work with the Win32 ANSI function used by Doom3 to handle paths and files.
For this I also moved the stdout/stderr redirection code from
SDL_win32_main.c to win_main.cpp and cleaned it up a bit
- use SDL_SetHint() to set the video driver to "dummy" for the
dedicated server
- adjustments for some more functions that now return bool instead
of int. I hope I found all cases of that now, at least in the generic
and Linux code, may have to take a closer look at Windows- and Mac-
specific code
.. except where SDL_Swap* is actually used (idlib/Lib.cpp).
Otherwise #if D3_IS_BIG_ENDIAN suffices, (NOT #ifdef, it's always set,
but to either 0 or 1!)
When applying the currently configured graphics quality preset
(it's set in the `com_machineSpec` CVar and applied with the
`execMachineSpec` command, or by using the menu), now soft particles
are disabled for all quality presets except for ultra, because this
feature has a noticeable impact on performance with some (slower) GPUs.
The previous commit didn't fix the issue for the pistol and only was a
workaround anyway. So I reverted that and fixed the issue properly.
The underlying issue is that the particle's material sets the
texture matrix (with "translate" or "scale" or whatever), and the soft
particle rendering code (and shader) didn't take the texture matrix
into account.
Now it does, in a similar way as the interaction shader code.
Fixes https://github.com/dhewm/dhewm3-sdk/issues/36
the base game entry is now called "Doom 3 (base game)" instead of
"dhewm3", which should be more obvious, and the d3xp entry now reads
"Resurrection Of Evil (d3xp)" instead of just "d3xp", which certainly
is clearer. d3xp now is also always second in the list (if installed)
Added the freshly supported perfected_roe and sikkmodd3xp mods to the
list of mods that need fs_game_base d3xp set, so they can be started
from the menu.
also added an entry for r_gammaInShader to Configuration.md
this avoid breaking the game DLL ABI (framework/DeclParticle.h is part
of the SDK), and for now doesn't make a difference, because that keyword
was introduced by TDM and thus is only used in their particle defs.
When we break the game ABI/API anyway (probably for high FPS support),
this commit can just be reverted