Open main menu

Difference between revisions of "HOWTO-Backends"

778 bytes removed ,  21:35, 19 April 2022
no edit summary
(→‎Testing your backend: clarified wording)
Line 38: Line 38:
=== Subclassing OSystem ===
=== Subclassing OSystem ===
TODO: This section is meant to give some specific hints on creating a useful OSystem subclass. For now I can't really think of anything useful besides the obvious, and besides what we already say in other places... Take a look at [https://doxygen.scummvm.org/d2/d38/class_o_system.html OSystem class] which contains lots of useful information. Also take a look at null.cpp to see what you have to implement, and peek at the SDL backend (which is our main backend and thus kind of a reference for all the others). And finally, take a look at <tt>common/system.h</tt> to see which methods are pure abstract, and thus '''must''' be implemented by you. Oh and of course: You can always talk to us on [[IRC Channel|IRC]] or via [[Mailing lists|email]] :-).
TODO: This section is meant to give some specific hints on creating a useful OSystem subclass. For now I can't really think of anything useful besides the obvious, and besides what we already say in other places... Take a look at [https://doxygen.scummvm.org/d2/d38/class_o_system.html OSystem class] which contains lots of useful information. Also take a look at null.cpp to see what you have to implement, and peek at the SDL backend (which is our main backend and thus kind of a reference for all the others). And finally, take a look at <tt>common/system.h</tt> to see which methods are pure abstract, and thus '''must''' be implemented by you. Oh and of course: You can always talk to us on [[IRC Channel|IRC]] or via [[Mailing lists|email]] :-).
=== Implementing subsystems ===
* [[HOWTO-Backends/File system]]
* [[HOWTO-Backends/Mutexes and Timers]]
* [[HOWTO-Backends/Graphics]]
* [[HOWTO-Backends/Events]]
* [[HOWTO-Backends/Audio]]
* [[HOWTO-Backends/Plugins]]
* [[HOWTO-Backends/Miscellaneous]]


==== Testing your backend ====
==== Testing your backend ====
Line 46: Line 55:
=== Misc notes ===
=== Misc notes ===
There is a [[Small Devices Backend]] in the works which is planned to be common for all devices with limited resources. If you are working on a backend for such a system, you may want to take a look on that page!
There is a [[Small Devices Backend]] in the works which is planned to be common for all devices with limited resources. If you are working on a backend for such a system, you may want to take a look on that page!
==== updateScreen() method ====
The updateScreen() method is called by an engine when it finished drawing something on the screen. It may happen quite often, up to several hundred times per second, but some devices have a restriction on how many times per second screen blitting takes place. For example, some NTSC version can not physically update more often than 60 Hz, and attempts to make it more often will result in the machine to hang.
If you are writing a backend for such a system, you may use code like this:
<syntaxhighlight lang="cpp">void updateScreen() {
    uint32 newTime = getMillis();
    if (newTime - _oldTime < 1000 / MAX_FPS)
        return;
    _oldTime = newTime;
    // do actual screen update
}</syntaxhighlight>
That should do the trick for you. This code has the slight disadvantage that it skips some screen updates though. This means there is a possibility that it skips an important screen update, which is not followed by any other screen update for some time, leading to some graphics glitch.
271

edits