display.cpp File Reference

#include "stdafx.h"

Include dependency graph for display.cpp:

Go to the source code of this file.

Functions

void InitGL (int Width, int Height)
 main OpenGL initialization function
void DrawGLScene (CWorld *ThisWorld)
 main in-game drawing function
void DrawHUD (CWorld *ThisWorld)
 draw the heads-up display
void DrawTiles (CWorld *ThisWorld)
 draw the background tiles
void DrawObjects (CWorld *ThisWorld)
 draw game world objects
void UpdateAnimation (CWorld *ThisWorld)
 main animation routine
void InitStripeAlpha (void)
 utility function to set the drawing stripe to full alpha
void DrawStripe (float top, float bottom, float alpha)
 draw a horizontal stripe on the screen
void DrawBarGraph (float top, float bottom, float left, float right, float fillPercent)
 draws a 2D bar graph on the screen at a specified level
void InitTextures ()
 load textres from disk
GLuint GetTexture (int texID)
 return the texture handle associated with a texture ID
GLuint GetFrame (int animID, int frame)
 gets the OpenGL texture ID associated with a particular frame of animation
int GetTotalFrames (int animID)
 returns the total number of frames contained in an animation
CAnimationGetAnimation (int animID)
 returns a pointer to an animation object, given it's animation ID
GLuint LoadTextureRAW (const char *filename, int wrap)
 load a texture from disk
int checkSize (int x)
unsigned char * getRGBA (FILE *s, int size)
unsigned char * getRGB (FILE *s, int size)
unsigned char * getGray (FILE *s, int size)
char * getData (FILE *s, int sz, int iBits)
int returnError (FILE *s, int error)
GLuint LoadTextureTGA (const char *filename, int wrap)
 loads a targa image
void DrawCircle (float radius)
 draw a circle on the screen
void DrawDisc (float radius)
 draw a disc on the screen
void DrawStar (float radius)
 draw a 'star' on the screen

Variables

GLuint textures [256]
CAnimationanimations [256]
static float stripeAlpha
GLenum texFormat


Function Documentation

int checkSize ( int  x  ) 

Definition at line 699 of file display.cpp.

Referenced by LoadTextureTGA().

Here is the caller graph for this function:

void DrawBarGraph ( float  top,
float  bottom,
float  left,
float  right,
float  fillPercent 
)

This function draws horizontal a 2D bar graph on the screen, allowing the screen position and dimensions to be specified, along with a value representing the percentage of the bar graph to be drawn 'filled'.

Definition at line 478 of file display.cpp.

Referenced by DrawHUD().

Here is the caller graph for this function:

void DrawCircle ( float  radius  ) 

Used for various effects, including the 'Shock Wave' effect.

Definition at line 880 of file display.cpp.

References DegreesToRadians().

Referenced by Shockwave::Draw(), and MiniShock::Draw().

Here is the call graph for this function:

Here is the caller graph for this function:

void DrawDisc ( float  radius  ) 

Used for various effects, including the 'Shock Wave' and 'Mini Shock' effects.

Definition at line 894 of file display.cpp.

References DegreesToRadians().

Referenced by Shockwave::Draw().

Here is the call graph for this function:

Here is the caller graph for this function:

void DrawGLScene ( CWorld ThisWorld  ) 

This function draws the in-game graphics. It draws the base tile-map, the world objects, and the special effects.

Definition at line 61 of file display.cpp.

References CWorld::DrawEffects(), DrawHUD(), DrawObjects(), DrawTiles(), CWorld::fFinalZoom, CWorld::fZoomBias, CObject::iHealth, CWorld::iStartingState, Vector::Magnitude(), CWorld::Player, PLAYFIELD_SIZE, CObject::Position, Vector::Reverse(), STARTINGSTATE_GO, STARTINGSTATE_IDLE, STARTINGSTATE_READY, STARTINGSTATE_RUN, STARTINGSTATE_SET, STARTINGSTATE_VICTORY, Vector::x, and Vector::y.

Referenced by PlayGame().

Here is the call graph for this function:

Here is the caller graph for this function:

void DrawHUD ( CWorld ThisWorld  ) 

Draw the heads-up information display to the screen. This includes game status information such as the players' health (bar graph), the players' current weapon and remaining ammunition, etc.

Definition at line 153 of file display.cpp.

References DrawBarGraph(), GetTexture(), CObject::iHealth, CObject::iWeapon, CWorld::Player, PLAYFIELD_SIZE, TEXID_POWERUP_BS, TEXID_POWERUP_HS, TEXID_POWERUP_LM, TEXID_POWERUP_PS, TEXID_POWERUP_SB, TEXID_TANK, WEAPONID_BOUNCY_SHOT, WEAPONID_HEAT_SEEKER, WEAPONID_LAND_MINE, WEAPONID_NULL, WEAPONID_PEA_SHOT, and WEAPONID_SUPER_BULLET.

Referenced by DrawGLScene().

Here is the call graph for this function:

Here is the caller graph for this function:

void DrawObjects ( CWorld ThisWorld  ) 

Draw all game world objects to the screen. This includes players, powerups, blocks, and walls. This will also draw 'dead' objects that haven't been removed from the world.

Definition at line 365 of file display.cpp.

References CObject::bVisible, CObject::Draw(), CObject::Next, and CWorld::Objects.

Referenced by DrawGLScene().

Here is the call graph for this function:

Here is the caller graph for this function:

void DrawStar ( float  radius  ) 

Used for various effects, including the 'Shock Wave' effect.

Definition at line 908 of file display.cpp.

References DegreesToRadians().

Referenced by Shockwave::Draw().

Here is the call graph for this function:

Here is the caller graph for this function:

void DrawStripe ( float  top,
float  bottom,
float  alpha 
)

Draw a text accentuation stripe to help text stand out when written to the screen. the strip will fade in alpha over time. Use InitStripeAlpha() to reset the stripe's opacity after updating it's position on the screen.

Definition at line 450 of file display.cpp.

References stripeAlpha.

Referenced by PlayGame().

Here is the caller graph for this function:

void DrawTiles ( CWorld ThisWorld  ) 

Draw the background tiles to the screen. This function uses a tile based method to render the backgound, one tile at a time, pulling data from the current world's tile map data array.

Definition at line 333 of file display.cpp.

References CELL_SIZE, CTile::iTexture, MAP_SIZE, textures, TILEMAP_DISTANCE, and CWorld::tiles.

Referenced by DrawGLScene().

Here is the caller graph for this function:

CAnimation* GetAnimation ( int  animID  ) 

Definition at line 635 of file display.cpp.

References animations.

Referenced by TileAnim::Draw(), and TileAnim::Step().

Here is the caller graph for this function:

char* getData ( FILE *  s,
int  sz,
int  iBits 
)

Definition at line 797 of file display.cpp.

References getGray(), getRGB(), and getRGBA().

Referenced by LoadTextureTGA().

Here is the call graph for this function:

Here is the caller graph for this function:

GLuint GetFrame ( int  animID,
int  frame 
)

Definition at line 623 of file display.cpp.

References animations, and CAnimation::ipFrameTex.

Referenced by TileAnim::Draw(), and CObject::Draw().

Here is the caller graph for this function:

unsigned char* getGray ( FILE *  s,
int  size 
)

Definition at line 774 of file display.cpp.

References texFormat.

Referenced by getData().

Here is the caller graph for this function:

unsigned char* getRGB ( FILE *  s,
int  size 
)

Definition at line 741 of file display.cpp.

References texFormat.

Referenced by getData().

Here is the caller graph for this function:

unsigned char* getRGBA ( FILE *  s,
int  size 
)

Definition at line 709 of file display.cpp.

References texFormat.

Referenced by getData().

Here is the caller graph for this function:

GLuint GetTexture ( int  texID  ) 

Look up the OpenGL texture handle, given the texture ID associated with it.

Definition at line 617 of file display.cpp.

References textures.

Referenced by TileStorm::Draw(), CObject::Draw(), DrawHUD(), and DrawMenuBackground().

Here is the caller graph for this function:

int GetTotalFrames ( int  animID  ) 

Definition at line 629 of file display.cpp.

References animations, and CAnimation::iTotalFrames.

void InitGL ( int  Width,
int  Height 
)

