Commit graph

563 commits

Author SHA1 Message Date
Kp 78fd6550ea Avoid unnecessary allocation in jukebox_play
If the song originates in an m3u playlist, no temporary buffer is
needed.  Avoid allocating and initializing one, and instead pass the
pointer directly from the CMLevelMusicPath field.
2022-07-02 18:10:45 +00:00
Kp 173d5559d7 Tighten TGA generation code
- Skip reading unused alpha channel in TGA screenshot path.  The alpha
  channel is discarded, so skip even retrieving it from OpenGL.
- Perform the red/blue swap in place, instead of copying into an
  additional buffer.
2022-07-02 18:10:45 +00:00
Kp 4fd412b2ea Precompute g3_draw_line GL color data 2022-06-05 17:44:52 +00:00
Kp e54338ce4e Combine canvas+color into g3_draw_line_context 2022-06-05 17:44:52 +00:00
Kp 9e0431b861 digi_win32_play_midi_song: write hmp_open result directly to global
Commit 3b5b69cb97 changed the logic to store the result of hmp_open
into a local that was destroyed at the end of the function.  This was
incorrect, as destruction of the returned value will immediately halt
the music.  Revert to the previous behavior, where the result is written
to the global `cur_hmp` so that it persists past the end of the
function.

Reported-by: norbert79 <https://github.com/dxx-rebirth/dxx-rebirth/issues/634>
Analyzed-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/634#issuecomment-1110510761>
Proposed-fix-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/634#issuecomment-1110510761>
Fixes: 3b5b69cb97 ("Improve error reporting for hmp_open / hmp2mid")
2022-04-28 02:19:26 +00:00
Kp 9cdf9152bc Always check return value of PHYSFSX_getRealPath
The contents of the output buffer are undefined if PHYSFSX_getRealPath
fails, so mark the function as [[nodiscard]] and modify all callers to
check that the function succeeded.
2022-03-19 22:55:58 +00:00
Kp 3b5b69cb97 Improve error reporting for hmp_open / hmp2mid
Rework the error paths to return path-specific status codes so that the
caller can report exactly which step caused an HMP file to be rejected.
On error, print this reason numerically and, if the reason was a PhysFS
error, also print the PhysFS error code numerically and symbolically.
2022-03-19 22:55:58 +00:00
Kp b8ae2c5e55 Remove unused-but-set variables in ogl_texture_stats 2022-01-15 20:39:10 +00:00
Kp d2478d0708 Require support for C++17 attribute [[fallthrough]] 2022-01-09 15:25:42 +00:00
Kreeblah 5b9b353231
Added high DPI flag to SDL 2.0 builds for macOS 2021-12-22 14:26:05 -08:00
Kp 157ec66668 Remove useless cast in DXX_USE_OGLES path in ogl_init_window
This triggers a diagnostic from -Wuseless-cast.  It appears to be
unnecessary, after tracing down typedefs.  It might need to be restored
if some platform uses a definition that is neither the same type nor
implicitly convertible.
2021-12-19 19:35:11 +00:00
Kp 93e98ae71a Fix -Wold-style-cast in DXX_USE_OGLES code 2021-12-19 19:26:44 +00:00
Kp 5eaa53d220 Fix SDL-only build 2021-11-01 03:37:20 +00:00
Kp 3cca690728 Assign weakly-typed symbolic names to ogl_ubitmapm_cs special cases 2021-11-01 03:37:18 +00:00
Kp 7bb55dff22 Remove dead computations in ogl_ubitmapm_cs 2021-11-01 03:37:18 +00:00
Kp 961aae074a Remove unused ogl_ubitmapm_cs argument scale
Every caller passes `F1_0`.  Remove the argument, and propagate its
results through the function.
2021-11-01 03:37:18 +00:00
Kp 5491630142 Pass canvas to ogl_texture_stats 2021-09-19 10:53:48 +00:00
Kp aba5fce3a9 Use enum class for gr fade_level 2021-09-19 10:53:48 +00:00
Kp 8623ce3c6a Pass canvas to ogl_draw_vertex_reticle 2021-09-12 16:20:52 +00:00
Kp 48a3ac2c53 Lift ogl_start_frame eye handling into caller 2021-09-12 16:20:52 +00:00
Kp d257d032f4 Avoid reloading GL viewport unnecessarily in stereo mode 2021-09-12 16:20:52 +00:00
Kp 7f51fa3ac5 Use enum class for VR StereoFormat 2021-09-12 16:20:52 +00:00
Kp c99b67e359 Switch callers to unchecked_partial_range(range) where possible
Use unchecked_partial_range(range) instead of
unchecked_partial_range(iterator), since the range form can preserve the
underlying index_type.
2021-09-04 12:17:14 +00:00
Kp ae3dc7f934 Simplify computed color reset
gr_find_closest_color did not need it.  Remove it.  For the others,
resetting the count is sufficient.  There is no need to reset the
individual elements.
2021-09-04 12:17:14 +00:00
Kp 1c90863d63 Move grs_main_bitmap earlier in the header 2021-09-04 12:17:14 +00:00
Kp 20a0166cf4 Avoid double-scaling sounds at start time
The SDL_mixer library has already been instructed, via Mix_Volume, to
scale the volume of sounds on all channels, by an amount based on
digi_volume.  There is no need to manipulate the effective distance of a
particular sound to further scale it by digi_volume.  Even if this
second scale was needed, it was done incorrectly, because it was only
applied when the sound was started, but not re-applied when the sound's
volume was updated due to positional changes.  As a result, any sound
which was updated would switch to an unscaled version.  Sounds which
were never updated, such as those attached to the viewer object, would
retain their original scaled volume.

