|
Patric Stout
|
r28464:897e1f8149ff
|
7 months ago
|
|
Fix: [SDL] remove hint to avoid hardware acceleration ( #11790) This hint was once needed because of the way we handled surfaces. But as OpenGL already uses a hardware surface, we already had to fix all the issues that comes with it. As that is generic code, this hint is no longer actually needed. Further more, recent SDL versions break because of it on Wayland.
|
|
Patric Stout
|
r28457:56b8cae2790d
|
7 months ago
|
|
|
|
Patric Stout
|
r28456:526c217dbaa8
|
7 months ago
|
|
|
|
glx22
|
r27845:2ecc8f63d57a
|
13 months ago
|
|
|
|
glx22
|
r27844:cf08d34d52cb
|
13 months ago
|
|
|
|
Patric Stout
|
r27842:f010c32f7293
|
11 months ago
|
|
Fix: [Emscripten] config not saved on exit game ( #11248) When changing a Game Option and pressing Exit Game, the changes were not actually stored. This because the post-mainloop code was never executed for Emscripten.
|
|
Rubidium
|
r27737:728d55b97775
|
15 months ago
|
|
Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
|
|
Rubidium
|
r27544:ff436bece3b8
|
14 months ago
|
|
|
|
Patric Stout
|
r27487:4d1c2a7bde00
|
14 months ago
|
|
Codechange: remove queue_wrap / last_position from mouse movement
No backend uses it anymore, so also no longer any need to support it.
|
|
Patric Stout
|
r27485:2850a45f8e7f
|
14 months ago
|
|
Fix: [SDL] unify the way X11 and Wayland handle mouse events
Basically, we drop RelativeMode completely, and use the same trick as used by the Windows driver: read all motion events till the last one, and use that as value.
|
|
Henry Wilson
|
r26809:d4ad4016fc34
|
21 months ago
|
|
|
|
Rubidium
|
r26730:4108b8dbfd24
|
19 months ago
|
|
|
|
Niels Martin Hansen
|
r26238:1e3d0e5795b7
|
2 years ago
|
|
|
|
embeddedt
|
r25736:169627858688
|
3 years ago
|
|
|
|
Patric Stout
|
r25724:cf37407a0fa2
|
3 years ago
|
|
Codechange: use _cur_palette the same in all the drivers
It was a bit of a mixed bag. With this change, gfx.cpp is in control who accesses _cur_palette from the video-drivers.
|
|
Rubidium
|
r25707:226494aad20a
|
3 years ago
|
|
|
|
rubidium42
|
r25655:1030dcb7eb52
|
3 years ago
|
|
|
|
sean
|
r25019:7bd7e70574c6
|
3 years ago
|
|
|
|
Patric Stout
|
r25014:e1f1bf3a062e
|
3 years ago
|
|
Add: [Video] move GameLoop into its own thread
This allows drawing to happen while the GameLoop is doing an iteration too.
Sadly, not much drawing currently can be done while the GameLoop is running, as for example PollEvent() or UpdateWindows() can influence the game-state. As such, they first need to acquire a lock on the game-state before they can be called.
Currently, the main advantage is the time spend in Paint(), which for non-OpenGL drivers can be a few milliseconds. For OpenGL this is more like 0.05 milliseconds; in these instances this change doesn't add any benefits for now.
This is an alternative to the former "draw-thread", which moved the drawing in a thread for some OSes. It has similar performance gain as this does, although this implementation allows for more finer control over what suffers when the GameLoop takes too long: drawing or the next GameLoop. For now they both suffer equally.
|
|
Patric Stout
|
r25011:61d28a13bb41
|
3 years ago
|
|
Remove: [Video] no longer draw in a thread
Drawing in a thread is a bit odd, and often leads to surprising issues. For example, OpenGL would only allow it if you move the full context to the thread. Which is not always easily done on all OSes. In general, the advise is to handle system events and drawing from the main thread, and do everything else in other threads. So, let's be more like other games.
Additionally, putting the drawing routine in a thread was only done for a few targets.
Upcoming commit will move the GameLoop in a thread, which will work for all targets.
|
|
Patric Stout
|
r25007:c39f47be967b
|
3 years ago
|
|
Fix #8784: using alt+enter didn't update the fullscreen toggle visibly ( #8820) Basically, the window was not invalidated, so it was never redrawn. This made it look like it wasn't working, but it really was.
|
|
Patric Stout
|
r24970:1ff44d19fa4a
|
3 years ago
|
|
Add: settings to limit your fast-forward game speed
By default this setting is set to 2500% normal game speed.
|
|
Patric Stout
|
r24940:46781aedfe1c
|
3 years ago
|
|
|
|
Patric Stout
|
r24939:f00f6879a003
|
3 years ago
|
|
Codechange: [Video] make the prototype of PollEvent() the same for all drivers
Additionally, call it from the draw-tick.
|
|
Michael Lutz
|
r24918:e55bb9103b0b
|
3 years ago
|
|
|
|
Michael Lutz
|
r24916:2d0cdad1b8b0
|
3 years ago
|
|
|
|
Patric Stout
|
r24915:5a3c224c2b5a
|
3 years ago
|
|
Codechange: [SDL2] Allow several places to hook into the SDL driver
This allows future subdrivers to use these to manage their own flow.
|
|
Patric Stout
|
r24914:bf493787c2f9
|
3 years ago
|
|
Codechange: [SDL2] Move functions and variables to class-scope
This allows future subdrivers to override them.
|
|
Patric Stout
|
r24913:8df991aa7a76
|
3 years ago
|
|
Codechange: [SDL2] Move SDLSurface code to its own function
This increases readability, and allow future subdrivers to not use SDLSurface to draw.
|
|
Patric Stout
|
r24912:d785e8bae96e
|
4 years ago
|
|
Codechange: [SDL2] Split Start() in a few more functions
This makes it a bit easier to follow what is going on, and allow future subdrivers to hook into a few of these functions.
Reworked the code slighly while at it, to return early where possible.
|
|
Michael Lutz
|
r24862:e81146f220fb
|
3 years ago
|
|
|
|
Patric Stout
|
r24855:196c88971d0d
|
3 years ago
|
|
Codechange: deduplicate tick-handlers of all video drivers
They were all identical, so better put this in a single place hoping it is less likely to break.
|
|
Patric Stout
|
r24852:00c1bd78d033
|
3 years ago
|
|
Codechange: be consistent in what CheckPaletteAnim() does and when it is called
Additionally, make sure this is a class method. Later commits will make use of this.
|
|
Patric Stout
|
r24851:a41e925d9dc7
|
3 years ago
|
|
Codechange: be consistent in naming the paint function Paint()
Also move this function to be a class member. This to allow further deduplicating of code in a later commit.
|
|
Patric Stout
|
r24850:df6b081a960b
|
3 years ago
|
|
|
|
Patric Stout
|
r24849:01243a72f255
|
3 years ago
|
|
|
|
Patric Stout
|
r24839:7ca334c34e5a
|
3 years ago
|
|
|
|
Patric Stout
|
r24837:5dde15d396bd
|
3 years ago
|
|
Fix: during switching of game-mode, drawing could show closed windows that shouldn't be closed yet
The higher your refresh-rate, the more likely this is. Mostly you notice this when creating a new game or when abandoning a game.
This is a bit of a hack to keep the old behaviour, as before this patch the game was already freezing your mouse while it was changing game-mode, and it does this too after this patch. Just now it freezes too a few frames earlier, to prevent not drawing windows people still expect to see.
|
|
Patric Stout
|
r24836:1b90bc77ac1d
|
3 years ago
|
|
Feature: configurable refresh-rate and change default to 60fps
Most modern games run on 60 fps, and for good reason. This gives a much smoother experiences.
As some people have monitors that can do 144Hz or even 240Hz, allow people to configure the refresh rate. Of course, the higher you set the value, the more time the game spends on drawing pixels instead of simulating the game, which has an effect on simulation speed.
The simulation will still always run at 33.33 fps, and is not influences by this setting.
|
|
Patric Stout
|
r24835:3784c0862167
|
3 years ago
|
|
Change: sleep till the next tick in the main loop
Sleep for 1ms (which is always (a lot) more than 1ms) is just randomly guessing and hoping you hit your deadline, give or take.
But given we can calculate when our next frame is happening, we can just sleep for that exact amount. As these values are often a bit larger, it is also more likely the OS can schedule us back in close to our requested target. This means it is more likely we hit our deadlines, which makes the FPS a lot more stable.
|
|
Patric Stout
|
r24834:b3e68a97e02c
|
3 years ago
|
|
Change: allow video-drivers to miss deadlines slightly
Before, every next frame was calculated from the current time. If for some reason the current frame was drifting a bit, the next would too, and the next more, etc etc. This meant we rarely hit the targets we would like, like 33.33fps.
Instead, allow video-drivers to drift slightly, and schedule the next frame based on the time the last should have happened. Only if the drift gets too much, that deadlines are missed for longer period of times, schedule the next frame based on the current time.
This makes the FPS a lot smoother, as sleeps aren't as exact as you might think.
|
|
Patric Stout
|
r24833:e40e0f8b2230
|
3 years ago
|
|
Add: draw the screen at a steady pace, also during fast-forward
During fast-forward, the game was drawing as fast as it could. This means that the fast-forward was limited also by how fast we could draw, something that people in general don't expect.
To give an extreme case, if you are fully zoomed out on a busy map, fast-forward would be mostly limited because of the time it takes to draw the screen.
By decoupling the draw-tick and game-tick, we can keep the pace of the draw-tick the same while speeding up the game-tick. To use the extreme case as example again, if you are fully zoomed out now, the screen only redraws 33.33 times per second, fast-forwarding or not. This means fast-forward is much more likely to go at the same speed, no matter what you are looking at.
|
|
Patric Stout
|
r24832:f2376ca1bbb7
|
3 years ago
|
|
Codechange: track _realtime_tick more accurate
_realtime_tick was reset every time the diff was calculated. This means if it would trigger, say, every N.9 milliseconds, it would after two iterations already drift a millisecond. This adds up pretty quick.
|
|
Patric Stout
|
r24831:5af48bd7a880
|
3 years ago
|
|
Codechange: switch all video drivers to std::chrono for keeping time
On all OSes we tested the std::chrono::steady_clock is of a high enough resolution to do millisecond measurements, which is all we need.
By accident, this fixes a Win32 driver bug, where we would never hit our targets, as the resolution of the clock was too low to do accurate millisecond measurements with (it was ~16ms resolution instead).
|
|
Patric Stout
|
r24819:2f929b5518a9
|
3 years ago
|
|
Fix: [SDL2] simplify what to redraw to prevent tearing ( #8685) When there are a lot of rects to redraw, of which one of the last ones is almost the full screen, visual tearing happens over the vertical axis. This is most visible when scrolling the map. This can be prevented by using less rects. To simplify the situation, and as solutions like OpenGL need this anyway, keep a single rect that shows the biggest size that updates everything correctly. Although this means it needs a bit more time redrawing where it is strictly seen not needed, it also means less commands have to be executed in the backend. In the end, this is a trade-off, and from experiments it seems the approach of this commit gives a better result.
|
|
Patric Stout
|
r24815:7aba68f1a12d
|
3 years ago
|
|
Fix 52317bb7: [SDL2] ensure we don't try to blit out of bounds ( #8684) During resizing, there can still be dirty-rects ready to blit based on the old dimensions. X11 with shared memory enabled crashes if you try to do this. So, instead, if we resize, reset the dirty-rects. This is fine, as moments later we mark the whole (new) screen as dirty anyway.
|
|
milek7
|
r24807:48a7f8b46730
|
3 years ago
|
|
|
|
Patric Stout
|
r24745:9b27f6321204
|
3 years ago
|
|
Change: [SDL2] Remove unneeded delay of redrawing the screen
In testing, I could find no reason why this statement is here.
The comment is rather unclear (it states what it does, but not why it would be needed).
This line of code was introduced with f4f40448, which gives no further insight on why it would be needed to have it here.
As such, let's remove it and see if anyone else reports any problems with it. If so, this commit can be reverted and a more clear comment should be added what this line of code is dealing with (the WHY, not the WHAT).
|
|
Patric Stout
|
r24744:6381326705ae
|
3 years ago
|
|
|
|
Patric Stout
|
r24743:6976bb35b8bd
|
3 years ago
|
|
Codechange: [SDL2] Name paint function Paint(), like other drivers do
This reduces confusion when reading different drivers.
|
|
Patric Stout
|
r24742:361ca2c91bfc
|
3 years ago
|
|
Fix 30e69c51: palette was not marked dirty when creating a new
This means the code depended that the caller did this for us before MakePalette() is executed, which is neither a requirement nor a promise the code makes.
|
|
Patric Stout
|
r24728:22025f065dbb
|
3 years ago
|
|
Fix #8029: [SDL2] disable draw-thread on wayland SDL video driver ( #8648) When the wayland SDL video driver is used, an EGL context is created in the main thread. It is not allowed to update this context from another thread, which is exactly what our draw-thread is trying. The other solution would be to move all of SDL into the draw-thread, but that would introduce a whole scala of different problems. The wayland SDL backend is significantly faster than the X11 SDL backend, but there is a performance hit nevertheless.
|
|
SamuXarick
|
r24723:21d4079f2184
|
3 years ago
|
|
Codechange: Apply coding style ( #8640) * Fix: Missing or needed spaces * Codechange: Remove space * Codechange: Remove space * Codechange: More missing spaces * Codechange: Missing spaces * Codechange: Remove space * Codechange: Remove space
|
|
Patric Stout
|
r24715:a20116c90996
|
3 years ago
|
|
Codechange: [SDL2] Use MakeDirty() to force a redraw
The original code is "strictly correct", but just reads really weird, and we use MakeDirty() in several other places instead too.
|
|
Patric Stout
|
r24714:bb51e0c11c9b
|
3 years ago
|
|
Codechange: [SDL2] Rework how palette is updated
It now follows more what the Win32 driver does, and has far less exceptions and special casing.
MakePalette creates the Palette and prepares surface. UpdatePalette updates the Palette. CheckPaletteAnim checks if UpdatePalette needs to be called and marks the whole screen dirty so DrawSurfaceToScreen will do a full redraw.
|
|
Patric Stout
|
r24713:203d26782dac
|
3 years ago
|
|
Fix: [SDL2] Display why SDL_CreateWindow() failed in case it does
All SDL_NNN errors print SDL_GetError, except for this one place.
|
|
Patric Stout
|
r24712:655f7e7d3209
|
3 years ago
|
|
Codechange: [SDL2] Split away CreateMainWindow from CreateMainSurface
This makes the code a bit more readable, as both intentions are more clear, and there is less nesting in the main function.
|
|
Patric Stout
|
r24711:b52ee24b1ce6
|
3 years ago
|
|
|
|
Patric Stout
|
r24710:d33f0b4c7291
|
4 years ago
|
|
|
|
Patric Stout
|
r24709:30621545effd
|
3 years ago
|
|
|
|
Patric Stout
|
r24708:9b4d7c0ea0fc
|
4 years ago
|
|
|
|
Patric Stout
|
r24707:6b517936fbe4
|
4 years ago
|
|
|
|
Patric Stout
|
r24706:81f07894b615
|
4 years ago
|
|
Codechange: [SDL2] reworked FindResolutions to be more like the rest
There was no default resolution fallback, and the code was different from the win32 driver. It is now named the same and much more similar.
|
|
Patric Stout
|
r24705:c418b9015c8d
|
4 years ago
|
|
Codechange: [SDL2] remove include-protection
This is already done by CMake: if SDL2 is not detected, this file is not included.
|
|
Patric Stout
|
r24677:0d72a0938d86
|
4 years ago
|
|
Codechange: [SDL2/Win32] Be consistent how 0bpp blitters are not allowed
Sometimes it returned an usererror(), sometimes Start() failed. Now it always fails on Start(), so nothing else has to check again what blitter is used.
AfterBlitterChange() can never change to a 0bpp, so it is sufficient to guard this with an assert().
|
|
frosch
|
r24670:4ede1ba9cce3
|
4 years ago
|
|
|
|
frosch
|
r24666:516313d51875
|
4 years ago
|
|
|
|
Michael Lutz
|
r24665:20a8caea4459
|
4 years ago
|
|
|
|
Charles Pigott
|
r24597:afde5721a3b6
|
4 years ago
|
|
|
|
Michael Lutz
|
r24524:a57f35a240ed
|
4 years ago
|
|
|
|
Patric Stout
|
r24440:3295012a081c
|
4 years ago
|
|
Add: [Emscripten] use "relative mouse mode" with SDL2
This mode doesn't wrap the mouse constantly, but requests SDL to lock the mouse pointer. This is needed, as with Emscripten you are not allowed to change the mouse poisition (only to lock it into place).
|
|
Patric Stout
|
r24439:3207de2680bf
|
4 years ago
|
|
Add: support for emscripten (play-OpenTTD-in-the-browser)
Emscripten compiles to WASM, which can be loaded via HTML / JavaScript. This allows you to play OpenTTD inside a browser.
Co-authored-by: milek7 <me@milek7.pl>
|
|
Patric Stout
|
r24438:b17f2f305eee
|
4 years ago
|
|
Codechange: unroll the SDL2 main loop
This commit prepares for the next commit, as Emscripten needs to have a way to trigger a single iteration of the main loop. To keep the real changes more clear, this commit only unrolls the loop, and makes no changes to the logic itself.
|
|
nikolas
|
r24265:f3c948df5360
|
4 years ago
|
|
Fix #8104: Always add WINDOW_RESIZABLE flag to SDL2 ( #8211) This fixes a bug that can reproduced with these steps: * Start openttd in fullscreen mode * Turn off fullscreen mode * Try to resize the window. The window can't be resized.
|
|
TechGeekNZ
|
r24236:6391ca82e560
|
4 years ago
|
|
|
|
Michael Lutz
|
r24218:c32caa9f014d
|
4 years ago
|
|
|
|
xdavidwu
|
r24062:1b0ecb18d0d1
|
5 years ago
|
|
Fix: [SDL2] Correct name of the video driver in debug log
SDL_GetVideoDriver(0) returns name of first video driver included in the library, not the driver currently used. SDL_GetCurrentVideoDriver() does what we want here.
|
|
S. D. Cloudt
|
r23917:50c2317ea357
|
5 years ago
|
|
|
|
Jonathan G Rennison
|
r23916:5686b9962962
|
5 years ago
|
|
Fix #7783, Fix #7816: [SDL2] Fix input handling in edit context In particular this fixes handling of the shift key
|
|
Jonathan G Rennison
|
r23913:7dc220f1285f
|
5 years ago
|
|
Change: [SDL2] Add an "unprintable" flag to struct VkMapping
SDL_Keysym::sym is not suitable for checking whether the character is printable or not
|
|
Jonathan G Rennison
|
r23912:87b90132cd91
|
5 years ago
|
|
Fix: [SDL2] Page down key not handled
SDLK_PAGEUP and SDLK_PAGEDOWN are not sequential They must have separate entries in _vk_mapping
|
|
Jonathan G Rennison
|
r23911:1f0b84f2a430
|
5 years ago
|
|
Fix: [SDL2] Detection of backtick scancode
SDL_Keysym::scancode is a SDL_SCANCODE_* constant, not a raw scan code
|
|
Nikolas Nyby
|
r23903:c5cf746b394f
|
5 years ago
|
|
Fix #7784: up/down/home/end key behavior in SDL2 Closes #7784.
|
|
Nikolas Nyby
|
r23882:d683a0787bc9
|
5 years ago
|
|
Codechange: Don't use SDL_CreateRGBSurfaceWithFormat() This function requires libSDL 2.0.5 or higher. It looks like we don't need to use it, and can just use the original SDL_CreateRGBSurface(), with the masks set to 0, to trigger the default 8-bit format, which is SDL_PIXELFORMAT_INDEX8. Closes #7785Note: this code path is activated by using an 8-bit blitter, like: ./bin/openttd -b 8bpp-simple
|
|
nikolas
|
r23833:61ad963f9e87
|
5 years ago
|
|
|