Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

GlutWindow Class Reference
[GLUT Master]

GLUT window base class. More...

#include <window.h>

Inheritance diagram for GlutWindow:

Inheritance graph
[legend]
Collaboration diagram for GlutWindow:

Collaboration graph
[legend]
List of all members.

Public Types

enum  MenuCallbacks { , MENU_CAPTURE_RGB, MENU_CAPTURE_STENCIL, MENU_CAPTURE_ZBUFFER }
 GlutWindow menu callback messages. More...


Public Methods

 GlutWindow (const std::string &title=titleDefault, const int width=widthDefault, const int height=heightDefault, const int x=xDefault, const int y=yDefault, const unsigned int displayMode=displayModeDefault)
 Constructor.

virtual ~GlutWindow ()
 Destructor.

virtual void OnOpen ()
 Handler for window open event(s).

virtual void OnClose ()
 Handler for window close event(s).

virtual void OnDisplay ()
 Handler for window draw events.

virtual void OnTick ()
 Handler for tick events, if enabled.

virtual void OnIdle ()
 Handler for idle events, if enabled.

virtual void OnTimer (unsigned char val)
 Handler for timer events.

virtual void OnKeyboard (unsigned char key, int x, int y)
 Handler for keyboard events.

virtual void OnKeyboardUp (unsigned char key, int x, int y)
 Handler for keyboard-up events.

virtual void OnSpecial (int key, int x, int y)
 Handler for special keyboard events (function keys, etc).

virtual void OnSpecialUp (int key, int x, int y)
 Handler for special keyboard-up events.

virtual void OnMouse (int button, int state, int x, int y)
 Handler for mouse button events.

virtual void OnMotion (int x, int y)
 Handler for mouse movement events.

virtual void OnPassiveMotion (int x, int y)
 Handler for passive mouse motion events (no button pressed).

virtual void OnEntry (int state)
 Handler for mouse entry/leave events.

virtual void OnMenu (int value)
 Handler for menu events.

virtual void OnReshape (int w, int h)
 Handler for window reshape events.

virtual void OnVisibility (int visible)
 Handler for window visibility events.

void open ()
 Open the window.

void grab (const GlutWindow &window)
 Grab an existing GLUT window.

void close ()
 Close the window.

void position (int x, int y)
 Position the window.

void reshape (int width, int height)
 Reshape (resize) the window.

void setCursor (int cursor)
 Set window cursor.

void enterGameMode ()
 Enter fullscreen game mode.

void leaveGameMode ()
 Leave fullscreen game mode.

void toggleGameMode ()
 Toggle fullscreen game mode.

void postRedisplay ()
 Trigger a redraw.

void setTimer (unsigned int msecs, unsigned char val)
 Configure a timer event to occur after an elapsed time period.

void setTick (unsigned int msec)
 Configure draw events to occur at a given frequency.

void setIdle (bool idle)
 Window will receive OnIdle() events, continuously.

void setSwapBuffers (const bool swap)
 Configure whether front and back buffers should be swapped after each redraw.

bool captureRGB (const std::string &filename)
 Capture OpenGL RGB Buffer.

bool captureZBuffer (const std::string &filename)
 Capture OpenGL Z Buffer.

bool captureStencil (const std::string &filename)
 Capture OpenGL Stencil Buffer.

bool getOpen () const
 Is the window currently open?

bool getIdle () const
 Is the window receiving idle events?

unsigned int getTick () const
 Get the window tick interval.

bool getSwapBuffers () const
 Is the window performing buffer swapping?

int getX () const
 Get X position of window.

int getY () const
 Get Y position of window.

int getWidth () const
 Get width of window.

int getHeight () const
 Get height of window.

int getBufferSize () const
 Get the number of color buffer bits.

int getStencilSize () const
 Get the number of stencil buffer bits.

int getDepthSize () const
 Get the number of z-buffer bits.

int getRedSize () const
 Get the number of red bits.

int getGreenSize () const
 Get the number of green bits.

int getBlueSize () const
 Get the number of blue bits.

int getAlphaSize () const
 Get the number of alpha bits.

int getAccumRedSize () const
 Get the number of red accumulation buffer bits.

int getAccumGreenSize () const
 Get the number of green accumulation buffer bits.

int getAccumBlueSize () const
 Get the number of blue accumulation buffer bits.

int getAccumAlphaSize () const
 Get the number of alpha accumulation buffer bits.

bool getDoubleBuffer () const
 Is the window double buffered?

bool getRGBA () const
 Is the window in RGBA mode?

bool getStereo () const
 Is the window in stereo mode?

bool getTopLevel () const
 Is this a top-level window?

int getNumChildren () const
 Get number of child windows (not counting children of children).

int getColormapSize () const
 Get size of color index map.

int getNumSamples () const
 Get number of samples for multisampling.

int getCursor () const
 Get current cursor.

bool getShiftModifier () const
 Is the shift key pressed?

bool getCtrlModifier () const
 Is the control key pressed?

bool getAltModifier () const
 Is the alt key pressed?


Protected Methods

virtual void OnPreDisplay ()
 Handler for pre-display event.

virtual void OnPostDisplay ()
 Handler for post-display event.

virtual void OnPreTimer (unsigned char val)
 Handler for pre-timer event.

int & windowID ()
 GLUT window ID.

const int & windowID () const
 GLUT window ID.

std::string nextFilename ()
 Increment file index and determine filename.


Protected Attributes

GltViewport _viewport
 Current OpenGL viewport region.

GlutMenu _leftButtonMenu
 Pop-up menu for left mouse button.

GlutMenu _rightButtonMenu
 Pop-up menu for right mouse button.

bool _swapBuffers
 Automatic window buffer swapping mode.

int _fileIndex
 Current file index.


Static Protected Attributes

const unsigned char _tickVal = 255
 Reserved ID for window-tick timer events.


Detailed Description

GLUT window base class.

Author:
Nigel Stewart (nigels.com@gmail.com)

Definition at line 61 of file window.h.


Constructor & Destructor Documentation

GlutWindow::GlutWindow const std::string &    title = titleDefault,
const int    width = widthDefault,
const int    height = heightDefault,
const int    x = xDefault,
const int    y = yDefault,
const unsigned int    displayMode = displayModeDefault
 

Constructor.

Parameters:
title  Window title text
width  Window width
height  Window height
x  Window x Position
y  Window y Position
displayMode  OpenGL display mode
Display mode can be a combination of
GLUT_RGB True color RGB mode
GLUT_RGBA True color RGBA mode
GLUT_ALPHA Alpha color buffer component
GLUT_INDEX Indexed color mode
GLUT_SINGLE Single buffered
GLUT_DOUBLE Double buffered
GLUT_DEPTH Depth buffer
GLUT_STENCIL Stencil buffer
GLUT_ACCUM Accumulation buffer
GLUT_STEREO Stereo mode

Definition at line 18 of file window.cpp.

References _swapBuffers.


Member Function Documentation

void GlutWindow::OnOpen   [virtual]
 

Handler for window open event(s).

Note:
Implement your own OpenGL initialisation here

Reimplemented in GlutWindowExaminer.

Definition at line 279 of file window.cpp.

Referenced by GlutWindowExaminer::OnOpen().

void GlutWindow::OnClose   [virtual]
 

Handler for window close event(s).

Note:
Implement your own OpenGL shutdown/cleanup here

Reimplemented in GlutWindowExaminer.

Definition at line 280 of file window.cpp.

Referenced by GlutWindowExaminer::OnClose().

void GlutWindow::OnDisplay   [virtual]
 

Handler for window draw events.

Note:
Implement your own OpenGL drawing here

Definition at line 231 of file window.cpp.

Referenced by captureRGB(), captureStencil(), and captureZBuffer().

void GlutWindow::OnTick   [virtual]
 

Handler for tick events, if enabled.

Note:
This is gentler on CPU load than the idle callback

Definition at line 241 of file window.cpp.

References postRedisplay().

Referenced by OnPreTimer().

void GlutWindow::OnIdle   [virtual]
 

Handler for idle events, if enabled.

Note:
Use of idle tends to be a CPU hog

Definition at line 246 of file window.cpp.

References postRedisplay().

void GlutWindow::OnTimer unsigned char    val [virtual]
 

Handler for timer events.

Note:
Queue timer events via GlutWindow::setTimer()

Definition at line 267 of file window.cpp.

void GlutWindow::OnEntry int    state [virtual]
 

Handler for mouse entry/leave events.

The state callback parameter is either GLUT_LEFT or GLUT_ENTERED depending on if the mouse pointer has last left or entered the window.

Note:
Some window systems may not generate accurate enter/leave callbacks.

Definition at line 285 of file window.cpp.

void GlutWindow::open  
 

Open the window.

Note:
Window will receive OnOpen() event
Window opens automatically, but can be re-opened after close()

Definition at line 53 of file window.cpp.

void GlutWindow::grab const GlutWindow &    window
 

Grab an existing GLUT window.

Note:
Old GlutWindow will receive OnClose() event
New GlutWindow will receive OnOpen() event

Definition at line 66 of file window.cpp.

References _windowID.

void GlutWindow::close  
 

Close the window.

Note:
Window will receive OnClose() event

Definition at line 59 of file window.cpp.

Referenced by GlutWindowExaminer::OnKeyboard(), OnKeyboard(), and OnMenu().

void GlutWindow::position int    x,
int    y
 

Position the window.

Note:
Window will receive OnReshape() event

Definition at line 114 of file window.cpp.

Referenced by leaveGameMode().

void GlutWindow::reshape int    width,
int    height
 

