Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Main.cpp File Reference

Implements the Bumpmap demonstration. More...

#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <Cg/cg.h>
#include <Cg/cgGL.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include "Const.h"
#include "GLproc.h"
#include "Transformer.h"
#include "TransformerArcBall.h"
#include "TransformerPan.h"
#include "TransformerZoom.h"
#include "Application.h"
#include "Painter.h"
#include "PainterMultipass.h"
#include "PainterMultitexture.h"
#include "PainterPixelShader.h"

Functions

void displayString (int x, int y, const char *message)
 Displays a string at the given coordinates.

void displayStatus ()
 Displays the current status (frames per second).

void displayCallback ()
 Callback function invoked to render the contents of the GLUT window.

void reshapeCallback (int width, int height)
 Callback function invoked when the window is resized.

void mouseCallback (int button, int state, int x, int y)
 Callback function invoked when a mouse button is pressed or released.

void motionCallback (int x, int y)
 Callback function invoked when the mouse is moved while a button is pressed.

void menuCallback (int value)
 Callback function invoked when a menu entry is selected.

void idleCallback ()
 Called when the application is idle.

void initGLUT (int argc, char **argv)
 Initialize GLUT.

void initOpenGL ()
 Initialize OpenGL.

void cgErrorCallback ()
 Callback invoked when a Cg error is encountered.

void initCg (const char *fileName)
 Initialize Cg.

int main (int argc, char **argv)
 The entry point into the application.


Variables

const int K_WINDOW_WIDTH = 640
 Constant representind the default width of the application window.

const int K_WINDOW_HEIGHT = 480
 Constant representind the default height of the application window.

const float K_FRUSTUM_Z_NEAR = 1.0f
 Constant representind the distance from the eye to the 'near' frustum plane.

const float K_FRUSTUM_Z_FAR = 100.0f
 Constant representind the distance from the eye to the 'far' frustum plane.

const float K_FRUSTUM_FOV = 90.0f
 Constant representind the angle of the field of view.

int s_windowWidth
 Dimensions of the application window.

int s_windowHeight
 Dimensions of the application window.

int s_menuHandle
 The menu identifier for the application menu.

const int K_MENU_FLAT = 0
 Identifier for menu entry: draw the scene flat (no bumpmapping).

const int K_MENU_MULTIPASS = 1
 Identifier for menu entry: draw the scene with bumpmaps using multipass.

const int K_MENU_MULTITEXTURE = 2
 Identifier for menu entry: draw the scene with bumpmaps using multitexture.

const int K_MENU_PIXELSHADER = 3
 Identifier for menu entry: draw the scene with bumpmaps using (Cg) pixel shader.

Matrix s_transformationMatrix
 The current transformation matrix for the scene.

CGcontext s_CgContext
 The Cg context in which the pixel shader code executes.

CGprofile s_CgProfile
 The Cg profile in which the pixel shader code executes.

CGprogram s_CgProgram
 The Cg pixel shader program.

Transformers_transformer
 The Transformer which moves the objects on the screen.

Applications_application
 The Application which renders the scene.


Detailed Description

Implements the Bumpmap demonstration.

Author:
Razvan Surdulescu
Version:
1.0
Date:
2/15/2003

Function Documentation

void displayString int    x,
int    y,
const char *    message
 

Displays a string at the given coordinates.

Uses glutBitmapCharacter() to draw the string at the specified coordinates with the font GLUT_BITMAP_HELVETICA_12

void displayStatus  
 

Displays the current status (frames per second).

This function should be called once per frame.

void displayCallback  
 

Callback function invoked to render the contents of the GLUT window.

This function is invoked from motionCallback to render the scene when a new transformation has been defined by the user.

The scene is drawn by calling Application#draw

void reshapeCallback int    width,
int    height
 

Callback function invoked when the window is resized.

This function is invoked when the window first appears on the screen as well as everytime the window is resized.

The function updates the Transformer dimensions and sets up the perspective to use a specified FOV and Z range.

void mouseCallback int    button,
int    state,
int    x,
int    y
 

Callback function invoked when a mouse button is pressed or released.

The function ignores all but the left mouse button events.

If the left mouse button is pressed, the function starts a new transformation on the current Transformer.

If the left mouse button is released, the function sets the transformation matrix on the Application.

Note: in GLUT, the Y coordinate increases from top to bottom (which is backwards from the way OpenGL expects it) so the y coordinate is flipped first.

void motionCallback int    x,
int    y
 

Callback function invoked when the mouse is moved while a button is pressed.

Computes the transformation matrix at the current mouse position by calling Transformer#end.

Note: in GLUT, the Y coordinate increases from top to bottom (which is backwards from the way OpenGL expects it) so the y coordinate is flipped first.

void menuCallback int    value
 

Callback function invoked when a menu entry is selected.

Changes the Painter used by the Application Model based on the user selection.

void idleCallback  
 

Called when the application is idle.

Refreshes the screen (glutPostRedisplay()).

void initGLUT int    argc,
char **    argv
 

Initialize GLUT.

Create the window, menu, and setup the appropriate callbacks.

void initOpenGL  
 

Initialize OpenGL.

Setup the global OpenGL state and initialize the OpenGL extensions via initExtensions

void initCg const char *    fileName
 

Initialize Cg.

Setup the global Cg error callback (cgErrorCallback), create the global Cg context (s_CgContext), setup the Cg profile (s_CgProfile) and load the Cg pixel shader program (s_CgProgram).

int main int    argc,
char **    argv
 

The entry point into the application.

Initialize GLUT, OpenGL, Cg and the Application, then enter the infinite event loop.


Variable Documentation

Matrix s_transformationMatrix [static]
 

The current transformation matrix for the scene.

This matrix is initialized when the user presses the mouse button (to start defining a new transformation) and is updated when the user releases the mouse button (to end the current transformation).


Generated on Sat Mar 22 15:12:06 2003 for Bumpmap by doxygen1.3-rc2