Difference between revisions of "HOWTO-Backends"

Jump to navigation Jump to search
No change in size ,  20:14, 4 August 2016
Fix syntax highlighting
(Removed Reference To SVN)
(Fix syntax highlighting)
Line 24: Line 24:


==== Example of minimal main() ====
==== Example of minimal main() ====
<syntax type="C++">int main(int argc, char *argv[]) {
<source 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;
}</syntax>
}</source>


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 47: Line 47:
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:


<syntax type="C++">void updateScreen() {
<source lang="cpp">void updateScreen() {
     uint32 newTime = getMillis();
     uint32 newTime = getMillis();
     if (newTime - _oldTime < 1000 / MAX_FPS)
     if (newTime - _oldTime < 1000 / MAX_FPS)
Line 55: Line 55:


     // do actual screen update
     // do actual screen update
}</syntax>
}</source>


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