My Project
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
GlutWindow Class Referenceabstract

Basic GlutWindow class that creates a window and initializes everything. It also implements a basic user input motion to move around in the environment. More...

#include <GlutWindow.h>

Inheritance diagram for GlutWindow:
GlutWindow2d ParticlePlot

Public Member Functions

 GlutWindow (const char *title, int width=800, int height=800)
 
virtual ~GlutWindow ()
 
int getWidth () const
 
int getHeight () const
 
int getButton () const
 
virtual void reshape (int w, int h)=0
 
virtual void idle ()
 
virtual void run ()
 
virtual void display ()=0
 
virtual void processNormalKeys (unsigned char key, int x, int y)
 
virtual void processSpecialKeys (int key, int x, int y)
 
virtual void mouse (int button, int state, int x, int y)
 
virtual void mouseMotion (int x, int y)
 
virtual void positionCamera ()
 
void drawText (const char *txt, float x, float y, float r, float g, float b, void *font)
 

Protected Member Functions

void initFunctionPtrs ()
 
virtual void init ()=0
 
double degToRad (const double &angle)
 

Static Protected Member Functions

static void _reshape (int w, int h)
 
static void _idle ()
 
static void _display ()
 
static void _mouse (int button, int state, int x, int y)
 
static void _processNormalKeys (unsigned char key, int x, int y)
 
static void _processSpecialKeys (int key, int x, int y)
 
static void _mouseMotion (int x, int y)
 

Protected Attributes

int windowID
 
char * myTitle
 
int windowHeight
 
int windowWidth
 
int buttonDown
 
int mouseStartX
 
int mouseStartY
 
bool windowLaunched
 

Static Protected Attributes

static GlutWindowmyWindow
 

Detailed Description

Basic GlutWindow class that creates a window and initializes everything. It also implements a basic user input motion to move around in the environment.

Note
: Need to override the draw() function which is called automatically from within display

Constructor & Destructor Documentation

GlutWindow::GlutWindow ( const char *  title,
int  width = 800,
int  height = 800 
)

Basic constructor

GlutWindow::~GlutWindow ( )
virtual

Basic destructor

Member Function Documentation

static void GlutWindow::_display ( )
inlinestaticprotected
static void GlutWindow::_idle ( )
inlinestaticprotected
static void GlutWindow::_mouse ( int  button,
int  state,
int  x,
int  y 
)
inlinestaticprotected
static void GlutWindow::_mouseMotion ( int  x,
int  y 
)
inlinestaticprotected
static void GlutWindow::_processNormalKeys ( unsigned char  key,
int  x,
int  y 
)
inlinestaticprotected
static void GlutWindow::_processSpecialKeys ( int  key,
int  x,
int  y 
)
inlinestaticprotected
static void GlutWindow::_reshape ( int  w,
int  h 
)
inlinestaticprotected

These are static member functions that provide an interface to the glut callbacks. The glut callbacks require static functions.

These functions call the appropriate virtual functions

double GlutWindow::degToRad ( const double &  angle)
inlineprotected
virtual void GlutWindow::display ( )
pure virtual

This will setup the camera and then call draw().

Implemented in GlutWindow2d.

void GlutWindow::drawText ( const char *  txt,
float  x,
float  y,
float  r,
float  g,
float  b,
void *  font 
)

This will draw the given string to the screen at the location given by x,y- (0,0 is the bottom left of the window, 1,1 is the top right). the color defaults to a gray

int GlutWindow::getButton ( ) const
inline

returns the status of the button

int GlutWindow::getHeight ( ) const
inline

This returns the height of the glut window

int GlutWindow::getWidth ( ) const
inline

This returns the width of the glut window

void GlutWindow::idle ( )
virtual

Function that is called when glut is in an "idle state"

virtual void GlutWindow::init ( )
protectedpure virtual

Any initialization specific to any inherited incarnation

Implemented in GlutWindow2d.

void GlutWindow::initFunctionPtrs ( )
protected

Initializes all of the Glut Function pointers

