TrustedUser
2,147
edits
(Fix syntax highlighting) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 24: | Line 24: | ||
==== Example of minimal main() ==== | ==== Example of minimal main() ==== | ||
< | <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; | ||
}</ | }</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 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 [http://doxygen.scummvm.org/d9/df4/classOSystem.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 [http://doxygen.scummvm.org/d9/df4/classOSystem.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]] :-). | ||
==== Testing your backend ==== | |||
We have a special game engine, called 'testbed'. Its only purpose is to perform series of tests which help engine authors to see correctness of their implementation. | |||
To run the game, point ScummVM to directory <tt><scummvm sources root>/dists/engine-data/testbed-audiocd-files/</tt> and then run. Follow the on-screen instructions. | |||
=== Misc notes === | === Misc notes === | ||
Line 47: | 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: | ||
< | <syntaxhighlight 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 60: | ||
// do actual screen update | // 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. | 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. |