0
0
Fork 0
mirror of https://github.com/dhewm/dhewm3.git synced 2025-04-10 20:11:36 +00:00
Commit graph

1085 commits

Author SHA1 Message Date
Daniel Gibson
f3cd3f31d0 Fix weird printing to console that sometimes happened with listImages
It sometimes happened when changing image_* cvars for compression and
then vid_restarting and then running listImages.
In one case the whole process hung and len was a ridiculously big number
=> most probably the (unsigned!) size_t overflowed by subtracting a
number > len (most likely from input_field.GetCursor()).

So I just made it a plain signed int.
I couldn't reproduce the issue anymore after doing this change.
2025-04-08 05:49:35 +02:00
Daniel Gibson
b050991ed2
Merge pull request from DanielGibson/cst-ui-improvements
Improvements in support for cst anchors in GUIs
2025-03-28 05:05:14 +01:00
Link4Electronics
f82569568b Update imconfig.h for big endian 2025-03-23 05:36:19 +01:00
Klaus Silveira
0691c5010f Fix buffer overflow warnings in dmap.cpp 2025-03-23 05:35:43 +01:00
Klaus Silveira
e63fbe66b8 Removed duplicate cullType check. 2025-03-23 05:34:52 +01:00
Klaus Silveira
a8fc1cee8f Removed duplicate check for muzzle_flash. 2025-03-23 05:34:52 +01:00
Daniel Gibson
b0e3f59c07
Merge pull request from DanielGibson/bc7
Support BPTC (BC7) -compressed .dds textures.
2025-03-23 05:33:54 +01:00
Daniel Gibson
19b2070c19 Mention BC7 support in changelog 2025-03-23 05:31:21 +01:00
Daniel Gibson
49fc3d70c2 Add options for precompressed textures to Dhewm3SettingsMenu 2025-03-23 04:24:25 +01:00
Daniel Gibson
42cfb157a2 Make sure it still builds when removing neo/libs/imgui/
.. when setting IMGUI=OFF in CMake, of course.

I don't think it's a very good idea to remove that directory, or to
disable ImGui support for any reason besides "I'm on an ancient
platform that doesn't support C++11", but this is an simple enough
change so whatever.
2025-03-22 17:21:19 +01:00
Daniel Gibson
06d919b410 Fix FormatIsDXT() check
there are lots of values between
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F3) and
GL_COMPRESSED_RGBA_BPTC_UNORM (0x8E8C). We don't support them as valid
compressed formats.

(strictly speaking BPTC is not DXT so the function name doesn't fit 100%
 anymore, but DXT1-5 is now BC1-3 and BPTC is BC7 so.. close enough.)
2025-03-06 06:37:09 +01:00
Daniel Gibson
8fd317ab4c Fix loading of DDS textures with incomplete mipmaps
Apparently OpenGL (or at least nvidias driver?) is unhappy if the
smallest mipmaplevel isn't 1x1 pixels. It doesn't show any error in
debug messages, but it's just set to black.
This can be worked around by setting GL_TEXTURE_MAX_LEVEL
2025-03-05 18:22:10 +01:00
Daniel Gibson
08c81e5693 Fix typo in Com_ExecMachineSpec_f() 2025-03-05 05:57:01 +01:00
Daniel Gibson
0f4b6e7245 Support BPTC (BC7) textures in .DDS
Can have better image quality than S3TC (DXT1-5).

based on a patch by Github user "Manoa1911":
https://github.com/dhewm/dhewm3/issues/447#issuecomment-2254369525

Only supports DXGI_FORMAT_BC7_UNORM - I hope that's enough?
BC7/BPTC is supported by all GPUs that support DX11 (or newer)
or OpenGL 4.2 (or newer). That should be the case for Radeon HD 5000
and newer, Geforce 400 and newer and Intel iGPUs from Ivy Bridge on.
Those GPUs are from 2009/2010, 2012 for Intel.

