World of Rigid Bodies (WoRB)
|
GLUT wrapper around a single instance of a GlutApplication template class. More...
#include <Utilities.h>
Public Member Functions | |
GLUT_Framework () | |
~GLUT_Framework () | |
bool | Initialize () |
bool | Initialize (int *argc, char *argv[]) |
void | Terminate () |
void | Connect (GlutApplication &application) |
Connects GLUT event handlers to GlutApplication instance. | |
void | Disconnect () |
Disconect event handlers from the GlutApplication instance. | |
Static Private Member Functions | |
static void | CloseFunc () |
Called when glut closes the application window. | |
static void | DisplayFunc () |
Called each frame to display the scene. | |
static void | MouseFunc (int button, int state, int x, int y) |
Called when a mouse button is pressed. | |
static void | ReshapeFunc (int width, int height) |
Called when the display window changes size. | |
static void | KeyboardFunc (unsigned char key, int, int) |
Called when a key is pressed. | |
static void | SpecialFunc (int key, int, int) |
Called when a special key is pressed. | |
static void | MotionFunc (int x, int y) |
Called when the mouse is dragged. | |
static void | MouseWheelFunc (int wheel, int direction, int x, int y) |
Called when the mouse wheel is spun. | |
Private Attributes | |
bool | Initialized |
Indicates whether glut has been initialized. | |
Static Private Attributes | |
static GlutApplication * | Application = 0 |
Holds an instance of the GlutApplication. |
GLUT wrapper around a single instance of a GlutApplication template class.
GlutApplication should implement event handlers that respond to GLUT callbacks.
Definition at line 477 of file Utilities.h.
WoRB::GLUT_Framework< GlutApplication >::GLUT_Framework | ( | ) | [inline] |
Definition at line 561 of file Utilities.h.
References WoRB::Printf().
: Initialized( false ) { Printf( "WoRB: GLUT_Framework: Constructed\n" ); }
WoRB::GLUT_Framework< GlutApplication >::~GLUT_Framework | ( | ) | [inline] |
Definition at line 567 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Initialized, and WoRB::Printf().
{ Initialized = false; Printf( "WoRB: GLUT_Framework: Destructed\n" ); }
static void WoRB::GLUT_Framework< GlutApplication >::CloseFunc | ( | ) | [inline, static, private] |
Called when glut closes the application window.
Definition at line 489 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->CloseEventHandler (); } }
void WoRB::GLUT_Framework< GlutApplication >::Connect | ( | GlutApplication & | application | ) | [inline] |
Connects GLUT event handlers to GlutApplication instance.
Definition at line 616 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application, WoRB::GLUT_Framework< GlutApplication >::CloseFunc(), WoRB::GLUT_Framework< GlutApplication >::DisplayFunc(), WoRB::GLUT_Framework< GlutApplication >::KeyboardFunc(), WoRB::GLUT_Framework< GlutApplication >::MotionFunc(), WoRB::GLUT_Framework< GlutApplication >::MouseFunc(), WoRB::GLUT_Framework< GlutApplication >::MouseWheelFunc(), WoRB::Printf(), WoRB::GLUT_Framework< GlutApplication >::ReshapeFunc(), and WoRB::GLUT_Framework< GlutApplication >::SpecialFunc().
Referenced by main(), and mexFunction().
{ Printf( "WoRB: GLUT_Framework: Connecting event handlers\n" ); GLUT_Framework::Application = &application; glutCloseFunc( CloseFunc ); glutDisplayFunc( DisplayFunc ); glutReshapeFunc( ReshapeFunc ); glutKeyboardFunc( KeyboardFunc ); glutSpecialFunc( SpecialFunc ); glutMouseFunc( MouseFunc ); glutMotionFunc( MotionFunc ); glutMouseWheelFunc( MouseWheelFunc ); }
void WoRB::GLUT_Framework< GlutApplication >::Disconnect | ( | ) | [inline] |
Disconect event handlers from the GlutApplication instance.
Definition at line 634 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application, and WoRB::Printf().
Referenced by mexFunction(), and WoRB::GLUT_Framework< GlutApplication >::Terminate().
{ Printf( "WoRB: GLUT_Framework: Disconnecting event handlers\n" ); GLUT_Framework::Application = 0; }
static void WoRB::GLUT_Framework< GlutApplication >::DisplayFunc | ( | ) | [inline, static, private] |
Called each frame to display the scene.
Definition at line 498 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->DisplayEventHandler (); } }
bool WoRB::GLUT_Framework< GlutApplication >::Initialize | ( | ) | [inline] |
Definition at line 573 of file Utilities.h.
Referenced by main(), and mexFunction().
{ // We must have proper dummy argument for glutInit() not to crash. int argc = 1; char arg0[] = "WoRB"; char* argv[] = { arg0 }; return Initialize( &argc, argv ); }
bool WoRB::GLUT_Framework< GlutApplication >::Initialize | ( | int * | argc, |
char * | argv[] | ||
) | [inline] |
Definition at line 583 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Initialized, and WoRB::Printf().
{ if ( Initialized ) { return true; } Printf( "WoRB: GLUT_Framework: Calling glutInit...\n" ); // In case of glut >= v2.8.0 #ifdef GLUT_HAS_MULTI glutInitWarningFunc( OnGlutWarning ); glutInitErrorFunc( OnGlutError ); #endif glutInit( argc, argv ); Initialized = glutGet( GLUT_INIT_STATE ) != 0; return Initialized; }
static void WoRB::GLUT_Framework< GlutApplication >::KeyboardFunc | ( | unsigned char | key, |
int | , | ||
int | |||
) | [inline, static, private] |
Called when a key is pressed.
Definition at line 525 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->KeyboardEventHandler( key ); } }
static void WoRB::GLUT_Framework< GlutApplication >::MotionFunc | ( | int | x, |
int | y | ||
) | [inline, static, private] |
Called when the mouse is dragged.
Definition at line 543 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->MotionEventHandler( x, y ); } }
static void WoRB::GLUT_Framework< GlutApplication >::MouseFunc | ( | int | button, |
int | state, | ||
int | x, | ||
int | y | ||
) | [inline, static, private] |
Called when a mouse button is pressed.
Definition at line 507 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->MouseEventHandler( button, state, x, y ); } }
static void WoRB::GLUT_Framework< GlutApplication >::MouseWheelFunc | ( | int | wheel, |
int | direction, | ||
int | x, | ||
int | y | ||
) | [inline, static, private] |
Called when the mouse wheel is spun.
Definition at line 552 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->MouseWheelEventHandler( wheel, direction, x, y ); } }
static void WoRB::GLUT_Framework< GlutApplication >::ReshapeFunc | ( | int | width, |
int | height | ||
) | [inline, static, private] |
Called when the display window changes size.
Definition at line 516 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->ReshapeEventHandler( width, height ); } }
static void WoRB::GLUT_Framework< GlutApplication >::SpecialFunc | ( | int | key, |
int | , | ||
int | |||
) | [inline, static, private] |
Called when a special key is pressed.
Definition at line 534 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Application.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Connect().
{ if ( Application && Application->IsValid () ) { Application->SpecialKeyEventHandler( key ); } }
void WoRB::GLUT_Framework< GlutApplication >::Terminate | ( | ) | [inline] |
Definition at line 604 of file Utilities.h.
References WoRB::GLUT_Framework< GlutApplication >::Disconnect(), WoRB::GLUT_Framework< GlutApplication >::Initialized, and WoRB::Printf().
Referenced by main().
{ Disconnect (); Printf( "WoRB: GLUT_Framework: glutExit...\n" ); // glutExit (); Initialized = false; }
T * WoRB::GLUT_Framework< T >::Application = 0 [static, private] |
Holds an instance of the GlutApplication.
Definition of the static instance wrapper for our GLUT application.
Definition at line 485 of file Utilities.h.
Referenced by WoRB::GLUT_Framework< GlutApplication >::CloseFunc(), WoRB::GLUT_Framework< GlutApplication >::Connect(), WoRB::GLUT_Framework< GlutApplication >::Disconnect(), WoRB::GLUT_Framework< GlutApplication >::DisplayFunc(), WoRB::GLUT_Framework< GlutApplication >::KeyboardFunc(), WoRB::GLUT_Framework< GlutApplication >::MotionFunc(), WoRB::GLUT_Framework< GlutApplication >::MouseFunc(), WoRB::GLUT_Framework< GlutApplication >::MouseWheelFunc(), WoRB::GLUT_Framework< GlutApplication >::ReshapeFunc(), and WoRB::GLUT_Framework< GlutApplication >::SpecialFunc().
bool WoRB::GLUT_Framework< GlutApplication >::Initialized [private] |
Indicates whether glut has been initialized.
Definition at line 481 of file Utilities.h.
Referenced by WoRB::GLUT_Framework< GlutApplication >::Initialize(), WoRB::GLUT_Framework< GlutApplication >::Terminate(), and WoRB::GLUT_Framework< GlutApplication >::~GLUT_Framework().