Public Member Functions | Private Member Functions | Private Attributes

OGL_Renderer Class Reference

OpenGL Renderer. More...

#include <OGL_Renderer.h>

Inheritance diagram for OGL_Renderer:
Renderer

List of all members.

Public Member Functions

 OGL_Renderer ()
 OGL_Renderer (Uint ResX, Uint ResY, Uint BPP, bool fullscreen, bool vsync)
 ~OGL_Renderer ()
void setApplicationTitle (const std::string &title)
bool drawImage (Image *image, int x, int y)
bool drawImage (Image *image, int rasterX, int rasterY, int x, int y, int width, int height)
bool drawImagePattern (Image *image, int x, int y, int w, int h)
bool drawImageRect (int x, int y, int w, int h, Image *topLeft, Image *top, Image *topRight, Image *left, Image *center, Image *right, Image *bottomLeft, Image *bottom, Image *bottomRight)
bool drawImageRect (int x, int y, int w, int h, ImageList &images)
void drawPixel (int x, int y, int r, int g, int b, int a)
void drawLine (int x, int y, int x2, int y2, int r, int g, int b, int a)
void drawBox (int x, int y, int width, int height, int r, int g, int b, int a)
void drawCircle (int cx, int cy, int radius, int r, int g, int b, int a, int num_segments, float scale_x, float scale_y)
void floodFill (int x, int y, int width, int height, int r, int g, int b, int a)
bool drawText (Font *font, const std::string &text, int x, int y, int r, int g, int b, int a)
bool drawTextClamped (Font *font, const std::string &text, int x, int y, int w, int h, int r, int g, int b, int a)
void imageDesaturate (Image *image)
void clearScreen (int r, int g, int b)
void update ()
Uint getPixelColor (Image *src, int x, int y)
bool isPixelTransparent (Image *src, int x, int y)
int getScreenWidth ()
int getScreenHeight ()

Private Member Functions

 OGL_Renderer (const OGL_Renderer &)
OGL_Rendereroperator= (const OGL_Renderer &)
void initGL ()
void initVideo (Uint resX, Uint resY, Uint bpp, bool fullscreen, bool vsync)
void checkExtensions ()
bool drawPointer (int x, int y)
GLuint getTextureId (Image *image)
GLuint getPatternTextureId (Image *image, int w, int h)
GLuint generateTexture (SDL_Surface *src)
void updateTextures ()
void getError ()

Private Attributes

SDL_Surface * mScreen
Timer mTimer
Uint mLastResourceCheck
std::map< int, pair< GLuint,
int > > 
mTextureArray

Detailed Description

OpenGL Renderer.

Implements all Renderer functions with the SDL_opengl API. Note: The use of glBegin()->glEnd() calls is now deprecated in OGL3. If we can switch to a non-immediate mode methodollogy it may help us when splitting towards a pure 3D renderer.


Constructor & Destructor Documentation

OGL_Renderer::OGL_Renderer (  ) 
OGL_Renderer::OGL_Renderer ( Uint  ResX,
Uint  ResY,
Uint  BPP,
bool  fullscreen,
bool  vsync 
)
OGL_Renderer::~OGL_Renderer (  ) 
OGL_Renderer::OGL_Renderer ( const OGL_Renderer  )  [private]

Member Function Documentation

void OGL_Renderer::checkExtensions (  )  [private]

Checks for expected extensions and prints warning messages if the video driver doesn't support the extension.

void OGL_Renderer::clearScreen ( int  r,
int  g,
int  b 
) [virtual]

Clears the screen with a given RGB value.

Parameters:
r Red color value between 0 - 255.
g Green Color Value between 0 - 255.
b Blue Color Value between 0 - 255.

Reimplemented from Renderer.

void OGL_Renderer::drawBox ( int  x,
int  y,
int  width,
int  height,
int  r,
int  g,
int  b,
int  a 
) [virtual]

Draws a hollow box on the primary surface.

Parameters:
x X-Coordinate of the box.
y Y-Coordinate of the box.
width Width, in pixels, of the box.
height Height, in pixels, of the box.
r Red Color Value. Must be between 0 - 255.
g Green Color Value. Must be between 0 - 255.
b Blue Color Value. Must be between 0 - 255.
a Alhpa value to use. Must be between 0 (completely transparent) - 255 (completely opaque).

Reimplemented from Renderer.

void OGL_Renderer::drawCircle ( int  cx,
int  cy,
int  radius,
int  r,
int  g,
int  b,
int  a,
int  num_segments,
float  scale_x,
float  scale_y 
) [virtual]

Reimplemented from Renderer.

bool OGL_Renderer::drawImage ( Image image,
int  x,
int  y 
) [virtual]

Draws an Image to the screen.

Parameters:
image A pointer to an Image Resource class.
x X-Coordinate of the Image to draw.
y Y-Coordinate of the Image to draw.

Reimplemented from Renderer.

bool OGL_Renderer::drawImage ( Image image,
int  rasterX,
int  rasterY,
int  x,
int  y,
int  width,
int  height 
) [virtual]
Todo:
Currently this function doesn't actually render a sub image of a larger image. Instead, it just stretches the texture across the entire surface of the quad.

Reimplemented from Renderer.

bool OGL_Renderer::drawImagePattern ( Image image,
int  x,
int  y,
int  w,
int  h 
) [virtual]

Trevor, Comment Me!

Parameters:
image A pointer to an Image Resource class.
x Comment me!
y Comment me!
w Comment me!
h Comment me!

Reimplemented from Renderer.

bool OGL_Renderer::drawImageRect ( int  x,
int  y,
int  w,
int  h,
Image topLeft,
Image top,
Image topRight,
Image left,
Image center,
Image right,
Image bottomLeft,
Image bottom,
Image bottomRight 
) [virtual]
Todo:
Comment me!

