Wiki

Clone wiki

sig / A First SIG Application

How does the code look like?

Starting a SIG application is as simple as declaring a viewer and a scene. For example:

#!c++
# include <sig/sn_primitive.h>
# include <sigogl/ws_viewer.h>
# include <sigogl/ws_run.h>

int main ( int argc, char** argv )
{
    WsViewer* v = new WsViewer ( -1, -1, 640, 480, "My First SIG APP" );

    SnPrimitive* p = new SnPrimitive ( GsPrimitive::Capsule, 5.0f, 5.0f, 9.0f );
    p->prim().nfaces = 100;
    p->prim().material.diffuse = GsColor::darkred;

    v->rootg()->add ( p );
    v->cmd ( WsViewer::VCmdAxis );
    v->cmd ( WsViewer::VCmdStatistics );
    v->view_all ();
    v->show ();

    ws_run ();
    return 1;
}
The code above produces:

firstapp-s.png

Starting a Project with SIG

In most applications you will however need to derive the WsViewer class with your own viewer class such that you can properly treat window events like mouse clicks and key presses. You may use the example project in examples/sigapp.7z as a more complete starting point for your projects.

Several additional example programs are available in the distribution package.

Updated