Difference between revisions of "HOWTO-Backends"

Jump to navigation Jump to search
36 bytes added ,  15:18, 25 October 2018
m
Text replacement - "</source>" to "</syntaxhighlight>"
(Added note about testbed)
m (Text replacement - "</source>" to "</syntaxhighlight>")
(One intermediate revision by the same user not shown)
Line 24: Line 24:


==== Example of minimal main() ====
==== Example of minimal main() ====
<source lang="cpp">int main(int argc, char *argv[]) {
<syntaxhighlight lang="cpp">int main(int argc, char *argv[]) {
     g_system = new OSystem_Foobar();
     g_system = new OSystem_Foobar();
     assert(g_system);
     assert(g_system);
Line 32: Line 32:
     g_system->quit();
     g_system->quit();
     return res;
     return res;
}</source>
}</syntaxhighlight>


That's it. The difficult part is of course writing the OSystem subclass. More on that in the next section!
That's it. The difficult part is of course writing the OSystem subclass. More on that in the next section!
Line 52: Line 52:
If you are writing a backend for such a system, you may use code like this:
If you are writing a backend for such a system, you may use code like this:


<source lang="cpp">void updateScreen() {
<syntaxhighlight lang="cpp">void updateScreen() {
     uint32 newTime = getMillis();
     uint32 newTime = getMillis();
     if (newTime - _oldTime < 1000 / MAX_FPS)
     if (newTime - _oldTime < 1000 / MAX_FPS)
Line 60: Line 60:


     // do actual screen update
     // do actual screen update
}</source>
}</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.
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.
TrustedUser
2,147

edits

Navigation menu