So, now I have installed crystal space and its python binding. It's time to start learning from the tutorial scripts.
CS comes with 4 tutorial scripts. The first one, tutorial0.py, is the simplest, all it does is opening a window, then quit when you press the ESC key. So, I've decided that the second milestone of my project is to understand how this script works.
So, after about an hour of screwing around with tutorial0.py, I think I understand how it works.
CS has an event driven framework. In other words, it's exactly like Java Swing or any other GUI libraries I've ever used. What this means is that your program basically consists of 2 parts: an initialization part and an event handling part. In the init part, you do all your preparation work such as setting up functions to handle mouse and keyboard events, requesting and registering the plugins and services that you need. Once all the preparation work is done, you just call the function csDefaultRunLoop to start your application and take care of the events as they are generated by the system or the user.
The meat of the first tutorial is in the initialization stage. It starts by creating an iObjectRegistry object to hold all the plugins. The plugins are just services that you can call upon during your game. For example, there is a plugin for doing collision detection, there is another plugin for loading various types of maps or 3D objects from files. Basically, you need to tell CS what services you need before you can use the services .... well duh!
Once the plugins have been requested and registered to the iObjectRegistry object, you have to check them to make sure they are actually there. Once the checking is done, you then need to tell CS which function is going to be handling all the events. This is done through the function: csInitializer.SetupEventHandler. Once the event handling is setup, you just need to actually open the application then start the mainloop. Simple!!