Commit graph

236 commits

Author SHA1 Message Date
Le Philousophe
2d1b05bf17 BACKENDS: SDL: Fix sdlGetAttribute shim on SDL2
sdlGetAttribute returns true on success (like SDL_GL_GetAttribute on
SDL3), but SDL_GL_GetAttribute on SDL2 return 0 on success.
2025-02-22 10:57:49 +01:00
scemino
8afb2c1f62 BACKENDS: Add SDL3 backend + update imgui 2025-02-18 22:13:56 +01:00
Le Philousophe
37305ba22c SDL: Allow to use ImGui with a GLES2 context
Init ImGui after our GLContext object has been initialized and check the
context type to specify the proper GLSL version.
Also make sure we are not in GLES mode before setuping ImGui.
2025-02-16 18:43:41 +01:00
Eugene Sandulenko
60d2b72fb1
BACKENDS: OPENGLSDL: Fix potential division by zero. CID 1452787 2024-10-25 15:59:57 +02:00
Le Philousophe
f04f248f20 BACKENDS: SDL: Implement ImGui API to load images 2024-09-29 17:04:03 +02:00
Le Philousophe
2eebb5db02 BACKENDS: SDL: Add SDL2 Renderer support for ImGui
Some adaptations will be needed for the the engines.
2024-09-29 17:04:03 +02:00
Vladimir Serbinenko
488353480f SDL, COMMON: Support screen rotation 2024-09-29 02:10:39 +03:00
Filippos Karapetis
928f5bbcff BACKENDS: Minimal render rate support (force-frame-update)
Originally authored by @magicmyth in PR #1039

ScummVM is optimised to render frames when something changes on screen.
As some host environments can perform poorly if the app does not
reliably refresh its output regularly (notably Steam overlay) this new
option ensures that Scummvm outputs a minimal amount of frames even if
nothing is changing in the game renderer.

Currently this is only implemented in the SDL OpenGL renderer.

The new config option is called force-frame-update and it takes a
integer value representing the desired minimum milliseconds Scummvm
should wait before forcing a screen update/refresh. E.g: 50.

Note that the rendering system will not force a re-draw of a frame if
the app has rendered a changed frame within the desired minimum refresh.

Thus if the app is outputting 30fps and force-frame-update is set to
100ms (~10fps) then no duplicate frame will be shown (in theory).

As this is implemented in OpenGLSdlGraphicsManager::updateScreen()
OpenGLGraphicsManager::_forceRedraw has had its access changed to
*protected* so that it can be access by it's descendant. The reason this
has been done in OpenGLSdlGraphicsManager::updateScreen() is so
SDL_GetTicks() can be used to track the elapsed time. If it is useful
for other platforms using OpenGL to have this feature it could be
implemented within OpenGLGraphicsManager::updateScreen() provided a
suitable platform independent replacement for SDL_GetTicks() is used.
This would potentially be better as OpenGLSdlGraphicsManager checks
various other states when deciding if the screen should update.
2024-09-03 10:58:56 +02:00
Le Philousophe
17a1b37dda BACKENDS: SDL: Refactor ImGui processing
This unifies the ImGui processing for both 2D and 3D engine.
This also make sure we don't destroy ImGui if init failed (like on older
OpenGL).
The destroy callback is also called whenever we destroy the context.
2024-06-30 15:57:03 +02:00
scemino
4a1209da9f IMGUI: Use docking branch
This is is imgui commit fee0210592b9cb5b1a778f005ffb1fe76b19ced0
2024-05-24 16:35:55 +02:00
Hubert Maier
09879b225b JANITORIAL: Fix choosen typo in openglsdl-graphics.cpp 2024-05-18 13:52:31 +02:00
Eugene Sandulenko
34be774f4b
BACKENDS: IMGUI: Bump ImGui to v1.90.6 2024-05-17 22:19:46 +02:00
Eugene Sandulenko
4cd62e3398
BACKENDS: IMGUI: Renamed modified files to minimize diff with upstream 2024-05-17 01:46:45 +02:00
scemino
8e07681356 BACKENDS: Update setImGuiRenderCallback in OSystem 2024-05-03 20:04:30 +02:00
Eugene Sandulenko
9bfba6bacc
JANITORIAL: Fix code formatting 2024-04-28 22:04:23 +02:00
Le Philousophe
a04fe8ef2f OPENGL: Don't always force redraw when ImGui is enabled
Only do it when ImGui is enabled by the engine and move the check in SDL
backend where ImGui is supported.
This makes the OpenGL backend independent of ImGui.
2024-04-28 21:48:10 +02:00
Le Philousophe
e6a7d6bc9b OPENGLSDL: Don't compile code when not on SDL 2.0 2024-04-28 21:48:10 +02:00
scemino
b721f95ffe BACKENDS: Add imgui in OpenGL backend 2024-04-28 13:59:31 +02:00
Christian Kündig
7bdadaefae EMSCRIPTEN: GRAPHICS: Fix screenshots 2024-02-27 17:07:13 +01:00
Le Philousophe
e689166a2c BACKENDS: Make screenshots use the Path class 2023-12-24 13:19:25 +01:00
Rana prathap
97a9ed6e8d OPENGLSDL: add way to force update the window to required resolution 2023-11-17 20:28:39 +01:00
Le Philousophe
adda0dc063 BACKENDS: OPENGL: Allow the backend to specify the render target
For now only backbuffer is used.
2023-07-03 21:50:32 +02:00
antoniou79
38e88cde66 BACKENDS: GRAPHICS: Implement scaler scrolling for OpenGL
Using the Ctrl+Alt+0 or 9 keymap

Also added a guard check for kFeatureScalers to allow the actions (kActionNextScaleFilter, kActionPreviousScaleFilter) to change scaler (but not scaler factor) in sdl/sdl-graphics.cpp
2023-06-17 20:21:29 +02:00
Le Philousophe
4a7d75595d OPENGLSDL: Make sure pipeline is destroyed when Manager is destroyed
When destroying the Manager its context is always destroyed.
Destroying OpenGLGraphicsManager must destroy the pipeline too.
2023-02-12 18:06:21 +01:00
Cameron Cawley
40f797fdef SDL: Support VSync with OpenGL in SDL1 builds 2023-01-16 18:09:53 +01:00
Cameron Cawley
138a983d80 COMMON: Refactor VSync handling to match the other options 2023-01-16 18:09:53 +01:00
Le Philousophe
06c38bbf3f OPENGLSDL: Redraw screen when receiving an expose event
Without this, the window is not refreshed when it is recovered or
minimized and restored.
2022-10-30 12:34:23 +01:00
Cameron Cawley
347870e6ea OPENGLSDL: Remove _ignoreLoadVideoMode
It doesn't work properly with shaders.
2022-10-08 23:39:18 +02:00
Le Philousophe
cecd5b3385 SDL: OPENGL: Remove useless #if guard
The code was already guarded by the same condition
2022-08-25 17:57:38 +02:00
Carlo Bramini
bdd2fb61d1 BACKENDS: OPENGLSDL: Fix corrupted graphics.
Size of the alpha channel is not set to its default value and this caused totally corrupted graphics on my PC.
See:
https://bugs.scummvm.org/ticket/13712
2022-08-12 00:30:05 +03:00
Le Philousophe
4ab044a254 OPENGL: Merge both OpenGL contexts 2022-06-26 18:32:10 +02:00
Cameron Cawley
a14c5a4a53 SDL: Replace gfx_mode with scale_factor in initSizeHint() 2022-01-16 13:22:37 +02:00
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh
44219dfa1a BACKENDS: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 15:51:59 +02:00
Orgad Shaneh
b11c5ace90 BACKENDS: JANITORIAL: Remove 'virtual' when override is specified 2021-11-14 14:31:41 +02:00
Vanfanel
5873dfad7c SDL: Add missing getFeatureState() case for VSYNC. 2021-10-23 20:53:22 +01:00
Vanfanel
046b48f90d SDL: Add OSystem::kFeatureVSync to SDL surface and OpenGL graphics. 2021-10-23 20:53:22 +01:00
Vanfanel
3a59c28179 SDL: Generalize VSYNC option so it works for 2D games too, in both SDL surface and opengl graphic modes. 2021-10-23 20:53:22 +01:00
Thierry Crozat
594a81f93c OPENGLSDL: Fix restoring window size when exiting fullscreen
When entering fullscreen it was storing the default window size
in the config, which was overwriting the current window size. As
a result when exiting window size, instead of restoring to the
previous window size it was restoring to the default window size.
2021-10-11 02:59:01 +03:00
Thierry Crozat
45a803c71c OPENGLSDL: Fix always restoring window to maximized size when exiting fullscreen
When loadVideoMode gets called to exit fullscreen, the window is
still fullscreen, which means that the SDL_WINDOW_MAXIMIZED is set
(at least on macOS). As a result the window was resized to the
stored maximized window size instead of the size it had before
entering fullscreen.
2021-10-11 02:59:01 +03:00
Thierry Crozat
1962e543fd JANITORIAL: Rename variable to follow code formatting conventions 2021-10-02 21:50:28 +01:00
Thierry Crozat
8d972b338d OPENGLSDL: Properly check for fullscreen state
The OpenGLSDLGraphicsManager was changed in bb15133a0a to use
SDL_WINDOW_FULLSCREEN_DESKTOP instead of SDL_WINDOW_FULLSCREEN.
But getFeatureState(kFeatureFullscreenMode) was still checking
the SDL_WINDOW_FULLSCREEN flag. This worked because in current
SDL2 versions SDL_WINDOW_FULLSCREEN_DESKTOP is defined as
SDL_WINDOW_FULLSCREEN | 0x00001000, but this is not documented
and could change in future SDL versions.
2021-10-02 18:59:44 +01:00
Lothar Serra Mari
d6f105e906 BACKENDS: OPENGLSDL: Only relocate the window to the center of the screen if truly necessary 2021-08-28 10:43:04 +02:00
Lothar Serra Mari
1b42675e52 BACKENDS: OPENGLSDL: Limit window positioning workaround to Win32
It looks like other platforms are not affected by this, at least I
wasn't able to reproduce the issue on Linux in any way.

Since branching off to the next release is very soon and we are running
out of time, I'm limiting this to Win32 in order to avoid unneccessary
breakage by only fixing _really_ affected platforms.
2021-08-28 10:43:04 +02:00
Lothar Serra Mari
4c7bc5effb BACKENDS: OPENGLSDL: Do not try to center window in fullscreen or maximized mode 2021-08-28 10:43:04 +02:00
Lothar Serra Mari
1b6c4f48aa BACKENDS: OPENGLSDL: Forcefully center the window to prevent off-screen rendering 2021-08-28 10:43:04 +02:00
Lothar Serra Mari
cedd57a4ac BACKENDS: OPENGLSDL: Fix wrong check for maximized windows 2021-08-28 10:43:04 +02:00
Lothar Serra Mari
3da65d47cb BACKENDS: OPENGLSDL: Prevent window resizing events in fullscreen mode 2021-08-28 10:43:04 +02:00
Lothar Serra Mari
d07c97f3cd BACKENDS: OPENGLSDL: Remember maximized window state 2021-08-28 10:43:04 +02:00
Thierry Crozat
dc7a09fdd1 SDL: Cleanup HiDPI macOS hacks
The SDL library handles HiDPI differently depending on the system.
On some systems, such as macOS, the drawable area and the SDL window
have a different size (the window is on low-dpi size) while on
other systems such as Windows they have the same size. Because of
that we sometimes need to scale sizes or coordinates between the
two, and sometimes we don't.

This was handled in two different ways. This commit change the code
to handle it consistently everywhere, and also should be more future
proof should SDL change the way it handles HiDPI in the future (as
we now query the size from SDL itself to find out if the scaling is
needed).
2021-08-20 22:10:26 +02:00