Commit graph

485 commits

Author SHA1 Message Date
Kp 23ebf27554 Move digi functions to dcx; use bitset for channels 2020-04-04 19:30:22 +00:00
Kp 3f8aced47d Check for converted sounds before doing any work 2020-04-04 19:30:22 +00:00
Kp 443f4f8c83 Avoid reloading ObjBitmapPtrs[i] 2020-04-04 19:30:22 +00:00
Arne de Bruijn a2b49a9a08 Add PIGGY_PAGE_IN to ogl_cache_polymodel_textures 2020-04-04 12:13:59 +02:00
Kp af8adaef1b Defer digi_mixer_start_sound work until it is needed
If no channel is available, the mix parameters are unused.  Move their
construction to occur after a channel for the sound is found.
2020-03-28 16:55:43 +00:00
Kp b19496ca72 Set digi_mixer channel callback once at startup
The callback is never changed, so it does not need to be reset on every
new sound.
2020-03-28 16:54:28 +00:00
Kp 6a27ae3544 Prevent copying RAIIMix_Chunk
No code tried to copy it, but if a copy was created, it would cause a
double-free later.  Prevent copying to avoid introduction of a
double-free bug.
2020-03-28 16:51:43 +00:00
Kp 59b94a4dcb Call arch_close before atexit hooks begin
arch_close calls various library shutdown routines, some of which may
not be in good order after atexit hooks begin executing.  Call it before
returning from main, so that the libraries are still fully initialized.
2020-01-06 01:25:35 +00:00
ziplantil 639d33b4de reorder palfx logic; use inline func in gr_palette_step_up 2019-07-28 12:47:24 +03:00
ziplantil 4f3b2a1520 make alast_* function-local 2019-07-28 01:41:37 +03:00
ziplantil f446790b03 optimize; abs no longer necessary 2019-07-28 00:49:30 +03:00
ziplantil 4eab54284c change palfx code; special only for all < 0 (cloak) 2019-07-28 00:42:37 +03:00
ziplantil 3753e5942d fix effect (on GL) when picking up cloak 2019-07-27 23:38:34 +03:00
Kp 86053852dc Fix build of SDL-only gr.cpp 2019-07-07 22:00:02 +00:00
Kp 3bd10610fc Use xrange for loops with zero start and simple identifier end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*!=\s*\([A-Za-z_0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3))/
2019-05-04 18:27:37 +00:00
Kp 2243cd7f58 Use xrange for loops with zero start and constant numerical end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*\(!=\|<\)\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\4u))/
2019-05-04 18:27:36 +00:00
Kp 3e25804026 Use NSDMI wherever possible 2019-04-28 00:53:40 +00:00
Kp 063bf29225 Enable -Wimplicit-fallthrough=5; fix resulting breaks
This enables using -Wimplicit-fallthrough with ccache+distcc, which
strip the fallthrough comments, but do not strip the attribute
annotationns.
2019-04-04 04:29:03 +00:00
Kp 699030606e Move Effects to d_level_unique_effects_clip_state 2019-03-03 00:31:09 +00:00
Kp 1008ab397e Move Objects to d_level_unique_object_state 2019-03-03 00:31:08 +00:00
Kp e84a65edc6 Move Robot_info into LevelSharedRobotInfoState 2018-12-30 00:43:59 +00:00
Kp 03fe3a6696 Move Polygon_models into LevelSharedPolygonModelState 2018-12-30 00:43:59 +00:00
Kp 706a704c6d Move unique_side to unique_segment 2018-12-13 02:31:38 +00:00
Kp a0ed5cb283 Pass Vclip as context 2018-10-21 00:24:07 +00:00
Kp 04569ebba5 Fix clang warning about using %hu with unsigned
gcc permits this, but clang complains.  Match the format specifier to
the type of the underlying temporary variable.

Fixes: a65068fed1 ("Move OGL RLE bitmap buffer to stack")
2018-10-20 17:25:59 +00:00
Kp a65068fed1 Move OGL RLE bitmap buffer to stack
Shrink it from 1MB to 300KB.  Add a diagnostic if the expansion fails
due to insufficient capacity.

300KB is required for the ship cockpit bitmap.  Everything else seems to
be smaller.
2018-09-19 02:13:29 +00:00
Kp 12b57e84e6 Switch most in-tree http:// links to https://
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it.  These domains were converted:

* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
2018-09-02 00:57:29 +00:00
Kp 1b8ff6ac77 SDL2-mixer: fix noise from reading undefined sound data
Commit a833d73d44 added the SDL_mixer backend for Rebirth sound.  That
commit set the length of the converted sound equal to the size of the
buffer that SDL requested as a work area.  No one ever touched that
logic, until now.  In SDL1, that choice worked fine.  In SDL2, this
causes garbage to play after the sound, because SDL2 considers the
buffer to be defined only up to the length returned in
`SDL_AudioCVT::cvt_len`.  Bytes beyond that length are undefined[1], and
in practice contain garbage.  Fix the noise by setting the sound length
equal to the length returned by SDL2, so that the undefined bytes are
not treated as sound.  SDL1 also maintains this length value, so no
version-specific logic is required.

[1]: https://wiki.libsdl.org/SDL_ConvertAudio

Reported-by: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/396>
2018-07-30 00:49:59 +00:00
Kp f491059ed7 Enable building with SDL2
This commit enables Rebirth to build with SDL2, but the result is not
perfect.

- SDL2 removed some sticky key support.  Rebirth may behave differently
  now in this area.
- SDL2 removed some key-repeat related support.  Rebirth may behave
  differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
  the desktop instead of by changing the desktop resolution.  Rebirth
  uses this, and it mostly works.
  - Resizing while in the automap does not notify the automap code, so
    the view is wrong until the player switches out of automap mode and
    back in.
- SDL2 changed how to enumerate available resolutions.  Since
  fitting the window to the desktop is generally more useful than
  fitting the desktop to the window, I chose to drop support for
  enumerating resolutions instead of porting to the new API.  Users can
  now enter an arbitrary window dimension and Rebirth will make an
  attempt to use it.
  - It might be useful to cap the window dimension at the desktop
    dimension, but that is not done yet.
  - Entering fullscreen mode through the Controls->Graphics submenu
    failed to notify the relevant subsystems, causing the rendered
    content not to rescale.  For now, compile out the option to toggle
    full screen through that menu.  Toggling through Alt+Enter works
    properly.

Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all.  The remaining issues can be
resolved in future work.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-28 23:22:58 +00:00
Kp da268c6d21 Preprocess out glmprintf in normal builds
Using sizeof(con_printf A) was a trick to avoid code generation, but it
interacts badly with gcc-6 and the other macros that con_printf
produces.  On >=gcc-6, `DXX_ALWAYS_ERROR_FUNCTION` is a complicated hack
to work around undesirable changes in `__builtin_constant_p`.  That hack
includes introducing a dummy type.  gcc-6 rejects declaring a type
inside a statement expression inside a sizeof.  gcc-7 permits this, so
it went unnoticed.

This particular usage was to prevent future regressions in calls that
had been broken for years without anyone noticing.  As such, reverting
to not checking those calls is unlikely to matter.

Reported-by: Ambaire <https://github.com/dxx-rebirth/dxx-rebirth/issues/393#issuecomment-401565872>
Fixes: 9b17450914 ("Fix up long broken glmprintf support")
2018-06-30 21:53:55 +00:00
Kp 9dafe85bbf Simplify clamping color values in SDL palette setup 2018-06-29 03:24:36 +00:00
Kp 9b17450914 Fix up long broken glmprintf support
Switch the macro so that the result is always checked for correct
syntax.  This will prevent future bitrot.
2018-06-08 04:04:05 +00:00
Kp d355ef4030 Pass font to various drawing functions 2018-05-19 23:21:42 +00:00
Kp fda1eb851e Pass fonts to LINE_SPACING 2018-05-19 23:21:42 +00:00
Kp 08446f0ab6 Pass font to gr_string,gr_printf 2018-05-19 23:21:42 +00:00
Kp 4a98e796ab Prevent stacking weapon rotation sounds
digi_play_sample_once is supposed to cancel prior instances of the
sound, but that functionality was lost in
21082c6db2.  As a result, the sound can be
stacked up to the limit of the engine.  Even when the functionality
existed, its implementation was wrong.

- Change these sounds to be attached to the player generating them.
- Pass the cancellation flag to other players when sending a sound.
- Send the full value of `volume`, rather than truncating it.
- Implement cancellation by killing and restarting the earlier version of a cancelled sound.
- Delete an ugly hack that prevented the patched logic from ever running.
- Fix an ancient quirk in digi_mixer that caused it to report all sounds as not playing, which then caused digi_sync_sounds to instantly cancel the new sound.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88>
Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88#issuecomment-269597361>
Fixes: 21082c6db2 ("Added own channel management to SDL_mixer sound interface since the builtin channel management of this lib cannot handle our needs; Little code cleanup")
2018-05-13 03:14:34 +00:00
Ronald M. Clifford a9fb3c9df9 Add missing glDisableClientState call. 2018-04-22 23:31:27 -07:00
Ronald M. Clifford e9d36a29c1 Fix Blocky Filtered option.
[Kp: as discussed in pull #377
<https://github.com/dxx-rebirth/dxx-rebirth/pull/377>, the previous
implementation requested a parameter combination not permitted by
OpenGL.  At best, this error was silently ignored.  Fix the error by
falling through to a switch case statement that sets valid parameters.]
2018-04-23 05:07:15 +00:00
Kp 869fea9498 Make SDL-only SDL_Surface pointers static 2018-03-02 03:19:02 +00:00
Kp 131c1b9f4d Add support for PNG screenshots 2018-02-18 00:42:42 +00:00
Kp 6e5c5f5c49 Mark some ogl parameters const 2018-02-01 05:38:47 +00:00
Kp 01e1b28d71 Replace useless printf with puts 2017-12-05 05:29:55 +00:00
Kp d049f738c8 Convert various gr_set_current_canvas calls to reference form 2017-11-05 20:49:08 +00:00
Kp ca804d5186 Clear canvas to fix missing exit tunnel movie
Global variable `grd_curcanv` is set to a variety of canvases, some of
which are local stack variables.  Use of global variables in this way is
fragile, but works as long as the global is not used beyond the life of
the backing local.

Unfortunately, some existing uses do access the canvas beyond the
lifetime of the backing local.  Playing movies sets the font of the
current canvas.  If the current canvas is an expired stack variable,
setting the font overwrites other stack data.  This data corruption
causes various symptoms, such as inability to play the escape tunnel
movie.

Prior to 03cca2b3dc, the corruption on
playing the endlevel movie had no user-visible effect.  That commit
created a large local variable, which changed stack layout.  Starting
with that commit, the corruption causes the movie to play as all black.

Fix this, and protect against some other data corruption possiblities,
by clearing the global when the local goes out of scope.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/345> (only as cutscene failure to play, not as the underlying corruption issue)
2017-11-05 20:49:08 +00:00
Kp 49c0cdae2e Simplify calls to gr_set_default_canvas
Rather than use an inline wrapper and rely on the compiler optimizer to
redirect gr_set_current_canvas(nullptr) to gr_set_default_canvas,
rewrite all relevant calls directly in the source.

git grep -l 'gr_set_current_canvas' | xargs sed -i -e 's:gr_set_current_canvas(\s*NULL\|nullptr\s*);:gr_set_default_canvas();:'
2017-11-05 20:49:08 +00:00
Kp e58956ddeb Simplify digi_audio_stop_all_channels 2017-10-14 17:10:31 +00:00
Kp 88832e3679 Use constexpr integral_constant for various magic numbers 2017-10-14 17:10:30 +00:00
Kp 3340a6c16c Report compiled/loaded library versions at verbose level
When reporting use of SDL_mixer, report its loaded version.  When
running in verbose mode, report both the compile-time and load-time
versions of PhysFS, libSDL, and SDL_mixer.
2017-08-26 19:47:51 +00:00
Kp 6b209c8713 Decorate OpenGL messages
Some Linux libraries print their own messages to stdout/stderr,
particularly in case of severe errors.  Decorate messages generated by
Rebirth to distinguish them from library generated messages.

For specific blacklisted renderers, add a message informing the user
that the blacklist matched and changed settings.
2017-08-26 19:47:51 +00:00
Kp b65b6339f4 Make g3_draw_sphere pnt argument const (for OGL only)
SDL still needs to modify it, so use alias type `cg3s_point`, which is
`const g3s_point` in OGL and `g3s_point` in SDL.
2017-08-16 01:54:26 +00:00