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>
|
| | 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) |
| |
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
| GlutWindow::GlutWindow |
( |
const char * |
title, |
|
|
int |
width = 800, |
|
|
int |
height = 800 |
|
) |
| |
| GlutWindow::~GlutWindow |
( |
| ) |
|
|
virtual |
| 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
-
| button | The button that was pressed |
| x | The x location of the cursor when the button was pressed |
| y | The 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
-
| button | The button that was pressed |
| x | The x location of the cursor when the button was pressed |
| y | The 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
-
| x | The x location of the mouse |
| y | The 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
-
| key | The key that was pressed |
| x | The x location of the cursor when the key was pressed |
| y | The 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
-
| key | The key that was pressed |
| x | The x location of the cursor when the key was pressed |
| y | The 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
-
| key | The key that was pressed |
| x | The x location of the cursor when the key was pressed |
| y | The 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
-
| w | Width of the window |
| h | Height of the window |
Implemented in GlutWindow2d.
The program will not return from this function call - it will start rendering the window
| 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 |
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 |
| bool GlutWindow::windowLaunched |
|
protected |
| int GlutWindow::windowWidth |
|
protected |
The documentation for this class was generated from the following files: