[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 4.19.1 Quick Start

In order to startup and use AWS2, the following tasks must be performed.

1. Initialize the Crystal Space facilities in the normal fashion. (see section Simple Tutorial 1: Basic Setup, World Creation). In particular, `csInitializer::OpenApplication()` must be invoked before any of the following tasks are performed. Initializing an AWS2 application also involves loading the AWS2 plugin. You can do this via the normal `csInitializer::RequestPlugins()` invocation (the common approach), or you can load it separately, if desired:

       csRef<iAws2> aws = csLoadPlugin<iAws2> (plugin_mgr,
         "crystalspace.window.alternatemanager2");

   If you know ahead of time that your application will be using AWS2, then loading the plugin via `csInitializer::OpenApplication()` is more convenient and less error-prone.

2. Setup the AWS2 canvas.

       awsCanvas = aws->SetupCanvas (0, myG2D, myG3D);

   Where `myG2D` and `myG3D` are your `iGraphics2D` and `iGraphics3D` cavas objects, respectively.

3. Load Javascript files

       aws->Load("/partedit2/startup.js");

   Substitute the VFS path of your own definition file in place of the path shown in the example.

4. You will also want to make sure that AWS2 gets events. So in your HandleEvent function you will want to put something like this:

       return aws->HandleEvent(Event);

5. Finally, you have to make sure it actually renders to the display. So, in your program's main drawing loop you might use code similar to this:

       // Start drawing 2D graphics.
       if (!myG3D->BeginDraw (CSDRAW_2DGRAPHICS))
         return;
       // Make sure invalidated areas get a chance to
       // redraw themselves.
       aws->Redraw ();

That's all there is to it. AWS2 is designed to be easy to use. Of course, this brief examination does not illustrate how to get user input from components in the windows, nor does it illustrate how to do anything other than display any widgets that your Javascript files have setup.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.