OpenGLPrakt --> cObject --> cWorld
The world class. The interface to OpenGL/GLUT.
Only _one_ cWorld object may be active at once. This object _has_ to be the root of the scene graph.
cWorld
cWorld
~cWorld
Activate
ActivateMenuEntry
AddMenuEntry
AddSubMenu
Animate
AttachMenu
Deactivate
DisableAnimation
Draw
EnableAnimation
GetDefaultName
GetDisplayHeight
GetDisplayWidth
GetWorkingMenu
Init
Init
MoveCameraAndLookatBy
MoveCameraBy
MoveCameraTo
MoveLookAtBy
OrbitCamera
PanCamera
ReceiveEvent
ReshapeDisplay
SceneGraphToMenu
SetAnimationSpeed
SetCamera
SetOrthoProjection
SetPerspectiveProjection
SetWorkingMenu
public cWorld ( cEventDispatcher * disp ,
const char * name = NULL ) ;
default constructor w/ optional name
| name | optional name of object |
public cWorld ( const cWorld & ) ;
copy constructor
public virtual ~ cWorld ( ) ;
destructor
public virtual int Init ( int * argc ,
char * * argv ) ;
initialize world (and OpenGL window using GLUT)
| argc | passed from main |
| argv | passed from main |
public virtual int Init ( int * argc ,
char * * argv ,
unsigned int glut_display_mode ,
int default_width = - 1 ,
int default_height = - 1 ,
int default_pos_x = - 1 ,
int default_pos_y = - 1 ) ;
Initialize world and OpenGL window using GLUT and providing several defaults
If you provide one of default_width or default_height you have to provide the "opposite" as well. The same rule applies to default_pos_x and default_pos_y.
| argc | passed from main |
| argv | passed from main |
| glut_display_mod | use GLUT_xxx constants ORed together to describe the display type you need (e.g. GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE) default: GLUT_RGB | GLUT_DEPTH |
| default_width | default width (-1 = don't care) |
| default_height | default height (-1 = don't care) |
| default_pos_x | default x position of window (-1 = don't care) |
| default_pos_y | default y position of window (-1 = don't care) |
public virtual void ReshapeDisplay ( int width ,
int height ) ;
set new window dimensions
| width | new width of window |
| height | new height of window |
public virtual void Draw ( ) ;
start drawing the whole world (wrapper for Activate())
note: this is called by GLUTDisplayCB, there should be no need to call it from somewhere else!
public virtual void SceneGraphToMenu ( int menu ) ;
make scene graph visible via menu
| menu | id of menu to add scene graph to |
public virtual void SetWorkingMenu ( int id ) ;
set current menu where entries are added to
| id | number of menu to activate |
public virtual int GetWorkingMenu ( ) ;
get current menu where entries are added to
public virtual int AddMenuEntry ( const char * entry ,
const cEvent & event ) ;
add menu entry to actual menu
| entry | text to show as the entry |
| event | event to trigger if menu is selected |
public virtual int AddSubMenu ( const char * name ) ;
add sub menu to actual menu
| name | text to show as sub menu name |
public virtual void AttachMenu ( int button ) ;
attach menu to given mouse button
| button | GLUT_x_BUTTON (x = LEFT|MIDDLE|RIGHT) |
public int SetCamera ( const cVertex & pos ,
const cVertex & lookat ,
const cVertex & up ) ;
set up camera
| pos | camera position |
| lookat | point the camera looks at |
| up | the direction which is "up" from the camera's point of view |
public int MoveCameraTo ( const cVertex & pos ) ;
move camera to a give point without changing LookAt, but probably with changing UpVector
| pos | position to move camera to |
public int MoveCameraBy ( const cVertex & dif ) ;
move camera by a given amount without changing LookAt
| dif | amount to move camera (it is added to camera pos.) |
public void MoveCameraAndLookatBy ( const cVertex & dif ) ;
for "walk" navigation
| dif | amount to move by |
public void PanCamera ( GLfloat x ,
GLfloat y ) ;
for "walk" navigation: look around
| x_angle | angle to turn around x |
| y_angle | angle to turn around y |
public void OrbitCamera ( GLfloat x ,
GLfloat y ) ;
for "orbit navigation": orbit around look-at
| x_angle | angle to turn around x |
| y_angle | angle to turn around y |
public void MoveLookAtBy ( const cVertex & dif ) ;
for "orbit navigation": move orbit center = look-at
| dif | amount to move look-at |
public unsigned int GetDisplayWidth ( ) ;
query width of display
public unsigned int GetDisplayHeight ( ) ;
query height of display
public int SetPerspectiveProjection ( GLdouble fovy ,
GLdouble near ,
GLdouble far ) ;
activate pespective projection
| fovy | field of view angle (degree) in y direction |
| near | coordinate for near clipping plane (>0 !) |
| far | coordinate for far clipping plane (>0 !) |
public int SetOrthoProjection ( GLdouble fovy ,
GLdouble near ,
GLdouble far ) ;
activate orthogonal projection
| fovy | field of view angle (degree) in y direction |
| near | coordinate for near clipping plane (>0 !) |
| far | coordinate for far clipping plane (>0 !) |
public int ActivateMenuEntry ( int id ) ;
trigger event bound to given menu id
this is basically an internal function, but can be called from outside without any risk
| id | menu entry id to activate |
public void EnableAnimation ( ) ;
start animation
public void SetAnimationSpeed ( int speed ) ;
set or change animation speed
| speed | ms per frame (0 - stop animation) |
public void DisableAnimation ( ) ;
stop animation
public virtual int ReceiveEvent ( const cEvent & event ) ;
event receiver
public void Animate ( int value ) ;
broadcast animation event, re-register timer callback if animation still activated
Should not be called by user.
| value | value to send around with animation event (a frame counter) |
protected virtual void Activate ( ) ;
set up for drawing
protected virtual void Deactivate ( ) ;
clean up after drawing the world
protected virtual const char * GetDefaultName ( ) const ;
return name of class (for poor RTTI and as fallback for GetName)
This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.
Click here to return to the top of the page.