1
0
Fork 0
Commit graph

280 commits

Author SHA1 Message Date
krcroft
a8a0e5fa91 Cleanup PVS warning about uninitialized members 2020-04-04 04:10:06 +02:00
krcroft
619742f70f Improve comment about EXPOSED event 2020-03-30 21:48:02 +02:00
krcroft
b4e6e40c95 Assess the mouse capture state when gaining window focus
This fixes mouse visibility issues on the Raspberry Pi,
which uses an older customized version of SDL2. SDL2 on
the Pi fires different windows events in a different
order, making dealing with states challenging.

To handle this generically, we additionally assess the
mouse capture state after the Window has gained focus.

We also add a "has_focus" state tracking boolean to the
SDL object, which protects against general SDL mouse
trigger events from changing the mouse state before the
Window has "risen" and delivered us an EXPOSED or FOCUS
event. In the prior code rapidly clicking the mouse while
DOSBox was starting could freeze the mouse cursor in
place on the Pi.

We still also assess the mouse state on EXPOSE events,
which is fired after full - windowed modes are toggled.
The EXPOSE even occurs reliably on OSX, X11, Wayland, and
Windows after the window has settled (but is never fired
on the Pi).
2020-03-30 21:48:02 +02:00
Patryk Obara
9d2b7ea578 Adjust help strings for sdl options 2020-03-27 00:54:11 +01:00
Patryk Obara
193f2ed564 Declare sdl.vsync as deprecated/disabled
vsync is an option introduced by SDL2 patch, but the testing indicates,
that it very rarely (if ever) works.  We still want to support it, but
this might require serious implementation effort, so for the time being
we're removing broken option to prevent confusing the users.
2020-03-27 00:54:11 +01:00
Patryk Obara
779131d396 Skip splash screen if resolution is not large enough
It's the easiest way to prevent problems when user wants to play the
game using fullscreen while explicitly setting tiny resolution
for a specific game (e.g. 320x200).
2020-03-27 00:54:11 +01:00
Patryk Obara
5ac2567adc Rename gimp_image to splash_image 2020-03-27 00:54:11 +01:00
Patryk Obara
6f238c0d1a Fix splash screen for surface output
All rendering backends except output=surface assume input buffer row
with the same length as output buffer row. Surface is "special" and in
fullscreen uses pitch equal to *screen* width instead. Padding the
output rows with black pixels is necessary for splash screen to show up
correctly.
2020-03-27 00:54:11 +01:00
Patryk Obara
00ffbd0977 Remove dead code remains of "lazy_fullscreen" feature 2020-03-27 00:54:11 +01:00
Patryk Obara
1f62338610 Fix indirect memory leak of icon surface 2020-03-27 00:54:11 +01:00
Patryk Obara
d34378b621 Define SDL rgb-masks for creating surfaces 2020-03-27 00:54:11 +01:00
Patryk Obara
a5b65b3c8e Initialize default window size before GUI_StartUp 2020-03-27 00:54:11 +01:00
Patryk Obara
acb020147d Move "extern C" to ppscale header 2020-03-27 00:54:11 +01:00
Patryk Obara
facabcee2a Handle surface as the last option during update
SCREEN_SURFACE is no longer the default option, and it's usable only for
debugging purposes. Move it to the last position in switches, to make
texture and opengl a little bit faster.
2020-03-27 00:54:11 +01:00
Patryk Obara
8d5bc9537a Prevent a crash in Windows AMD drivers
Usually, when window is being created without SDL_WINDOW_OPENGL flag,
SDL2 internally re-creates it to support OpenGL during
SDL_CreateRenderer if needed.

This leads to crash in AMD OpenGL drivers (Windows only), which happens
for drivers: "opengl", "opengles", "opengles2".

When the window is created with correct flag from the get-go, the crash
does not happen.

On Linux, the code does not crash either way (at least not when using
Mesa and AMDGPU open source driver), so there's no point in propagating
the hack.

Also, remove a comment that is no longer relevant to the code below.
2020-03-27 00:54:11 +01:00
Patryk Obara
bb43294f68 Store SDL texture render driver as std::string 2020-03-27 00:54:11 +01:00
Patryk Obara
54a50d4231 Replace Lock/UnlockTexture with UpdateTexture
Lock/UnlockTexture is stable and works very well on Linux and with
OpenGL texture driver and on Linux and Windows, but it's usage caused
problems with content of updated texture when used with drivers:
'direct3d11' on Windows and 'metal' on macOS.

Also, Lock/Unlock turned out to be the root cause of deadlocks for
'opengl' driver on AmigaOS.

According to SDL2 documentation, using Lock/UnlockTexture is supposed to
be faster, but in DOSBox usecase we couldn't confirm significant
performance change - there are some community reports indicating, that
UpdateTexture might be actually faster (but we couldn't confirm it
either).

Discussion on this topic can be found on SDL forum:
https://forums.libsdl.org/viewtopic.php?t=9728

In our case, switch to UpdateTexture has no serious negative impact, but
makes the behaviour more robust across the board.
2020-03-27 00:54:11 +01:00
Patryk Obara
fa4e8c28de Update description of sdl.windowresolution 2020-03-27 00:54:11 +01:00
Patryk Obara
aed68e9e6e Destroy SDL resources in the proper order
Prevent internal SDL2 asserts on Windows 10 when using output=texture,
also improves stability on AmigaOS and Linux using Wayland.
2020-03-27 00:54:11 +01:00
Patryk Obara
d3f3833f2c Set icon after sdl.window is created
Otherwise internal SDL2 asserts are triggered in Windows debug builds.
2020-03-27 00:54:11 +01:00
Patryk Obara
919099c757 Start with the correct full/window resolution
Make the user settings affect splash screen as well as emulator; this
way, when user wants to start in fullscreen, the splash screen will be
displayed in fullscreen - making the startup process more streamlined.

This fixes long-standing problem on SteamOS (or Steam in Big Picture
mode), when starting dosbox moves the user out of fullscreen to window
(to show tiny splash screen), and then back to fullscreen.
2020-03-27 00:54:11 +01:00
Patryk Obara
600ccccd37 Display splash screen using GFX API
Simplify the code displaying the splash screen and extract it to a new
function. Using GFX_* functions avoids the problem of re-creating
the window from scratch after splash is shown, which solves a lot of
problems:

- application window is always visible on screen, it does not disappear
  for a moment between closing splash and starting emulator.
- seriously reduces resolution trashing on start
- user will not experience loss of window focus due to splash screen
  disappearing (this was happening e.g. on AmigaOS)
2020-03-27 00:54:11 +01:00
Patryk Obara
0b173eec08 Cleanup and document GFX_StartUpdate function
Usage of this function depends on the state of global sdl struct; and
it's very easy to make a mistake - documentation should lower this risk.

Change the type of output parameter 'pitch' and assure type safety with
internal SDL types via static asserts.
2020-03-27 00:54:11 +01:00
Patryk Obara
08934b2972 Remove dead code remains of WinDIB usage
This used to have meaning for Windows 9x support via SDL 1.2; the issue
described in README was never mentioned in the context of SDL2.

Add missing include to video header while we're at it.
2020-03-27 00:54:11 +01:00
krcroft
a1a3e0203d Only initialize the mapper once during startup 2020-03-21 23:41:06 +01:00
krcroft
81efce0862 Refactor and make the joystick querier re-runnable
The previous function could only be effectively run one because
it changes the value of the global 'joytype' to something other
than AUTO, which is what this function looks for to re-query
the joysticks.

Second, if this function is run more than once, then it clobbers
the prior set number of joysticks back to zero (without
re-requerying for the actual quantity), rendering the joysticks
unuseable.

Finally, this function depends on several SDL calls to the joystick
subsystem, but fails to check or initialize it.

The commit:
 - Checks for an initializes the joystick subsystem before using it
 - Always re-queries the current state of the joystick (re-runnable)
 - Simplifies the logic to determine useability (retains criteria)
 - Conservatively writes the joysticks quantities at the end
2020-03-20 01:06:23 +01:00
Anton Shepelev
d1be65b105 Add output type texturepp for pixel-perfect scaling
The new output type `texturepp' was added, which implements
pixel-perfect scaling using SDL's hardware-accelerated texture output.
In pixel-pefect mode, each original pixel is displayed as a rectangle m
by n pixels, so that m:n yields a reasonably good approximation of the
pixel aspect ratio (PAR) of the emulated graphical mode while using as
much screen space as possible. The balance between the precision of
aspect ratio and the utilisation of screen space is specified as the
`parweight' parameter to pp_getscale() and is currently hard-coded in
sdlmain.cpp.

This implementation emulatates pixel-perfect mode as a special case of
nearest-neighbor interpolation when the horisontal and vertical scaling
factors are integers.
2020-03-09 20:12:36 +01:00
Joshua Fern
f2029d71d8 Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
Patryk Obara
8703917a02 Fix window position when starting in fullscreen 2020-02-21 01:20:16 +01:00
Patryk Obara
c77638bb18 Fix window position when switching to windowed mode 2020-02-21 01:20:16 +01:00
Patryk Obara
6ffe13d81f Change 'sdl.fullresolution' default to 'desktop'
It works the same as 0x0, except it's documented in help string. Remove
the misleading and old comments from the help string.
2020-02-15 19:10:20 +01:00
Patryk Obara
040e47372e Change 'sdl.capture_mouse' default to 'seamless middlerelease'
Also, reformat help string, so that help comment generated in default
.conf file sort-of matches 80 columns.
2020-02-15 19:10:20 +01:00
Patryk Obara
9fee755542 Change 'sdl.output' default to 'opengl'
When OpenGL support is disabled during compilation, previous default of
'texture' is preserved.
2020-02-15 19:10:20 +01:00
Patryk Obara
6099ab60f3 Merge branch 'svn/trunk' r4326 2020-02-15 17:53:38 +01:00
Peter Veenstra
9912151a89 Add patch 285 from MHM to fix bug 367, mimics the normal event.gain code
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4326
2020-02-14 21:52:10 +00:00
Peter Veenstra
a2f473cebd Fix compilation for platforms where the include guard is different and the exported symbol was changed by Khronos.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4323
2020-02-14 16:53:52 +00:00
Peter Veenstra
5fc132c124 Improve logging and OS X support (jmarsh).
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4322
2020-02-13 20:39:45 +00:00
Peter Veenstra
c765582c3e Some fixes to 4319 by jmarsh.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4321
2020-02-12 16:18:05 +00:00
Patryk Obara
45704c95fe Remove useless cast 2020-02-12 08:43:13 +01:00
Patryk Obara
b7ec86f980 Prevent compilation of unreachable code
Fixes a finding from PVS-Studio and Coverity each.
2020-02-12 08:40:39 +01:00
Patryk Obara
e872ea0169 Use memory safe container for GL error log
Fixes V576 warning from PVS-Studio - in this case PVS is somewhat
pedantic, as it warns about printf'ing of malloc'ed memory and risk the
associated problems in OOM situations.

In this case it can be a problem, as LOG_MSG aka GFX_ShowMsg
allocates memory during printing in result an error message could cause
stack overflow, although it's extremely unlikely on modern OSes.

Avoid triggering this warning by using memory-safe container and using
C++11 data() accessor to vector internal buffer; in case of OOM
situation, stack will be unrolled and program should exit with nice
error message.
2020-02-12 08:40:01 +01:00
Patryk Obara
be6b446028 Merge branch 'svn/trunk' r4319 2020-02-12 08:39:40 +01:00
Peter Veenstra
4a565a75ed Add OpenGL shader support. (patch by ny00123 and refined by jmarsh). Add several builtin ones that mimic the scalers and some extra. Thanks jmarsh
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4319
2020-02-10 18:59:01 +00:00
Peter Veenstra
eb9b86269d Some graphics cards return a too small overlay when the size is larger than 1024. Fall back in that case.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4315
2020-02-07 14:25:52 +00:00
krcroft
219ebc491c Fix six Coverity and PVS analysis bugs 2020-02-02 16:37:09 +01:00
krcroft
1666275515 Fixup all effc++ warnings 2020-02-02 00:43:24 +01:00
krcroft
3446db1ee9 Expand mouse control methods
Replace the [sdl] `autolock = true/false` configuration setting with [sdl]
`capture_mouse = ...` with a two-value setting.

The first value defines how the mouse is controlled:
- onclick:       The mouse will be captured with a click inside the window.
- onstart:       The mouse is captured immediately on start (similar to real DOS).
- seamless:      The mouse will move seamlessly in and out of DOSBox and cannot be captured.
- nomouse:       The mouse is disabled and hidden without any input sent to the game.

The second value defines how middle-clicks are handled:
- middlegame:    Middle-clicks are sent to the game (not used to uncapture the mouse).
- middlerelease: Middle-click will uncapture the mouse when windowed (not sent to the game).

Middle-clicks are sent to the game when fullscreen or when seamless control is set.

The default setting of "onclick middlegame" reproduces DOSBox's existing behavior.
2020-02-02 00:43:24 +01:00
Patryk Obara
1f1e832a6c Use dosbox-staging splash screen
Users who test dosbox-staging via various GUI frontends might have a
problem distinguishing if the instance they have configured is really
dosbox-staging or some other version of DOSBox. Different splash screen
is a simple remedy for it.

Two graphical files are included: one in vector format to allow for
further refinements and one converted to necessary size in png format,
that is used as direct source of logo embedded in the source code. Use
GIMP to convert the png logo to a C file.

Notes about new design:

Orange background was replaced by black to make switch to black
background of empty terminal a little less jarring.

The box side is covered with the rainbow-like pattern to resemble logos
of various computer platforms popular in the 80s.  AFAIK IBM or
PC-clones never had such colourful logos, but the point is to resemble
a retro-computing platform while being aesthetically pleasing.

Some computing platforms, that used rainbow patterns are Sinclair,
Commodore, Amiga, Dragon 32, and Apple.  The pattern used for
dosbox-staging splash is deliberately different from all of these.

Word "staging" is rendered using excellent Raleway font:
https://www.theleagueofmoveabletype.com/raleway

This change is not supposed to be upstreamed.
2020-01-16 06:42:19 +01:00
Patryk Obara
5e3535f1e5 Merge branch 'svn/trunk' r4306 (sans SDL 1.2 bits)
This merge had serious conflicts; some of changes could be applied, but
others needed to be removed.

- Code for new SETMODE_RESTARTS_SUBSYSTEM was removed, as it depends on
  SDL 1.2 functionality (SDL_SetVideoMode) and seems rather pointless
  for SDL 2.0.
- Support for setting windowresolution as a percentage was retained, but
  window centering of this feature likely won't work, as it depends on
  SDL 1.2 env variable SDL_VIDEO_CENTERED.
- Support for applying windowresolution as a percentage was removed, as
  it was implemented purely in code removed during transition to
  SDL 2.0.
2020-01-08 04:27:29 +01:00
Patryk Obara
343b9babca Merge branch 'svn/trunk' r4305 2020-01-07 11:29:39 +01:00