summaryrefslogtreecommitdiff
path: root/src/video/allegro_v.cpp
AgeCommit message (Collapse)Author
2021-02-24Codechange: [Video] move InteractiveRandom() to the VideoDriverPatric Stout
2021-02-24Codechange: [Video] make the prototype of PollEvent() the same for all driversPatric Stout
Additionally, call it from the draw-tick.
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-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: move all input-handling of video-drivers into InputLoopPatric 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-14Fix: VkMapping declarations violated C++ ODR rule.milek7
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-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: Use platform independent C++11 function for sleeping on a thread.Michael Lutz
2019-03-19Remove: DOS supportPatric Stout
In 10 years there was no active development on DOS. Although it turned out to still work, the FPS was very bad. There is little interest in the current community to look into this. Further more, we like to switch to c++11 functions for threads, which are not implemented by DJGPP, the only current compiler for DOS. Additionally, DOS is the only platform which does not support networking. It is the reason we have tons of #ifdefs to support disabling networking. By removing DOS support, we can both use c++11 functions for threads, and remove all the code related to disabling network. Sadly, this means we have to see DOS go. Of course, if you feel up for the task, simply revert this commit, and implement stub c++11 functions for threads and stub functions for networking. We are more than happy to accept such Pull Request.
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-04-29Remove: PSP supportPatric Stout
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-04-23(svn r26486) -Codechange: replace a number of snprintfs with seprintfrubidium
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-01-02(svn r26209) -Codechange: remove some template magic and simplify some coderubidium
2013-08-05(svn r25671) -Codechange: Pass character and key code separately to the ↵michi_cc
keyboard handler.
2013-01-08(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by ↵planetmaker
Eagle_rainbow)
2011-12-11(svn r23488) -Fix [FS#4879] (r23241): artefacts when right click mouse ↵rubidium
moving with the allegro video driver
2011-12-08(svn r23448) -Fix: keep a local copy of the palette in the 32bpp animated ↵rubidium
blitter so changes of the palette data during the game don't influence drawing (with SDL)
2011-12-08(svn r23446) -Codechange: move _cur_palette and it's related first/count ↵rubidium
dirty variables into a single structure
2011-11-17(svn r23241) -Codechange: make the decision when to go to the custom drawn ↵rubidium
cursor more prominently during the initialisation of OpenTTD
2011-10-04(svn r22999) -Codechange: Allow changing the blitter during the running game.michi_cc
2011-02-07(svn r22021) -Fix (r22019): ofcourse make doesn't notice files are gone, so ↵rubidium
it doesn't recompile everything that needs to be recompiled...
2010-11-19(svn r21252) -Codechange: introduce a constant for the number of ↵rubidium
milliseconds per game tick and use it
2010-08-01(svn r20286) -Codechange: Unify end of doxygen comments.frosch
2010-08-01(svn r20283) -Codechange: Unify start of doygen comments.frosch
2010-07-19(svn r20192) -Cleanup: bye bye variables.h, bye bye VARDEF... you won't be ↵rubidium
missed :)
2010-05-19(svn r19861) -Fix (r19814): Silence a warning.frosch
2010-05-13(svn r19814) -Codechange: give some more unnamed enums a name, in case they ↵rubidium
consisted of unrelated values use static const (u)int
2010-01-15(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, ↵rubidium
if a header require a header make it include that header
2010-01-04(svn r18709) -Fix (r10227,FS#3464): Animation buffer for 32bpp-anim blitter ↵peter1138
was only validated during sprite blitting, other drawing operations didn't check it. Initial startup and window resize could therefore lead to crash.
2009-12-19(svn r18545) -Fix [FS#3292]: Assign '_screen.dst_ptr' as soon as it is ↵frosch
allocated.
2009-11-09(svn r18031) -Codechange: since basically r7157 adding up 'all' mouse ↵rubidium
movement isn't needed anymore because after each even that movement is handled and the counter is reset. As such simply assigning instead of adding works.
2009-10-17(svn r17787) -Codechange: be a bit more verbose about while allegro failed ↵rubidium
with some actions.
2009-10-15(svn r17776) -Codechange: [SDL] make "update the video card"-process ↵rubidium
asynchronious. Profiling with gprof etc. hasn't shown us that DrawSurfaceToScreen takes a significant amount of CPU; only using TIC/TOC it became apparant that it was a heavy CPU-cycle user or that it was waiting for something. The benefit of making this function asynchronious ranges from 2%-25% (real time) during fast forward on dual core/hyperthreading-enabled CPUs; 8bpp improvements are, in my test cases, significantly smaller than 32bpp improvements. On single core non-hyperthreading-enabled CPUs the extra locking/scheduling costs up to 1% extra realtime in fast forward. You can use -v sdl:no_threads to disable threading and undo this loss. During normal non-fast-forwarded games the benefit/costs are negligable except when the gameloop takes more than about 90% of the time of a tick. Note that allegro's performance does not improve with this system, likely due to their way of getting data to the video card. It is not implemented for the OS X/Windows video backends, unless (ofcourse) SDL is used there. Funny is that the performance of the 32bpp(-anim) blitter is, at least in some test cases, significantly faster (more than 10%) than the 8bpp(-optimized) blitter when looking at real time in fast forward on a dual core CPU; it was slower. The idea comes from a paper/report by Idar Borlaug and Knut Imar Hagen.
2009-10-14(svn r17773) -Cleanup: sdl.h isn't needed for allegrorubidium