Propane Namespace Reference

The top-level namespace for everything in Propane Injector. More...


Classes

class  Camera
 Basic GL camera class that uses quaternions for internal rotation. More...
class  TextureRenderTarget
 An interface enabling render-to-texture using FBO and/or glCopyTexImage depending on hardware extensions. More...
class  FBOTextureRenderTarget
 An implementation of the TextureRenderTarget that uses FBO (Frame Buffer Objects). Thanks to Rob. More...
class  TextureRectangleFBOTextureRenderTarget
 A version of the FBO texture render target that doesn't *have* to have npow2 support (for older cards such as GeForce FX 5200). Instead it uses ARB_texture_rectangle. More...
class  CopyTextureRenderTarget
 An implementation of the TextureRenderTarget that uses glCopyTexSubImage2D and the like; this is intended for hardware that does not support FBO. It is dramatically slower and uglier. More...
class  Log
 A singleton for maintaining HTML logs. More...
struct  _BitmapChar
 A structure containing the representation of an individual character. More...
class  Font
 A class for rendering AngelCode bitmap fonts. More...
struct  Coordinate
 Basic coordinate unit. More...
class  RefCounter
 Wrapper class that handles reference counts, and deletes unused items. More...
class  SharedPtr
 A smart pointer, similar to boost::shared_ptr. More...
class  Singleton
 Singleton base type. NOT thread safe. More...

Namespaces

namespace  Exception
 Exceptions that Propane Injector may throw.
namespace  Game2D
 Game engine oriented methods and classes for a 2D game.
namespace  Image
 Routines and classes that handle image files and image data (textures).
namespace  Input
 The namespace that is primarily concerned with obtaining input from external input devices, such as joysticks, brain implants and other fun devices.
namespace  Map
 3D/2D "map" data that's used to represent game levels.
namespace  Material
 Stateful changes to the OpenGL pipeline that alter the appearance of vertices rendered after their application.
namespace  Math
 Classes and methods that provide helpful math functionality.
namespace  Shader
 Functions and classes that have to do with GLSL support in Propane Injector.

Functions

TextureRenderTargetgetNewTextureRenderTarget (int w, int h)
 Obtains the specific TextureRenderTarget for your hardware. A factory method that will automatically return a new render target, appropriate for the current hardware.
int initGL (int screenW, int screenH)
 Obtain a SDL context, then use this to initialize a 2D OpenGL context.
int initGL3D (int screenW, int screenH, float fov=75.0f)
 Obtain a SDL context, then use this to initialize a 3D OpenGL context.
Propane::Coordinate project (float x, float y, float z)
 Projects a screen coordinate into OpenGL space based on the current matrices.
Propane::Coordinate unproject (float x, float y, float z=0.0f)
 Projects a OpenGL coordinate to screen space based on the current matrices.
int initSDL (int screenW, int screenH, bool fullscreen=false)
 Use this to obtain a SDL context. Returns < 0 on failure.
int initMixer (int rate, int channels)
 Use this method to initialize the sound driver. Must use before MusicManager.
int setWindowTitle (char *buf)
 Set the title of the window holding the SDL context.
int getMonth ()
 Returns the current month.
int getYear ()
 Returns the current year.
int getDay ()
 Returns the current day.
int getMinute ()
 Returns the current minute [0..59].
int getHour ()
 Returns the current hour [0..23].
std::string getMODFileTitle (const std::string &filename)
 Get the 20-byte title from a MOD file.
void flip ()
 Flip the backbuffer to the display. Equivalent to D3D Present.
bool hasExtension (char *extensionname)
 Check for the presence of a named OpenGL extension. Must initialize OpenGL before executing this.
char * getExtensions ()
 Returns a large string containing the extensions supported on this video card. Must initialize OpenGL before using this.
void delay (int ms)
 Delay this thread for a given number of milliseconds. Use this in your inner loop to prevent your game from taking up 100% CPU usage.
float getNewDelta (bool noOverDeltaCheck=false)
 Get the delta time value for this frame, and do some light logic. Set the argument to TRUE to eliminate framerate capping (to avoid "warping" on slow PCs).
long getFPS ()
 Return the FPS (Updated by Propane::getNewDelta).
long getTicks ()
 Return the number of ticks since program initialization (1 tick = 1 ms).
void clearScreen ()
 Wipe the screen and replace it with the glClearColor.
void takeScreenshot (char *filename, int screen_width, int screen_height)
 Save a picture of the screen to a given file name.
float getFOVForResolution (int width, int height)
 Gets the ideal horizontal FOV for a given resolution.
void * getProcedureAddress (const std::string &proc)
 Gets an address for a function from GL.
void internalGLErrorCheck (const std::string &file, int line, const std::string &message)
 Test for a GL error.
template<class T>
std::string toString (T &o)
 Cast any object type to a STL string as long as ostringstream supports it.
std::vector< std::string > tokenizeString (const std::string &str, const std::string &delimiters)
int getMonth ()
 Returns the current month.
int getDay ()
 Returns the current day.
int getYear ()
 Returns the current year.
int getMinute ()
 Returns the current minute [0..59].
int getHour ()
 Returns the current hour [0..23].


Detailed Description

The top-level namespace for everything in Propane Injector.

Function Documentation

void Propane::clearScreen  ) 
 

Wipe the screen and replace it with the glClearColor.

Tell OpenGL to clear the depth and colour buffers.

This does NOT clear the stencil buffer.

Examples:
ShaderUse.cpp.

void Propane::delay int  ms  ) 
 

Delay this thread for a given number of milliseconds. Use this in your inner loop to prevent your game from taking up 100% CPU usage.

Tells SDL to sleep the current thread for a given number of milliseconds. SDL will probably sleep for *at least* 20ms no matter what you provide.

Parameters:
ms The number of milliseconds to sleep the thread for. See SDL docs for more.
Examples:
ShaderUse.cpp.

void Propane::flip  ) 
 

Flip the backbuffer to the display. Equivalent to D3D Present.

Tell SDL to swap the OpenGL backbuffer, incrementing global frame count

Examples:
ShaderUse.cpp.

int Propane::getDay  ) 
 

Returns the current day.

Get the current day number (0 to 30)

Returns:
The current month number (0 to 30, inclusive)

int Propane::getDay  ) 
 

Returns the current day.

Get the current day number (0 to 30)

Returns:
The current month number (0 to 30, inclusive)

char * Propane::getExtensions  ) 
 

Returns a large string containing the extensions supported on this video card. Must initialize OpenGL before using this.

Returns a string listing all of the OpenGL extensions, space delimited

Returns:
A string of all the OpenGL extensions, space delimited

float Propane::getFOVForResolution int  width,
int  height
 

Gets the ideal horizontal FOV for a given resolution.

Returns a FOV value for gluPerspective that is useful for our needs based on the screen resolution; for example, 16:10 displays will require a wider FOV than a 4:3 screen.

It even supports portrait displays.

Parameters:
width The width of the OpenGL window, in pixels.
height The height of the OpenGL window, in pixels.
Returns:
The FOV (Field of View) in degrees. 90 for 4:3, 110 for 16:10, and somewhere in between for others.

long Propane::getFPS  ) 
 

Return the FPS (Updated by Propane::getNewDelta).

Get the FPS from the internal counter. Call getNewDelta to update your FPS counter

Returns:
The count of frames per second

int Propane::getHour  ) 
 

Returns the current hour [0..23].

Get the current hour (0 to 23)

Returns:
The current hour (0 to 23, inclusive)

int Propane::getHour  ) 
 

Returns the current hour [0..23].

Get the current hour (0 to 23)

Returns:
The current hour (0 to 23, inclusive)

int Propane::getMinute  ) 
 

Returns the current minute [0..59].

Get the current minute (0 to 59)

Returns:
The current minute (0 to 59, inclusive)

int Propane::getMinute  ) 
 

Returns the current minute [0..59].

Get the current minute (0 to 59)

Returns:
The current minute (0 to 59, inclusive)

int Propane::getMonth  ) 
 

Returns the current month.

Get the current month number (1 to 12)

Returns:
The current month number (1 to 12, inclusive)

int Propane::getMonth  ) 
 

Returns the current month.

Get the current month number (1 to 12)

Returns:
The current month number (1 to 12, inclusive)

float Propane::getNewDelta bool  disableOver = false  ) 
 

Get the delta time value for this frame, and do some light logic. Set the argument to TRUE to eliminate framerate capping (to avoid "warping" on slow PCs).

Performs delta time calculations, and returns the delta from the previous frame. Updates the FPS counter and frame counters, as well as the internal delta variables _PI_OldDelta and _PI_OldStart.

This function should be called each frame.

By default, this function will clamp the delta to 0.150f if it is too big; this is so that if your player has a slow computer things will not make enormous jumps (potentially through walls). To disable this behaviour, pass TRUE to disableOver.

Parameters:
disableOver Set this to true if you do NOT want to clamp the delta to 0.150f
Returns:
The number of seconds it's been since the last call to getNewDelta
Examples:
ShaderUse.cpp.

TextureRenderTarget* Propane::getNewTextureRenderTarget int  w,
int  h
[inline]
 

Obtains the specific TextureRenderTarget for your hardware. A factory method that will automatically return a new render target, appropriate for the current hardware.

As of this release it supports three targets:

  • FBO Texture Render Target (ideal): You have OpenGL 2.0, GL_EXT_framebuffer_object and GL_ARB_texture_non_power_of_two.
  • Texture Rectangle FBO Texture Render Target (med): You have OpenGL >= 1.5, GL_EXT_framebuffer_object, but no npow2 support, but you have GL_ARB_texture_rectangle.
  • Copy Texture Render Target (worst): You have any version of OpenGL supported by PI, and no particular extensions. However, you are rendering to a pow2 texture and so will use more memory and will be slower than FBO support.

Parameters:
w The width of the texture you are rendering to, in pixels.
h The height of the texture you are rendering to, in pixels.
Returns:
A pointer to the new render target, or NULL if there is no render target for your hardware.
Examples:
useRenderTarget.cpp.

void * Propane::getProcedureAddress const std::string &  proc  ) 
 

Gets an address for a function from GL.

Returns the address of a given procedure using SDL's GL support. Useful if you're on Windows and need the address of, well, any procedure made in the last 10 years.

Generally used to get the function pointers to OpenGL extensions, though you might also need to use this if you are loading the GL library at runtime using something like SDL_GL_LoadLibrary.

Parameters:
proc The procedure name (e.g. "glActiveTextureARB")
Returns:
The procedure address, or NULL if it was not found. See the SDL docs for more.

long Propane::getTicks  ) 
 

Return the number of ticks since program initialization (1 tick = 1 ms).

Get the number of 'ticks' (milliseconds) since program initialization.

Returns:
The number of ticks since the call to Propane::initSDL

int Propane::getYear  ) 
 

Returns the current year.

Get the current year in 4-digit form (1900 to ????)

Returns:
The current year (1900 to ????)

int Propane::getYear  ) 
 

Returns the current year.

Get the current year in 4-digit form (1900 to ????)

Returns:
The current year (1900 to ????)

bool Propane::hasExtension char *  ext  ) 
 

Check for the presence of a named OpenGL extension. Must initialize OpenGL before executing this.

Checks if OpenGL supports the given extension name, using Propane::getExtensions

Parameters:
ext The OpenGL extension name to check for (e.g. ARB_multitexture)
Returns:
True if the extension is present, false otherwise

int Propane::initGL int  width,
int  height
 

Obtain a SDL context, then use this to initialize a 2D OpenGL context.

Initialize a 2D (orthogonal) OpenGL context with the given width and height for viewport. Uses gluOrtho2D. Automatically enables: textures, smooth shading model, blending, nicest perspective correction, LEQUAL depth function, 1.0f clear depth, black clear colour, SDL style coordinate system (y positive = down)

Parameters:
width The viewport width, in pixels
height The viewport height, in pixels
Returns:
-1 on error, 0 otherwise.

int Propane::initGL3D int  width,
int  height,
float  fov = 75.0f
 

Obtain a SDL context, then use this to initialize a 3D OpenGL context.

Initializes a 3D (perspective) OpenGL context, with a given width, height and Field of View (fov) Defines the perspective with the field of view, default ratio of width:height, NEARPLANE and FARPLANE clipping planes, smooth shading model, no lighting, LEQUAL depth function, textures, blending, nicest perspective correction, light gray clear colour.

Parameters:
width The width of the viewport, in pixels
height The height of the viewport, in pixels
fov The Field of View (in degrees) for gluPerspective to use. Consider using Propane::getFOVForResolution to get this.
Returns:
-1 on error, 0 otherwise.

int Propane::initMixer int  rate,
int  channels
 

Use this method to initialize the sound driver. Must use before MusicManager.

Initializes SDL_mixer. Starts with AUDIO_S16SYS, 1024 buffer size.

Parameters:
rate The audio rate for SDL to use (22050 is good enough)
channels The number of channels for SDL to use
Returns:
-1 if error, 0 otherwise. Will dump an error to stderr.

int Propane::initSDL int  screenwidth,
int  screenheight,
bool  fullscreen = false
 

Use this to obtain a SDL context. Returns < 0 on failure.

Initializes SDL. You must do this before initializing OpenGL, always.

Sets SDL_OPENGL, SDL_ANYFORMAT, SDL_GL_DOUBLEBUFFER, enables Unicode and sets the window caption to "Propane Injector" by default. Initializes SDL_INIT_EVERYTHING.

Parameters:
screenwidth The width of the window you wish to create, in pixels
screenheight The height of the window you wish to create, in pixels
fullscreen Set this to true to make the window fullscreen and cause a resolution change (beware!)
Returns:
-1 if there was an error, 0 otherwise.

Coordinate Propane::project float  x,
float  y,
float  z
 

Projects a screen coordinate into OpenGL space based on the current matrices.

Use gluProject to turn a world coordinate into a screen coordinate. Useful for reverse picking (such as target indicators, etc)

Parameters:
x The x-coordinate, in world units
y The y-coordinate, in world units
z The z-coordinate, in world units
Returns:
The 2D coordinate of the point, in screen space. This is dependent upon the modelview/projection matrices active at the time of this method being called -- consult the documentation for gluProject for more information

int Propane::setWindowTitle char *  buf  ) 
 

Set the title of the window holding the SDL context.

Use SDL to set the window title for your application. Does not support setting icons.

Parameters:
buf The title of the window to use (for example, "Ravuya's Amazing Game")
Returns:
-1 if there was an error, 0 otherwise.

void Propane::takeScreenshot char *  filename,
int  scrWidth,
int  scrHeight
 

Save a picture of the screen to a given file name.

Save a BMP screenshot of the current window contents to filename, with the given width and height of the viewport.

Endian-independent.

Parameters:
filename The file-name to save the BMP to (e.g. "sshot.bmp")
scrWidth The width of the viewport, from top left. If this is smaller than the width of the window, it will just take that part of the window. In pixels.
scrHeight The height of the viewport, from top left. If this is smaller than the width of the window, it will just take that part of the window. In pixels.

std::vector< std::string > Propane::tokenizeString const std::string &  str,
const std::string &  delimiters = " "
 

Splits a string into many tokens depending on delimiters.

For example, handing "key=value hello xyz" to the machine with the delimeters "= " will produce ["key", "value", "hello", "xyz"]

Parameters:
str The string to tokenize
delimiters The list of characters to tokenize by, same as strtok
Returns:
A STL vector of non-blank substring tokens.

Coordinate Propane::unproject float  x,
float  y,
float  z = 0.0f
 

Projects a OpenGL coordinate to screen space based on the current matrices.

Uses gluUnProject to turn a screen coordinate into a world coordinate. Useful for picking.

Parameters:
x The x-coordinate, in screen space
y The y-coordinate, in screen space
z The z-coordinate, in screen space. This is generally used to reject picking stuff that's "too close" to the screen.
Returns:
The 3D coordinate, in world space, of the object you "hit". This is dependent upon the current values of the projection/modelview matrices at the time of this method's execution; consult the documentation for gluUnProject for more information.


Generated on Sun Jan 14 16:49:11 2007 for Propane Injector by  doxygen 1.4.6