fix 
2025-03-05 05:56:46 +01:00
Daniel Gibson
2b20aadda5 idSlowChannel::Reset(): Don't memset() the class
it has a member with a vtable that gets overwritten then, that's bad
(even though I've never seen a crash caused by this?!)

Instead set the members to NULL/zero manually
2025-03-04 05:27:52 +01:00
Daniel Gibson
b78becde4c Fix loading ridiculously large non-POT-textures
After loading a texture, Doom3 calculates an MD4-sum of it.. this is
mostly pointless and only used for the "reportImageDuplication" console
command, but whatever.
The problem here was that the image was 32000x2000 pixels (due to some
error when creating it) which dhewm3 wanted to convert to the next
bigger power-of-two values with R_ResampleTexture(), but that function
clamps to 4096x4096, so the actually used pixeldata was for 2048x4096.
However, R_ResampleTexture() didn't communicate this to its caller,
and thus a too big size was used for calculating the MD4-sum and it
crashed.

That's fixed now and also a warning is printed about this.
2025-03-03 05:49:16 +01:00
Daniel Gibson
dda5e3f499 Silence compiler warning in idMaterial::IsDiscrete
for some reason `sort` is a float, and newer GCC doesn't like comparing
float with enums, so just cast it to int
2025-03-03 05:29:10 +01:00
Daniel Gibson
e1e443dbe1 Fix CPU architectore in version strings on Windows
BUILD_CPU has been replaced by D3_ARCH, which is also set by CMake on
most platforms, except for Windows, there it's set in neo/sys/platform.h
because CMake is not able to tell us what CPU platforms it's targeting
(for other platforms we parse the output of gcc/clang's -dumpmachine
 option, but for MSVC that's not an option, of course)
2025-03-03 05:27:37 +01:00
Daniel Gibson
c8f09d4ac7 Initialize all idRegister class members in constructors
in SkinDeep regs not being initialized caused random crashes
(in dhewm3 I haven't seen that so far, but fixing this won't hurt).

From SkinDeep commit message:

In idRegister::SetToRegs() at `registers[ regs[ i ] ] = v[i];`
regs[i] contained values like 21845 or 22010 or 32272, even though
the static registers array that's written to there only holds 4096
elements (it's `static float regs[MAX_EXPRESSION_REGISTERS];`
 from `idWindow::EvalRegs()`).
So it overwrites other data, likely other global variables, like
`gameLocal.entities[4967]`, that now contain garbage and next time
someone tries to use them, bad things happen.
In this case, if someone tries to dereference gameLocal.entities[i]
and the pointer at i contains garbage, there's a segfault (crash).

462404af67
2025-03-03 05:22:40 +01:00
Klaus Silveira
da119a30c6 Fix memory deallocation issue by using delete[] for arrays 2025-02-25 23:42:49 +01:00
Daniel Gibson
8a6cef6c71 Add documentation about dhewm3's enhancements of the Doom3 GUI system 2025-02-23 22:46:26 +01:00
Daniel Gibson
c41ac185cc Rename variables and Named Event for GUI scripts, add more such vars
"gui::horPad" is now called "gui::cstHorPad", "gui::vertPad" is now
called "gui::cstVertPad", so it's clearer that they belong to the
CST anchor system.

I also added "gui::cstAspectRatio", the aspect ratio of screen or Doom3's
window resolution (when using windowed mode).
Furthermore "gui::cstWidth" and "gui::cstHeigh" with the screen
(or Doom3 window) resolution in *virtual* pixels, based on that GUI
640x480 coordinate system.
For widescreen resolutions, "gui::cstHeight" is always 480 and
"gui::cstWidth" is scaled according to the aspect ratio (>640).
For tall resolutions, "gui::cstWidth" is always 640 and "gui::cstHeight"
is scaled according to the aspect ratio (> 480).
2025-02-23 06:33:27 +01:00
Daniel Gibson
15285e268a Allow using both naturalmatscale and matscalex/y in GUIs
So far one could only use either naturalmatscale or matscalex/matscaley.
Just "naturalmatscale 1" lets a texture repeat in its native size, i.e.
if you have a 64x32 texture and a 320x160 (in the 640x480 GUI coordinate
system) windowDef, it will be repeated 5 times in each direction.
If you resize the windowDef to 384x160, it will repeat the texture
6 times horizontally (and still 5 times vertically).

matscalex/y allow scaling that texture. If both values are set to 2,
(and naturalmatscale to 1) the 64x32 texture in a 384x160 windowDef
will be repeated 12 times horizontally and 10 times vertically, at half
the size per direction.
Without naturalmatscale it would be repeated 2 times in each direction,
no matter how big the windowDef is.
2025-02-21 00:44:17 +01:00
Daniel Gibson
60e670f12a Provide variables "gui::horPad" and "gui::vertPad" to GUI scripts
they are set before onActivate and also whenever the (Doom3 SDL) window
size changes, in that case additionally the "UpdateWindowSize" Named
Event is called in the script, in case you wanna do anything special
in that case:

  onNamedEvent UpdateWindowSize {
    set "print" "UpdateWindowSize - horPad:" "gui::horPad"
          "vertPad:" "gui::vertPad";
  }

horPad is the width of the padding border (empty space) between the
  left/right border of Doom3's SDL window and a centered
  (cstAnchor CST_ANCHOR_CENTER_CENTER) full-sized windowDef in virtual
  pixels (in the Doom3 GUI coordinate system, which usually is 640x480).
vertPad is the same for the padding border between the top/bottom border
  and a centered full-sized windowDef

One of those values will always be 0.

So for example if you play Doom3 at 1600x1200 (a 4:3 resolution like
640x480) both horPad and vertPad are 0.
If you play at 1680x1050 (16:10 resolution) and your windowDef Desktop
is 640x480 (the default), horPad is 64 (and vertPad is  0), because
there are 64 virtual pixels between the left window border and a
centered 640x480 windowDef (and also between the centered windowDef
and the right window border.

gui::horPad and gui::vertPad are useful for filling those otherwise
empty padding areas with windowDefs that you anchor to the corresponding
points of the window (like CST_ANCHOR_LEFT and CST_ANCHOR_RIGHT when
there's horizontal padding) that have just the right size.

Example of a green rectangle filling parts of the left padding area,
but not touching the center area (10 virtual pixels distance):

  windowDef leftPadFiller {
    cstAnchor  CST_ANCHOR_LEFT
    rect   0, 200, "gui::horPad" - 10, 40
    backColor 0, 1, 0, 1
  }
2025-02-20 03:44:18 +01:00
Daniel Gibson
384fd0cca1 Allow GUI scripts to do debug printing to the console
Example:
  onActivate {
    set "print" "this windowDefs rect:" "$rect";
  }
(added to the Desktop of a GUI) prints
"GUI debug: this windowDefs rect: 0 0 640 480"
to the ingame console
2025-02-20 02:05:31 +01:00
Daniel Gibson
4aef5c1dd4 Fix mousecursor handling for menus using "scaleto43 0"
especially useful when using cstAnchor

also providing an easy generic way to figure out if the window of an
idUserInterface is scaled to 4:3 aspect ratio or not, depending on
r_scaleMenusTo43 and the WIN_SCALETO43/WIN_NO_SCALETO43 window flags,
that come from "scaleto43 1" (or 0) set in the GUIs Desktop windowDef
2025-02-19 22:38:29 +01:00
Daniel Gibson
57a75f8b08 Fix clicking in (CST) anchored windowDefs and stretched mouse cursor 2025-02-18 05:40:40 +01:00
Daniel Gibson
3ee8ef55ef Fix scaling of renderDefs when anchored with cstAnchor
for my scale to 4:3 hack idRenderWindow::Draw() already calls
  if(dc->IsMenuScaleFixActive()) {
      dc->AdjustCoords(&x, &y, &w, &h);
  }
and AdjustCoords() already takes the cst offsets into account, so all
that was left to do was making idDeviceContext::IsMenuScaleFixActive()
aware of the cst stuff
2025-02-17 03:59:20 +01:00
Daniel Gibson
c30bff8c67 Support "scaleto43 0" in Desktop windowDefs to explicitly stretch them
even if r_scaleMenusTo43 1 and they'd usually be scaled to 4:3.
Useful when using anchors in fullscreen menus (like the PDA)

This is analogous to "scaleto43 1" in windowDefs which allows scaling
to 4:3 (with black/empty bars) even if by default it would *not* be
scaled.
2025-02-17 03:42:50 +01:00
r-a-sattarov
a18b9e6bad Added use of O3 instead of O2 for e2k arch
O3 on E2K mcst-lcc approximately equal to O2 at X86/ARM gcc
2025-02-07 14:50:18 +01:00
Daniel Gibson
cc5f1d9fd2 Fix issues in first map of the "UAC Franchise 666" user campaign,
somehow the collision code managed to spread NaNs on Win32, which caused
a horrible framerate, "GetPointOutsideObstacles: no valid point found"
warnings in the console and assertions in debug builds.
Didn't happen in Vanilla Doom3 though.

At the location I changed the code in, I saw the following values in the
debugger:
normal: {x=0.00610326231 y=5.58793545e-09 z=1.19209290e-07 }
trmEdge->start: {x=-1358.00000 y=913.948975 z=25.2637405 }
start: {x=-1358.00000 y=916.000000 z=34.0000000 }
end:   {x=-1358.00000 y=810.000000 z=34.0000000 }
dist (normal*trmEdge->start): -8.28822231
d1: 9.53674316e-07
d2: 9.53674316e-07
f1 (d1/(d1-d2)): inf

"normal" isn't normalized and also very small (in all directions),
"start" and "end" have quite different y values, but still doing scalar
multiplications of each with "normal" gave the same result..
No idea what this all means exactly, but checking if d1 - d2 is (almost)
0 to prevent INF solved the problems. In the end it will be some tiny
differences in floating point calculations between different platforms
and compilers..
In my test d1-d2 was exactly 0, but I compare with FLT_EPSILON to be
on the safer side.
2025-02-04 18:50:42 +01:00
Daniel Gibson
63963058df Update Dear ImGui to 1.91.7 2025-01-29 18:16:28 +01:00
Daniel Gibson
63b84a8b8e
Merge pull request from DanielGibson/cst-ui
Support CstDoom3 GUIs for aspect-ratio-independent HUD
2025-01-22 01:55:58 +01:00
Daniel Gibson
a97caf0836 Make cst_hudAdjustAspect default to 1
If GUIs with CST anchors are there, they should be displayed correctly.
With standard GUIs this doesn't make a difference, so it doesn't hurt.
2025-01-21 03:06:41 +01:00
Daniel Gibson
f3192be0f8 Bump SAVEGAME_VERSION to 18 for the CstDoom3 GUI changes
incl. backwards compat for older savegames.
only partly useful: old savegames only work if you didn't change the
gamedata, with the CstDoom3 .gui files, loading them crashes. I don't
think that can be avoided, apparently Doom3 has no way to detect that
the GUIs have changed?
2025-01-21 03:04:18 +01:00
Daniel Gibson
565d3e3fc1 Make CstDoom3 anchored GUIs work with dhewm3's menu scale fix
In idWindow::Redraw(), I had to make sure the menu scale fix (which,
if enabled for a window, renders that in 4:3 with empty or black bars
on the side if needed for widescreen etc, instead of stretching it)
is disabled if a window uses CST anchors, because the CST anchor code
also adjusts for the display aspect ratio and if we do both, things get
distorted in the other way.

The biggest change is that idDeviceContext::DrawStretchPic(Rotated) now
has code to adjust the coordinates for both CST and the menu scale fix,
so idDeviceContext::AdjustCoords() is mostly obsolete - it's only still
used by idRenderWindow.
Unlike DstDoom3 now that extra adjustCoords argument to those Draw
functions indicates that any coordinate adjustment should be done, so
if it's set by a caller, it's set to true.

I removed idDeviceContext::AdjustCursorCoords() because it was only used
in one place anyway
2025-01-21 03:04:18 +01:00
Daniel Gibson
46cb46630d Changes from CstDoom3 for anchored GUIs,
those GUIs are aspectratio-independent

doesn't properly work yet, esp. together with my hack that makes sure
menus are rendered in 4:3
2025-01-21 03:04:18 +01:00
Daniel Gibson
0110a624a3 Show some OpenGL information in Dhewm3SettingsMenu's Video tab
hopefully helps detecting when you're using the wrong GPU in a system
with iGPU and dGPU, like in 
2025-01-21 01:17:40 +01:00
Daniel Gibson
79f046abf7 Support nospecular and allow_nospecular in demos
By writing that info into the demo when recording it (when demos are
played back, mylevel.map isn't read, only mylevel.proc, so the
worldspawn can't be accessed to get allow_nospecular from there)
2025-01-21 00:51:38 +01:00
Daniel Gibson
a0d7198dd0 Set tr.allowNoSpecular in DOOMEdit
depending on worldspawn's allow_nospecular
2025-01-21 00:51:38 +01:00
Daniel Gibson
46052a9526 Fix ImGui assertion when starting into DOOMEdit (+editor)
D3::ImGuiHooks::NewFrame() was still called every frame, but EndFrame()
wasn't because idSessionLocal::UpdateScreen() exited early.
This caused an assertion in Dear ImGui, because it doesn't like calling
NewFrame() if it has been called before without EndFrame() afterwards
2025-01-21 00:51:38 +01:00
Daniel Gibson
2d068377ae Support lights "nospecular" parm (if explicitly enabled)
based on https://github.com/dhewm/dhewm3/pull/254

The "nospecular" parm will only be used if either
r_supportNoSpecular is set to 1
or r_supportNoSpecular is set to -1 (the default) and the maps spawnargs
contain "allow_nospecular" "1"

This probably doesn't work with (time)demos yet, because I think when
they're being played I can't access the worldspawn entity
2025-01-21 00:51:38 +01:00
Daniel Gibson
ab333c68c3 Fix typo in "Make sure dhewm3log.txt can be created" commit
thanks @turol for pointing this out!

also updated the changelog
2025-01-19 06:52:59 +01:00
Daniel Gibson
92310f66f0 Fix running timedemo if sound is disabled (s_noSound 1), fix
By adding some nullpointer checks
2025-01-19 02:05:50 +01:00
Daniel Gibson
eefdd8343e Win32: Make sure dhewm3log.txt can be created
If it (or Documents/My Games/dhewm3/) can't be created, show a windows
MessageBox with an error message and exit.

Would've made  easier to figure out
2025-01-18 23:51:24 +01:00
Daniel Gibson
09b1ede069 Make our ImGui code build with older Visual C++ versions again
At least VS2017 doesn't like the big string literal of
proggyvector_font_base85.h (its limit is 64KB, Error C1091), so go back to
using proggyvector_font.h (which contains an int32 array) for MSVC..

Keep the base85 version around for proper compilers, because (unlike
the non-base85 version of the font) it works on Big Endian machines.

It seems like VS2022, maybe even some point release of VS2019 removed this
limitation (our CI build succeeds), but I couldn't find any details about
that change.
2025-01-18 23:51:24 +01:00
Daniel Gibson
e3795a36e0 Use SDL_Start/StopTextInput() also with SDL2
Based on whether handleMouseGrab() in events.cpp sets
GRAB_ENABLETEXTINPUT or not.

Should prevent the issue that on macOS pressing a button for longer
while playing (as one does, e.g. to run forward) opens a popup menu
with alternative characters (like "è", "é", "ê", etc for "e")
2025-01-17 02:05:50 +01:00
Daniel Gibson
c23d819f5e Add com_disableAutoSaves CVar (fix )
like in Doom3 BFG: If it's set to 1, no autosaves are created when
entering a level. Defaults to 0 (autosaves enabled)

While at it, I also documented com_numQuicksaves in Configuration.md
2025-01-15 04:21:49 +01:00
Daniel Gibson
a0b52bd700 Fix scaling of Grabber cursor in RoE for non-4:3 resolutions (fix )
based on a fix from @dezo2 from the >60Hz support branch

(TBH I don't know why the crosshair must be scaled to 4:3 but the
 grabber cursor not, but this works..)
2025-01-15 01:10:10 +01:00
Daniel Gibson
ce4e6f076f Don't ignore "ridiculous mouse deltas", allow sensitivity < 1.0
Modern mice support ridiculously high DPI values, >20'000.
Not sure what that's actually good for, but if people use that, they
ran into the "idUsercmdGenLocal::MouseMove: Ignoring ridiculous
 mouse delta" case which just threw away the mouse input values so the
game didn't respond to mouse input anymore or at least felt choppy.

I'm not sure what that code was originally good for, under which
(undesired) circumstances that happened, but for now it's disabled,
only the warning is still logged, but only once.

For these high DPI values to still be usable (camera not moving way
too fast), it probably makes sense if the mouse sensitivity can be set
to values < 1.0. The CVar always supported that, but I adjusted the
Dhewm3SettingsMenu so it sensitivity can also be set to values between
0.01 and 1 there (still going up to 30, like before).

fixes 
2024-12-03 19:27:58 +01:00