summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2021-02-22Codechange: [Win32] Move the global video buffer pointer into the driver class.Michael Lutz
2021-02-22Codechange: [OpenGL] Only update the dirty parts of the video buffer texture.Michael Lutz
2021-02-22Codechange: [OpenGL] Enable driver debug messages if supported.Michael Lutz
2021-02-22Codechange: [OpenGL] Use new-style extension testing introduced with OpenGL 3.0.Michael Lutz
2021-02-22Add: [Win32] Video driver that uses OpenGL to transfer the video buffer to ↵Michael Lutz
the screen.
2021-02-22Codechange: [Win32] Move common initialization and finalization to the video ↵Michael Lutz
driver base class.
2021-02-22Codechange: [Win32] Move GDI-specific variables and related functions into ↵Michael Lutz
the GDI video driver class.
2021-02-22Codechange: [Win32] Move GDI specific drawing code into the GDI video driver ↵Michael Lutz
class.
2021-02-22Codechange: [Win32] Split the video driver into a base class and a GDI ↵Michael Lutz
backend class.
2021-02-22Fix #6319: [Win32] don't use clipping; draw whole screen every frame (#8726)Patric Stout
When we clip the region that is only been redrawn, something weird happens on Windows. When pushing 60 frames per second on a 60Hz monitor, it appears that the clipped region is often shown of another frame, instead of the current. Examples of this are: - pause the game, move your mouse to the left, and at the right speed it totally disappears. - fast aircrafts seem to be in several places at once, weirdly lagging behind. - in title screen, moving your mouse gives you the idea it is jumping places, instead of smooth movements. In the end, if you do nothing, everything is correct, so it is eventually consistent. Just when we are firing many BitBlt in a clipped region, the in-between is not. What goes wrong exactly, I honestly do not know. On every frame that we push to the DC is a mouse painted, but visually it sometimes appears like it is not. Recording with external software shows it really is there. It is also not our eyes playing tricks on us, as the first example makes it really clear the mouse pointer really is not painted. And to be clear, with the mouse this is easiest reproduceable, as high-speed objects are influences by this most. But this happens for all movement that redraws small regions. Either way, not using clipped regions resolves the issue completely, and there appears to be little to no penalty (I failed to measure any impact of drawing the full screen). So better have a good game than fast code, I guess?
2021-02-22Update: Translations from eintstranslators
english (us): 78 changes by 2TallTyler polish: 1 change by yazalo
2021-02-22Fix #8724: Got wrong DepotID/StationID for airports, causing crashCharles Pigott
2021-02-22Change: Make pathfinder account for maximum order speed, if setCharles Pigott
2021-02-21Update: Translations from eintstranslators
estonian: 19 changes by siimsoni french: 3 changes by glx22
2021-02-21Fix #8276: Crash when a NewGRF object's size was not setCharles Pigott
2021-02-21Fix #8349: Close depot vehicle list windows when closing the depot windowCharles Pigott
2021-02-21Codechange: [OSX] remove final bits of old debugging code (#8714)Patric Stout
2021-02-21Fix: [YAPF] Road pathfinder did not account for length of tunnel/bridge in ↵Charles Pigott
path cost Copy calculations from the rail pathfinder
2021-02-21Fix #8594: [NRT] Road pathfinder did not account for roadtype speed limitsCharles Pigott
2021-02-20Fix ec1dd0bf: missing override causing compiler warnings (#8708)Patric Stout
2021-02-20Codechange: Use C++-ism for zeroing.Michael Lutz
2021-02-20Fix: [OSX] Don't wait on the event loop for drawing.Michael Lutz
2021-02-20Codechange: [OSX] Only keep a total dirty rect for drawing.Michael Lutz
When drawing an 8bpp screen buffer, palette resolving was done for each dirty rectangle. In areas with high activity, this would mean a pixel might have been resolved multiple times. Also, if too many individual updates were queued, the whole screen would be refreshed, even if unnecessary. All other drivers only keep one overall dirty rect, so do it here as well.
2021-02-20Update: Translations from eintstranslators
estonian: 62 changes by siimsoni korean: 1 change by telk5093 russian: 2 changes by Ln-Wolf finnish: 2 changes by hpiirai
2021-02-20Codechange: rename sound ids to make more sense. (#8701)frosch
2021-02-20Codechange: Apply coding styleSamuXarick
2021-02-20Remove: [SDL] SDL 1.3 never happened, so remove all the special code for itPatric Stout
2021-02-20Codechange: deduplicate tick-handlers of all video driversPatric Stout
They were all identical, so better put this in a single place hoping it is less likely to break.
2021-02-20Change: [Win32] Remove force_full_redraw and display_hz settingsPatric Stout
These were special settings only for the win32-drivers, and introduced in the very first version we track. Time kinda had caught up with those variables, so it is time to say farewell. force_full_redraw was most likely a debug functionality "in case our dirty-rect fails". This should no longer be needed. display_hz was cute, as it had a max of 120. That is kinda out-dated information, but I also doubt anyone was really using this.
2021-02-20Codechange: [Win32] simplify when/where GdiFlush() is calledPatric Stout
2021-02-20Codechange: be consistent in what CheckPaletteAnim() does and when it is calledPatric Stout
Additionally, make sure this is a class method. Later commits will make use of this.
2021-02-20Codechange: be consistent in naming the paint function Paint()Patric Stout
Also move this function to be a class member. This to allow further deduplicating of code in a later commit.
2021-02-20Codechange: use (Un)LockVideoBuffer() to manage video bufferPatric Stout
2021-02-20Codechange: move all input-handling of video-drivers into InputLoopPatric Stout
2021-02-20Codechange: [Win32] make fast-forward check the same as with other driversPatric Stout
It was of all the drivers the only one doing this slightly different. When trying to unify more code, that was rather annoying.
2021-02-20Fix: [Cygwin] Fix missing uint definitionJoe Stringer
In file included from src/settingsgen/../string_func.h:30, from src/settingsgen/settingsgen.cpp:11: src/settingsgen/../core/bitmath_func.hpp:34:15: error: 'uint' does not name a type; did you mean 'uint8'? 34 | static inline uint GB(const T x, const uint8 s, const uint8 n) | ^~~~ | uint8
2021-02-20Fix: [Win32] run InteractiveRandom() once every tick, not once every messagePatric Stout
Win32 was the only video driver doing this. It is just a bit too much random.
2021-02-20Fix: [Win32] now we are drawing on a tick, no longer use WM_PAINTPatric Stout
WM_PAINT hits when-ever Windows feels like, but always after we marked the screen as dirty. In result, it was lagging behind, giving a sub-60fps experience. With the new draw-tick there is no longer a need to be driven by WM_PAINT, so it is better anyway to drive the drawing ourself. As an added bonus this makes the win32 driver more like the others.
2021-02-19Update: Translations from eintstranslators
german: 1 change by Wuzzy2 russian: 11 changes by Ln-Wolf catalan: 2 changes by J0anJosep spanish: 14 changes by perezdidac
2021-02-19Fix d437445c: also use std::chrono for the GRFFileScanner modal windowPatric Stout
For some reason I only converted one of the two modal windows we have, and completely forgot the other. While at it, synchronize the way those two modal windows work in terms of "next_update".
2021-02-19Fix fa170b9: [SDL2] forgot to use GetGameInterval where neededPatric Stout
2021-02-19Fix cd4f0f95: [Allegro] driver failed to build because of missing includePatric Stout
2021-02-19Fix: during switching of game-mode, drawing could show closed windows that ↵Patric Stout
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.
2021-02-19Feature: configurable refresh-rate and change default to 60fpsPatric Stout
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.
2021-02-19Change: sleep till the next tick in the main loopPatric Stout
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.
2021-02-19Change: allow video-drivers to miss deadlines slightlyPatric Stout
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.
2021-02-19Add: draw the screen at a steady pace, also during fast-forwardPatric Stout
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.
2021-02-19Codechange: track _realtime_tick more accuratePatric Stout
_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.
2021-02-19Codechange: switch all video drivers to std::chrono for keeping timePatric Stout
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).
2021-02-19Codechange: use std::chrono to track time in modal windowsPatric Stout
Adding to _realtime_ticks in a random place is a bit of a hack, and by using modern C++, we can avoid this hack.