Changes between Version 4 and Version 5 of ManualPage

09/27/07 20:32:52 (12 years ago)



  • ManualPage

    v4 v5  
     29Note: You do not have to initialize logging at all. However this helps to determine errors and to debug the engine integration into your application. I would suggest to enable logging during the development of your software (e.g. with level=LL_DEBUG) and to disable it in the release version. 
    2932== How to use Kernel/Task subsystem == 
     34Each game has a main game loop. During the execution of one cycle of the loop a game engine has to perfrom a lot of tasks, e.g. checking user input, rendering, physic update and so on. [[BR]]  
     35nrEngine's Kernel/Task subsystems provides a simple but powerfull interface to manage the main loop. The engine does contains a '''Kernel''' which runs in the background of the engine. A '''Task''' can be bound to the kernel, so that it gets updated every cycle. A task can be any user derived class which has to perform repetitive jobs, e.g. check for user input or stream data from the disk. [[BR]] 
     36Moreover a task can get a specific order number or it can depend on another task. Hence the engine does provide a simple graph based task execution system. The functionality of the nrEngine's kernel is similar to the operatin gsystem kernel, but in a very simple form. [[BR]] 
     37And finally a task can be shifted to a thread, so that it executes in parallel to the main application. 
     39The following code show you how to use the engine's kernel subsystem for a simple managment of tasks in your application/game: 
     41#include <nrEngine/nrEngine.h> 
     43using namespace nrEngine; 
     45//! This is a simpel task performing sound output 
     46class SoundTask :  public ITask 
     50        SoundTask(); 
     51        ~SoundTask(); 
     53        //! This method will be called when the task stops                               
     54        Result stopTask();       
     56        //! Task was added to the kernel, so initilize it 
     57        Result onAddTask(); 
     59        //! This is called every cycle, so that SoundTask can react on it 
     60        Result updateTask(); 
     62        ... 
     65void main() 
     67        // Initialize engine 
     68        ... 
     71        // Add the sound task to the kernel with a low order number 
     72        Engine::sKernel()->AddTask(new SoundTask(), ORDER_LOW); 
     74        // Executes engine's kernel, hence execute all tasks which are in the kernel 
     75        // The function returns if there are no more tasks in the kernel (i.e. if all tasks stops) 
     76        Engine::sKernel()->Execute();