Reimplemented from Renderer.

bool OGL_Renderer::drawImageRect ( int  x,
int  y,
int  w,
int  h,
ImageList images 
) [virtual]

Draws a rectangle using a series of set of images.

This function expects an ImageList with 9 images in it: four corners, four edges and a center image to fill the rest in with.

Todo:
Document the expected order of images to properly draw a rectangle.

Reimplemented from Renderer.

void OGL_Renderer::drawLine ( int  x,
int  y,
int  x2,
int  y2,
int  r,
int  g,
int  b,
int  a 
) [virtual]

Draws a line from (x, y) - (x2, y2) on the primary surface.

Parameters:
x X-Coordinate of the start of the line.
y Y-Coordinate of the start of the line.
x2 X-Coordinate of the end of the line.
y2 Y-Coordinate of the end of the line.
r Red Color Value. Must be between 0 - 255.
g Green Color Value. Must be between 0 - 255.
b Blue Color Value. Must be between 0 - 255.
a Alpha Value. Must be between 0 - 255. Defaults to 255.

Reimplemented from Renderer.

void OGL_Renderer::drawPixel ( int  x,
int  y,
int  r,
int  g,
int  b,
int  a 
) [virtual]

Draws a single Pixel to the primary surface.

Parameters:
x X-Coordinate of the pixel to draw.
y Y-Coordinate of the pixel to draw.
r Red Color Value. Must be between 0 - 255.
g Green Color Value. Must be between 0 - 255.
b Blue Color Value. Must be between 0 - 255.
a Alpha Value. Must be between 0 - 255. Defaults to 255.

Reimplemented from Renderer.

bool OGL_Renderer::drawPointer ( int  x,
int  y 
) [private, virtual]

Renders the mouse cursor.

Reimplemented from Renderer.

bool OGL_Renderer::drawText ( Font font,
const std::string &  text,
int  x,
int  y,
int  r,
int  g,
int  b,
int  a 
) [virtual]

Reimplemented from Renderer.

bool OGL_Renderer::drawTextClamped ( Font font,
const std::string &  text,
int  x,
int  y,
int  w,
int  h,
int  r,
int  g,
int  b,
int  a 
) [virtual]

Reimplemented from Renderer.

void OGL_Renderer::floodFill ( int  x,
int  y,
int  width,
int  height,
int  r,
int  g,
int  b,
int  a 
) [virtual]

Fills a given area with a solid color on the primary surface.

Parameters:
x X-Coordinate of the area to fill.
y Y-Coordinate of the area to fill.
width Width, in pixels, of the area to fill.
height Height, in pixels, of the area to fill.
r Red Color Value. Must be between 0 - 255.
g Green Color Value. Must be between 0 - 255.
b Blue Color Value. Must be between 0 - 255.
a Alpha value. Must be between 0 - 255.

Reimplemented from Renderer.

GLuint OGL_Renderer::generateTexture ( SDL_Surface *  src  )  [private]

Todo:
When compiling in nightmare mode with Visual Studio, it indicated that textureFormat could be potentially uninitialized should nColors be anything other than '3' or '4' (24 bit and 32 bit color modes, respectively). The only other expected values would be '2' (16 bit color mode) or '1' (8 bit color mode). While in practice neither of these cases is likely to show up, it's extremely important that textureFormat is initialized to a good default value that will work for generally all modes or one that will at least not cause a crash.

void OGL_Renderer::getError (  )  [private]
GLuint OGL_Renderer::getPatternTextureId ( Image image,
int  w,
int  h 
) [inline, private]
Uint OGL_Renderer::getPixelColor ( Image src,
int  x,
int  y 
) [virtual]

Returns the RGB color of a pixel at X, Y as an unsigned 32-Bit Integer.

Parameters:
src A pointer to an Image.
x X-Coordinate of the pixel to inspect.
y Y-Coordinate of the pixel to inspect.

Reimplemented from Renderer.

int OGL_Renderer::getScreenHeight (  )  [virtual]

Returns the primary display's Height.

Reimplemented from Renderer.

int OGL_Renderer::getScreenWidth (  )  [virtual]

Returns the primary display's Width.

Reimplemented from Renderer.

GLuint OGL_Renderer::getTextureId ( Image image  )  [inline, private]

Gets a TextureID from our array of GL Texture's.

void OGL_Renderer::imageDesaturate ( Image image  )  [virtual]
Todo:
There ought to be a better/faster way of doing this with OpenGL than we could possibly do with SDL's functions.

Reimplemented from Renderer.

void OGL_Renderer::initGL (  )  [private]
void OGL_Renderer::initVideo ( Uint  resX,
Uint  resY,
Uint  bpp,
bool  fullscreen,
bool  vsync 
) [private, virtual]

Reimplemented from Renderer.

bool OGL_Renderer::isPixelTransparent ( Image src,
int  x,
int  y 
) [virtual]

Reimplemented from Renderer.

OGL_Renderer& OGL_Renderer::operator= ( const OGL_Renderer  )  [private]
void OGL_Renderer::setApplicationTitle ( const std::string &  title  )  [virtual]

Reimplemented from Renderer.

void OGL_Renderer::update (  )  [virtual]

Reimplemented from Renderer.

void OGL_Renderer::updateTextures (  )  [inline, private]

Checks through the list of textures and removes any textures that haven't been accessed for more than TEXTURE_EXPIRE_TIME minutes.


Member Data Documentation

Tick count from last resource check.

SDL_Surface* OGL_Renderer::mScreen [private]

Primary screen surface.

std::map<int, pair<GLuint, int> > OGL_Renderer::mTextureArray [private]

Internal array of GL Texture ID and time stamp.

Internal Timer.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines