summaryrefslogtreecommitdiff
path: root/src/video/video_driver.hpp
AgeCommit message (Collapse)Author
2021-04-12Fix: [Video] fast forward boolean states not initialised, potentially ↵Rubidium
causing unstoppable fast forward
2021-04-11Feature: allow a toggle to enable/disable vsyncPatric Stout
Vsync should be off by default, as for most players it will be better to play without vsync. Exception exist, mainly people who play in fullscreen mode.
2021-03-10Add: make modal windows update more smoothPatric Stout
Basically, modal windows had their own thread-locking for what drawing was possible. This is a bit nonsense now we have a game-thread. And it makes much more sense to do things like NewGRFScan and GenerateWorld in the game-thread, and not in a thread next to the game-thread. This commit changes that: it removes the threads for NewGRFScan and GenerateWorld, and just runs the code in the game-thread. On regular intervals it allows the draw-thread to do a tick, which gives a much smoother look and feel. It does slow down NewGRFScan and GenerateWorld ever so slightly as it spends more time on drawing. But the slowdown is not measureable on my machines (with 700+ NewGRFs / 4kx4k map and a Debug build). Running without a game-thread means NewGRFScan and GenerateWorld are now blocking.
2021-03-09Add: Display refresh rate game option (#8813)sean
2021-03-08Fix: ensure switching blitter happens in the main threadPatric Stout
This because video-drivers might need to make changes to their context, which for most video-drivers has to be done in the same thread as the window was created; main thread in our case.
2021-03-08Add: [Video] move GameLoop into its own threadPatric Stout
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.
2021-03-08Codechange: remove the unused lock around BlitterPatric Stout
2021-03-08Remove: [Video] no longer draw in a threadPatric Stout
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.
2021-03-08Add: Option to (dis-)allow accelerated video drivers. (#8819)Patric Stout
The video drivers using the OpenGL backend are currently our only accelerated drivers. The options defaults to off for macOS builds and to on everywhere else. Co-authored-by: Michael Lutz <michi@icosahedron.de>
2021-02-28Add: settings to limit your fast-forward game speedPatric Stout
By default this setting is set to 2500% normal game speed.
2021-02-27Codechange: remove _realtime_tick variablePatric 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-22Add: [OpenGL] Support for a separate animation buffer that stores the ↵Michael Lutz
palette values of the screen in addition to the colour buffer.
2021-02-22Codechange: Allow video drivers to handle the cursor themselves.Michael Lutz
2021-02-22Add: [OpenGL] Support for 8bpp blitters.Michael Lutz
2021-02-22Change: Lock the video buffer when drawing inside the game loop to properly ↵Michael Lutz
account for threaded drawing.
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: use (Un)LockVideoBuffer() to manage video bufferPatric Stout
2021-02-20Codechange: move all input-handling of video-drivers into InputLoopPatric Stout
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: 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-14Feature: Automatic UI and font zoom levels when supported by the OS.Michael Lutz
2021-01-14Feature: Choose a sensible window size on a fresh OTTD config file. (#8536)Michael Lutz
2020-05-21Codechange: Use std::string in the driver and blitter selection code.Michael Lutz
2019-11-10Cleanup: Removed SVN headersS. D. Cloudt
2019-11-10Codechange: Add EditBoxGainedFocus method to VideoDriver base classJonathan G Rennison
2019-04-18Codechange: use std::vector for _resolutionsglx
2017-03-11(svn r27775) -Fix [FS#6510]: Insufficient thread synchronisation when ↵frosch
switching blitters. (JGR)
2014-04-28(svn r26538) -Codechange: remove double accounting of the driversrubidium
2013-11-25(svn r26108) -Codechange: some coding style (whitespace)rubidium
2013-11-25(svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the ↵rubidium
driver factory instatiations
2013-08-05(svn r25678) -Codechange: Notify the video driver when an edit box lost ↵michi_cc
(global) focus so it can abort any current input composition.
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-08-24(svn r22818) -Fix [FS#4742] (r22796, rlongago): don't spawn threads for ↵rubidium
world generation and NewGRF scanning when using the dedicated or null video driver regardless of the used blitter
2011-05-02(svn r22410) -Document: some more bits ;)rubidium
2010-07-19(svn r20186) -Codechange: remove VARDEF from _realtime_tick and ↵rubidium
_rightclick_emulate
2009-08-21(svn r17248) -Fix: add GPL license notice where appropriaterubidium
2009-01-08(svn r14907) -Codechange: Remove 32 character limit from driver/blitter ↵peter1138
selection and parameters.
2008-06-16(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use ↵smatz
Dimension instead of uint16[2] for resolutions
2008-05-06(svn r12971) -Documentation: add @file in files that missed them and add ↵rubidium
something more than whitespace as description of files that don't have a description.
2008-01-13(svn r11839) -Codechange: move some variables from variables.h to a more ↵rubidium
logical location.
2008-01-01(svn r11734) -Change: Allow ToggleFullScreen to return the result of the ↵belugas
operation' attempt. Previously, only visual clues were available. -Fix[FS#1519]: When you can not use this resolution at full screen, now you'll know that it failed. As for the reason it did not work, each computer/OS has its reason.
2007-07-07(svn r10471) -Codechange: implement driver probing priority so that ↵peter1138
'preferred' drivers are loaded first
2007-07-05(svn r10444) -Codechange: switch to c++ classes and inheritance for ↵peter1138
sound/music/video drivers, using self-registration based on the blitter-model.