Update the implementation of digi_mixer_set_channel_volume to call
Mix_SetDistance in the same way as digi_mixer_start_sound, for
readability and consistency.
2021-06-28 03:37:51 +00:00
Kp 659be87a5b Saturate return value of fix2byte 2021-06-28 03:37:51 +00:00
Kp e0008cceb3 Use enum class for sound angle parameter 2021-06-28 03:37:51 +00:00
Kp 76a7361786 Close descent.hog on exit
Add RAII wrappers for unmounting PHYSFS paths.  Use them in places that
previously handled unmounting explicitly.  Also, use it for descent.hog
/ descent2.hog, which previously were left mounted indefinitely.
2021-06-28 03:37:49 +00:00
Kp 3d14dbacde Remove digi_reset
It was only available in debug builds, and did nothing when called.
2021-06-28 03:37:49 +00:00
Kp 73c3474f8e Reduce uses of RAIIdmem for local variables 2021-06-28 03:37:49 +00:00
Dave Milici a394bd0312 Consolidated above/below format cases for readability. 2021-05-04 08:46:26 -07:00
Dave Milici 5025cedf45 Simplified case for above/below blank interval adjustment. 2021-05-03 16:05:12 -07:00
Dave Milici ea6379de2d Add above/below option sync blank interval for external sync doubler. 2021-04-08 14:07:35 -07:00
Kp 70ef749ff4 Consolidate stereo GL calls
Reorder the logic to unify the common calls at the bottom of the
function, and skip computing anything if called in no-stereo mode.
2021-04-04 22:01:25 +00:00
Kp 426621398f Only read viewport if VR needs it for an update 2021-04-04 22:01:25 +00:00
Kp 8cc8e80eae Fix VR build failure due to implicit fallthrough
The fallthrough appears to be intentional.  Add an annotation to allow
it.