Reshape (resize) the window.

Note:
Window will receive OnReshape() event

Definition at line 120 of file window.cpp.

Referenced by leaveGameMode().

void GlutWindow::setCursor int    cursor
 

Set window cursor.

Parameters:
cursor  Cursor type
Cursor may be one of
GLUT_CURSOR_RIGHT_ARROW Arrow pointing up and to the right.
GLUT_CURSOR_LEFT_ARROW Arrow pointing up and to the left.
GLUT_CURSOR_INFO Pointing hand.
GLUT_CURSOR_DESTROY Skull & cross bones.
GLUT_CURSOR_HELP Question mark.
GLUT_CURSOR_CYCLE Arrows rotating in a circle.
GLUT_CURSOR_SPRAY Spray can.
GLUT_CURSOR_WAIT Wrist watch.
GLUT_CURSOR_TEXT Insertion point cursor for text.
GLUT_CURSOR_CROSSHAIR Simple cross-hair.
GLUT_CURSOR_UP_DOWN Bi-directional pointing up & down.
GLUT_CURSOR_LEFT_RIGHT Bi-directional pointing left & right.
GLUT_CURSOR_TOP_SIDE Arrow pointing to top side.
GLUT_CURSOR_BOTTOM_SIDE Arrow pointing to bottom side.
GLUT_CURSOR_LEFT_SIDE Arrow pointing to left side.
GLUT_CURSOR_RIGHT_SIDE Arrow pointing to right side.
GLUT_CURSOR_TOP_LEFT_CORNER Arrow pointing to top-left corner.
GLUT_CURSOR_TOP_RIGHT_CORNER Arrow pointing to top-right corner.
GLUT_CURSOR_BOTTOM_RIGHT_CORNER Arrow pointing to bottom-left corner.
GLUT_CURSOR_BOTTOM_LEFT_CORNER Arrow pointing to bottom-right corner.
GLUT_CURSOR_FULL_CROSSHAIR Full-screen cross-hair cursor (if possible, otherwise GLUT_CURSOR_CROSSHAIR).
GLUT_CURSOR_NONE Invisible cursor.
GLUT_CURSOR_INHERIT Use parent's cursor.

setCursor()
changes the cursor image of the current window. Each call requests the window system change the cursor appropriately. The cursor image when a window is created is GLUT_CURSOR_INHERIT. The exact cursor images used are implementation dependent. The intent is for the image to convey the meaning of the cursor name. For a top-level window, GLUT_CURSOR_INHERIT uses the default window system cursor.

Definition at line 126 of file window.cpp.

Referenced by GlutWindowExaminer::OnMotion(), and GlutWindowExaminer::OnMouse().

void GlutWindow::enterGameMode  
 

Enter fullscreen game mode.

Note:
Window will occupy the whole screen, but will not change display mode.

Definition at line 79 of file window.cpp.

Referenced by toggleGameMode().

void GlutWindow::leaveGameMode  
 

Leave fullscreen game mode.

Note:
Window will receive OnReshape() event

Definition at line 94 of file window.cpp.

References position(), and reshape().

Referenced by toggleGameMode().

void GlutWindow::toggleGameMode  
 

Toggle fullscreen game mode.

Note:
Window will receive OnReshape() event

Definition at line 105 of file window.cpp.

References enterGameMode(), and leaveGameMode().

Referenced by OnKeyboard().

void GlutWindow::postRedisplay  
 

Trigger a redraw.

Note:
Window will receive OnDraw() event

Definition at line 150 of file window.cpp.

Referenced by OnIdle(), GlutWindowExaminer::OnKeyboard(), GlutWindowExaminer::OnMotion(), OnReshape(), GlutWindowExaminer::OnSpecial(), and OnTick().

void GlutWindow::setTimer unsigned int    msecs,
unsigned char    val
 

Configure a timer event to occur after an elapsed time period.

Note:
Window will receive OnTimer() event

Definition at line 132 of file window.cpp.

References uint32.

void GlutWindow::setTick unsigned int    msec
 

Configure draw events to occur at a given frequency.

Parameters:
msec  Time between draw events in milli seconds, zero to disable
Note:
Window will receive OnDraw() events

Definition at line 138 of file window.cpp.

void GlutWindow::setIdle bool    idle
 

Window will receive OnIdle() events, continuously.

Warning:
This tends to hog the CPU

Definition at line 144 of file window.cpp.

Referenced by GlutWindowExaminer::OnMouse().

void GlutWindow::setSwapBuffers const bool    swap
 

Configure whether front and back buffers should be swapped after each redraw.

Note:
Will be enabled by default if double buffering is enabled.

Definition at line 164 of file window.cpp.

References _swapBuffers.


The documentation for this class was generated from the following files:
Generated on Tue Nov 5 11:11:48 2002 for GLT by doxygen1.2.18