void GlutWindow::mouse ( int  button,
int  state,
int  x,
int  y 
)
virtual

This is used in conjunction with mouseMotion to provide the camera movement.

If you would like to perform other operations with the mouse, override this function, you may want to consider calling Glut_Window::mouse() in that routine to maintain the mouse interface.

Parameters
buttonThe button that was pressed
xThe x location of the cursor when the button was pressed
yThe y location of the cursor when the button was pressed

This is used in conjunction with mouseMotion to provide the camera movement. Moving the mouse with the left button down rotates the camera around a fixed point (specified by viewX, viewY, viewZ). Moving the mouse with the right button down zooms the camera in and out

If you would like to perform other operations with the mouse, override this function, you may want to consider calling Glut_Window::mouse() in that routine to maintain the mouse interface.

Parameters
buttonThe button that was pressed
xThe x location of the cursor when the button was pressed
yThe y location of the cursor when the button was pressed

Reimplemented in GlutWindow2d.

void GlutWindow::mouseMotion ( int  x,
int  y 
)
virtual

This routine is called whenever a mouse movement event has occured. If you are overriding it, consider calling Glut_Window::mouse_motion() in your descendant classes, to maintain the mouse interface

Parameters
xThe x location of the mouse
yThe y location of the mouse

Reimplemented in GlutWindow2d.

void GlutWindow::positionCamera ( )
virtual

Overide this function to change the location from which the scene is rendered. It currently uses information from the mouse and the special keyboard keys to set its direction

Reimplemented in GlutWindow2d.

void GlutWindow::processNormalKeys ( unsigned char  key,
int  x,
int  y 
)
virtual

This function is called when an ascii key is pressed.

Parameters
keyThe key that was pressed
xThe x location of the cursor when the key was pressed
yThe y location of the cursor when the key was pressed

Reimplemented in ParticlePlot, and GlutWindow2d.

void GlutWindow::processSpecialKeys ( int  key,
int  x,
int  y 
)
virtual

This function is used to perform actions when one of the non-ascii keys are presed.

If you would like to perform other options with the special keys, then when overriding this function, you may want to consider calling GlutWindow::processSpecialKeys(key, x, y) in the overridden function to maintain the same base functionality.

Parameters
keyThe key that was pressed
xThe x location of the cursor when the key was pressed
yThe y location of the cursor when the key was pressed

This function is used to perform actions when one of the non-ascii keys are presed. In the base class, the arrow keys are used to move the center of the field of view around in the plane, while PAGE_UP & PAGE_DOWN are used to change the Z value of the center of view.

If you would like to perform other options with the special keys, then when overriding this function, you may want to consider calling GlutWindow::processSpecialKeys(key, x, y) in the overridden function to maintain the same base functionality.

Parameters
keyThe key that was pressed
xThe x location of the cursor when the key was pressed
yThe y location of the cursor when the key was pressed

Reimplemented in GlutWindow2d.

virtual void GlutWindow::reshape ( int  w,
int  h 
)
pure virtual

This performs generic graphics matrix setup operations, and will be called if the user resizes the window

Parameters
wWidth of the window
hHeight of the window

Implemented in GlutWindow2d.

void GlutWindow::run ( )
virtual

The program will not return from this function call - it will start rendering the window

Member Data Documentation

int GlutWindow::buttonDown
protected

Which mouse button is pressed

int GlutWindow::mouseStartX
protected

The x location of the mouse when the button is pressed

int GlutWindow::mouseStartY
protected

The x location of the mouse when the button is pressed

char* GlutWindow::myTitle
protected

Window Title

GlutWindow * GlutWindow::myWindow
staticprotected

A static pointer to the glut window, this is used in the static member functions so that they can call the appropriate class member functions.

int GlutWindow::windowHeight
protected

Window Height

int GlutWindow::windowID
protected

ID of the window

bool GlutWindow::windowLaunched
protected
int GlutWindow::windowWidth
protected

Window Width


The documentation for this class was generated from the following files: