How is an XVR program Organised?

No matter how complex XVR programs get, they are always based on 5 fundamental functions; these are the only predefined functions, and they constitute the bases of any project.

 

OnInit();
    OnFrame();

    OnUpdate();

    OnEvent();

OnExit();

OnInit();

This is the place where to put the initialisation code for the app. All commands are executed sequentially. All the other functions are not active until OnInit() complete its execution.

OnFrame();

This is the place for functions and calls that produce graphics output. This is the only function where the graphics context is visible. Placing graphics command outside this function would produce no results.

OnTimer();

This function runs indipendently by OnFrame and it’s the perfect place where to put commands that must be independent from the rendering task. Also, the timer is hi-res, and you can setup some parameters so that this function can be called up to 1k times per second.

OnEvent();

This function is independend from both OnInit() and OnFrame(); it gets called whenever the application receive an event message. Event messages can be external (i.e. some Windows messages) or internal (i.e. generated anywhere in the XVR program). Events and Messages are supported in XVR cause they add flexibility to the programming environment for task where fixed timers are not the best option. If your app does not need them, you can ignore this function.

OnExit();

This function is called when the app quits or the user closes the page your app is in. If you want to be sure to perform some operations on exit, place your code here.







© 2004 - 2005 Franco Tecchia