green::glutApp Class Reference

#include <glutApp.h>

List of all members.

Public Member Functions

 glutApp ()
int CreateWindow (std::string name, unsigned int displayMode, int width, int height)
virtual void RegisterGLUTCallbacks ()
void SetCurrent (ApplicationPtr app)
virtual void Init ()
virtual void Run ()
int WindowWidth () const
int WindowHeight () const

Static Protected Member Functions

static Application::MouseButton ConvertGLUTButton (int glutButton)
static Application::MouseState ConvertGLUTState (int state)
static void _initialize ()
static void _display ()
 glut display function to be registered with glutDisplayFunc
static void _reshape (int width, int height)
 glut reshape function to be registered with glutReshapeFunc
static void _motion (int x, int y)
 glut motion function to be registered with glutMotionFunc
static void _mouse (int button, int state, int x, int y)
 glut mouse function to be registered with glutMouseFunc
static void _keyboard (unsigned char ch, int x, int y)
 glut keyboard function to be registered with glutKeyboardFunc
static void _keyboard_up (unsigned char ch, int x, int y)
 glut keyboard_up function to be registered with glutKeyboardUpFunc

Protected Attributes

int mWindowID
 The window ID of the glut window for this app.

Static Protected Attributes

static ApplicationPtr currentApp
 pointer to the currently running glutApp
static bool initialized
 true iff _initialize() has been called


Detailed Description

glutApp is a fairly lightweight wrapper around GLUT to make it more object oriented. The way GLUT uses callback functions makes it necessary to use global variables to store game information. glutApp introduces the concept of an Application class, with the same functions as a glut application. Game information is stored as member variables to an Application subclass, rather than global variables. Hidden static member variables and functions are used to bridge GLUT's way of doing things into this way. The static functions are registered as the GLUT callback functions, which pass through to the currently running Application (stored in a hidden static variable in glutApp).


Constructor & Destructor Documentation

green::glutApp::glutApp (  )  [inline]

default constructor, which will initialize glut if it isn't already. You do not need to call glutApp::_initialize() directly (indeed you can't, it is private).


Member Function Documentation

int green::glutApp::CreateWindow ( std::string  name,
unsigned int  displayMode,
int  width,
int  height 
)

create a new window for this glutApp and set it as the current window

Parameters:
name is the title of the window
displayMode is the glut display mode for the window (see man glutInitDisplayMode for a description of this parameter)
width the width of the window
height the height of the window
Returns:
Returns the glut window ID of the window created

void glutApp::RegisterGLUTCallbacks (  )  [virtual]

this function should always be overridden by the subclass each subclass should choose which callbacks to register

void green::glutApp::SetCurrent ( ApplicationPtr  app  )  [inline]

this function sets an Application as the current application

void green::glutApp::Init (  )  [virtual]

Initialize the glutApp

void green::glutApp::Run (  )  [virtual]

this is called to start the GLUT event loop

int green::glutApp::WindowWidth (  )  const

get the width of the current window

int green::glutApp::WindowHeight (  )  const

get the height of the current window

static Application::MouseButton green::glutApp::ConvertGLUTButton ( int  glutButton  )  [inline, static, protected]

Convert GLUT button to Application::MouseButton

Parameters:
glutButton the button sent from GLUT

static Application::MouseState green::glutApp::ConvertGLUTState ( int  state  )  [inline, static, protected]

convert GLUT mouse state to Application::MouseState

void green::glutApp::_initialize (  )  [static, protected]

this function is called once for all instances of glutApp to initialize glut


The documentation for this class was generated from the following files:
Generated on Fri Apr 27 10:27:38 2007 for Green Engine by  doxygen 1.5.1