summaryrefslogtreecommitdiff
path: root/src/video/win32_v.cpp
AgeCommit message (Collapse)Author
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: [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-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-14Fix: VkMapping declarations violated C++ ODR rule.milek7
2021-02-14Add: [Win32] Automatic zoom level suggestion for Win32 video driver.Michael Lutz
The zoom level suggestion is based on the DPI scaling set in Windows. We use 150% scaling as the threshold for 2X zoom and 300% scaling as the threshold for 4X zoom.
2021-01-17Codechange: [SDL2/Win32] Be consistent how 0bpp blitters are not allowedPatric Stout
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().
2021-01-17Codechange: [Win32] Use _local_palette for most operationsPatric Stout
Other drivers do this too, and this makes the world a bit more the same.
2021-01-17Codechange: [Win32] use CSleep() instead of Sleep() like everywhere elsePatric Stout
Functional it is identical. Just helps future-us when searching for sleeps.
2021-01-17Codechange: [Win32] Use return-early in RegisterWndClass()Patric Stout
2021-01-17Codechange: [Win32] Remove Windows 95 specific mouse tracking work-around.Michael Lutz
2021-01-14Feature: Choose a sensible window size on a fresh OTTD config file. (#8536)Michael Lutz
2021-01-08Codechange: Remove min/max functions in favour of STL variants (#8502)Charles Pigott
2020-12-21Doc: some comments for the win32 video driver (#8409)Patric Stout
Co-authored-by: Niels Martin Hansen <nielsm@indvikleren.dk>
2020-05-21Codechange: Use std::string in the driver and blitter selection code.Michael Lutz
2019-11-10Cleanup: Removed SVN headersS. D. Cloudt
2019-04-18Codechange: use std::vector for _resolutionsglx
2019-04-10Codechange: Use null pointer literal instead of the NULL macroHenry Wilson
2019-04-06Codechange: C++11 STL has a function for getting the number of CPU cores.Michael Lutz
2019-04-06Codechange: Replace custom thread code with C++11 thread objects.Michael Lutz
We assume a conforming C++11 compiler environment that has a valid <thread>-header. Failure to run a real thread is handled gracefully.
2019-04-06Codechange: Replace custom mutex code with C++11 mutex'es.Michael Lutz
A conforming compiler with a valid <mutex>-header is expected. Most parts of the code assume that locking a mutex will never fail unexpectedly, which is generally true on all common platforms that don't just pretend to be C++11. The use of condition variables in driver code is checked.
2019-01-17Codechange: Remove unnecessarily defined functions under MinGWCharles Pigott
2019-01-17Fix: A few minor compile warnings under MinGWCharles Pigott
2018-07-19Feature: Framerate display window (#6822)Niels Martin Hansen
Frame rate and various game loop/graphics timing measurements and graphs. Accessible via the Help menu, and can print some stats in the console via the fps command.
2018-06-27Fix: [Win32] Garbage in OS window title if branch name was too long.Michael Lutz
This was caused by a missing \0-character on reaching the buffer limit.
2018-04-29Remove: WinCE supportPatric Stout
2018-04-10Codechange: [Win32] Use OS function for mouse tracking if present.Michael Lutz
2017-12-09(svn r27935) -Fix [FS#6629]: [Win32] Right mouse scrolling didn't work ↵michi_cc
properly with the Windows 10 Fall Creators Update.
2017-08-13(svn r27893) -Codechange: Use fallthrough attribute. (LordAro)frosch
2017-03-11(svn r27775) -Fix [FS#6510]: Insufficient thread synchronisation when ↵frosch
switching blitters. (JGR)
2016-10-30(svn r27673) -Add: [Win32] Thread names for windows debuggers.michi_cc
2015-02-22(svn r27167) -Fix: [SDL, Windows] Right-mouse-button scrolling ↵frosch
scrolled/jumped way to far, when OpenTTD lagged during mouse event processing.
2014-09-30(svn r26943) -Fix: [Win32] Silence a warning about comparison of signed and ↵planetmaker
unsigned variables when using gcc
2014-04-28(svn r26538) -Codechange: remove double accounting of the driversrubidium
2014-04-27(svn r26522) -Add: A config-file-only setting to disable usage of 8bpp video ↵frosch
modes. -Remove: [win32] fullscreen_bpp setting, which is replaced by above setting. -Change: Disable usage of 8bpp blitters and video modes by default. Many modern OS and hardware cause issues with those.
2014-04-23(svn r26482) -Codechange: add an include that allows us to undefine/redefine ↵rubidium
"unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values
2014-02-23(svn r26367) -Fix: [Win32] Use a separate event to indicate that the drawing ↵michi_cc
thread has finished initialising, preventing potential deadlocks.
2014-02-23(svn r26366) -Fix: Protect the windows video driver from concurrent access ↵fonsinchen
(frosch123)
2014-02-23(svn r26365) -Fix [FS#5867]: Don't draw the cursor when its sprite isn't ↵fonsinchen
ready and set _screen.dst_ptr immediately when the buffer changes (frosch123)