Sets all of the required OpenGL parameters to the game's defaults. Also sets up the viewing matrix.

Definition at line 36 of file display.cpp.

Referenced by main(), and ToggleFullScreen().

Here is the caller graph for this function:

void InitStripeAlpha ( void   ) 

Definition at line 437 of file display.cpp.

References stripeAlpha.

Referenced by PlayGame().

Here is the caller graph for this function:

void InitTextures (  ) 

Load all textures from disk and associate them with entries in the texture ID array.

Definition at line 500 of file display.cpp.

References animations, ANIMID_BROWN_HOP_IN, ANIMID_BROWNTANKEXPLODE, ANIMID_CRATECRUSH, ANIMID_EXPLOSION, ANIMID_GREEN_HOP_IN, ANIMID_GREENTANKEXPLODE, ANIMID_TANKROLL, CAnimation::ipFrameTex, LoadTextureTGA(), TEXID_BOUNCY_SHOT, TEXID_CRATE, TEXID_DIRT, TEXID_EZRAS_HEAD, TEXID_GRASS, TEXID_HEAT_SEEKER, TEXID_ICE, TEXID_LAND_MINE, TEXID_LAVA, TEXID_MENUBACK, TEXID_MUD, TEXID_PEA_SHOT, TEXID_POWERUP_BS, TEXID_POWERUP_HEALTH, TEXID_POWERUP_HS, TEXID_POWERUP_LM, TEXID_POWERUP_PS, TEXID_POWERUP_SB, TEXID_SAND, TEXID_SUPER_BULLET, TEXID_TANK, TEXID_TARMAC, TEXID_TNT_BLOCK, TEXID_WALL_BLOCK, TEXID_WATER, and textures.

Referenced by main(), and ToggleFullScreen().

Here is the call graph for this function:

Here is the caller graph for this function:

GLuint LoadTextureRAW ( const char *  filename,
int  wrap 
)

Load a 256x256 RGB/8 .RAW file as a texture, and return a handle to it.

Definition at line 645 of file display.cpp.

GLuint LoadTextureTGA ( const char *  filename,
int  wrap 
)

Loads a targa (.tga) image file from disk. Supported types are 8, 24 and 32 bit uncompressed images.

Definition at line 820 of file display.cpp.

References checkSize(), getData(), returnError(), TGA_BAD_BITS, TGA_BAD_DATA, TGA_BAD_DIMENSION, TGA_BAD_IMAGE_TYPE, and TGA_FILE_NOT_FOUND.

Referenced by InitTextures().

Here is the call graph for this function:

Here is the caller graph for this function:

int returnError ( FILE *  s,
int  error 
)

Definition at line 808 of file display.cpp.

Referenced by LoadTextureTGA().

Here is the caller graph for this function:

void UpdateAnimation ( CWorld ThisWorld  ) 

Update the animation frames of all the objects in the game world that are currently animating. The routine will update each object's frame using an independent delay variable, referenced to the current world's time.

Definition at line 393 of file display.cpp.

References ANIM_CYCLE_CYCLE, ANIM_CYCLE_ONESHOT, animations, CObject::bAnimating, CObject::bAnimCycle, CObject::iAnimTimeStamp, CObject::iCurrentFrame, CWorld::iCurrentTime, CObject::iNormalAnim, CObject::iNormalAnimSpeed, CAnimation::iTotalFrames, CObject::Next, and CWorld::Objects.

Referenced by PlayGame().

Here is the caller graph for this function:


Variable Documentation

CAnimation* animations[256]

Definition at line 27 of file display.cpp.

Referenced by GetAnimation(), GetFrame(), GetTotalFrames(), InitTextures(), and UpdateAnimation().

float stripeAlpha [static]

Definition at line 28 of file display.cpp.

Referenced by DrawStripe(), and InitStripeAlpha().

GLenum texFormat

Definition at line 697 of file display.cpp.

Referenced by getGray(), getRGB(), and getRGBA().

GLuint textures[256]

Definition at line 26 of file display.cpp.

Referenced by DrawTiles(), GetTexture(), and InitTextures().

 

Copyright Windsor Schmidt 2006 - All rights reserved.