Fixes: 6bc0e822d2 ("Handle HUD overlays in separate screen rects for stereo renderings.")
2021-04-04 22:01:25 +00:00
Dave Milici 6bc0e822d2 Handle HUD overlays in separate screen rects for stereo renderings. 2021-03-17 16:30:31 -07:00
Dave Milici ca1478ea88 Relocate stereo viewport scaling at caller level outside of OGL layer.
Almost compatible size with HUD screen effects if re-enabled.
2021-03-15 20:02:22 -07:00
Dave Milici 528650c37e Use std::array for viewport/tranform params per PR suggestion. 2021-03-15 14:45:29 -07:00
Dave Milici 08b8790ad0 Remove separate left/right caches for stereo viewport + transform params.
ogl_stereo_frame() is only ever called once for selected stereo view..
2021-03-15 14:30:48 -07:00
Dave Milici ab7924e129 Relocate viewport/transform adjustments inside ogl_stereo_frame() call.
Note since ogl_stereo_frame() is only ever called once per ogl_start_frame()..
ogl_end_frame() instance, only the active stereo eye view needs to be handled.
Implies that separate left/right viewport/transform caches are redundant.
2021-03-15 14:01:53 -07:00
Dave Milici fdfcb726d1 Use frustum left/right clipping for image shift instead of viewport clipping.
left/right clipping planes affected by frustum matrix term M[2][0] (8th element)
2021-03-14 11:45:37 -07:00
Dave Milici 4ca5f63b49 Use GL viewport clipping for stereo parallax image shift adjustments.
Equivalent to legacy Descent 1.5 pixel shift methods for stereo formats.
Since Descent is rendering viewpoint differences for left/right eyes,
pixel shifting via display viewport is sufficient adjustment.

Since OGL layer here is essentially handling display output surfaces,
the OGL projection transform is not useful for stereo parallax effects
as when used for 3D scenes.
2021-03-11 12:32:01 -08:00
Dave Milici 8c8b7419b6 Improved conditionals for stereo vs non-stereo modes.
Hot-key handling for cycling thru stereo modes & parallax adjustments.
Simplified stereo adjustments for left/right eye separation & offsets.
Not quite compatible yet with Bob Akka stereo method from Descent 1.5.
Function key assignments different (F5..F8) due to pre-empted hot-keys.

ALT+SHIFT+F5:	decrease eye separation (VR_eye_width)
ALT+SHIFT+F6:	increase eye separation (VR_eye_width)
    SHIFT+F5:	decrease image shift (VR_eye_offset)
    SHIFT+F6:	increase image shift (VR_eye_offset)
ALT|SHIFT+F7:	reset eye separation + image shift
ALT|SHIFT+F8:	cycle thru half-width + half-height formats

Note for compiling dxx-rebirth snapshot on MacOSX:

export CXXFLAGS=-Wno-uninitialized
scons macos_add_frameworks=False
2021-03-11 12:32:01 -08:00
Dave Milici bb903a1d80 Support stereo viewport rendering in half-height & half-width formats.
Enable stereo mode when launched via -gl_stereo option.
GL_STEREO quad buffering may not be available unless OGL layer
supports stereo pixel format descriptors.
Half-height viewport rendering for above/below format.
Half-width viewport rendering for side/by/side formats.
HUD & cockpit elements disabled when stereo views active.
2021-03-11 12:32:01 -08:00
Dave Milici 4169183342 Initial stereo rendering test in side-by-side format.
OGL layer used for rendering surfaces, so using left/right viewports absent stereo quad buffers.
Using legacy Descent +/- eye offset method for left/right stereo perspective rendering passes.
2021-03-11 12:32:01 -08:00
Kp 9aab870cad Fix build break in digi.cpp
fbd05a1592 dropped an include of "jukebox.h" as unnecessary.  jukebox
was almost unnecessary, but jukebox includes physfsx, and physfsx
includes stdexcept.  stdexcept is necessary.  Include stdexcept
directly.

Fixes: fbd05a1592 ("optimize include files (include what you use)")
2021-02-20 23:46:51 +00:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp b70f569178 Use enum class for OGL_TEXFILT_* constants 2021-01-17 22:23:23 +00:00