Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Texture Class Reference

#include <texture.h>

List of all members.

Public Member Functions

 Texture (const string &rcFile)

Static Public Member Functions

static const GLuint Load (const string &rcFile)
static const GLuint Load (const string &rcFile, uint &ruiW, uint &ruiH)
static SDL_Surface * HorizontalMirror (const SDL_Surface *const psurface)
static void Surface2Texture (const SDL_Surface *const psurface, GLuint &ruiTexture)

Static Private Member Functions

static void GetCorrectSize (const uint w, const uint h, uint &rW, uint &rH)

Private Attributes

uint uiWidth
uint uiHeight
GLuint uiTexture


Detailed Description

This class can be considered as a tool class for texture image loading. Thanks to the SDL_image library, it can read all the file formats that SDL_image supports.

Definition at line 30 of file texture.h.


Member Function Documentation

void Texture::GetCorrectSize const uint  w,
const uint  h,
uint &  rW,
uint &  rH
[static, private]
 

Find the correct OpenGL dimensions for given width w and height h

Parameters:
w,h The origial texture width and height
rW,rH The corrected texture width and height

Definition at line 263 of file texture.cpp.

Referenced by Surface2Texture().

SDL_Surface * Texture::HorizontalMirror const SDL_Surface *const   psurface  )  [static]
 

After calling this function, the image pixels are flipped in the vertical direction because the SDL_image library reads the image's pixels from the upper left corner, left to right, to the bottom right corner whereas the glTexImage2D builds the texture from the bottom left corner, left to right, to the upper right corner

Parameters:
psurface A source surface
Returns:
A new surface with the flipped pixels from the source surface. The returned surface must be freed by the caller

Definition at line 113 of file texture.cpp.

Referenced by Load().

const GLuint Texture::Load const string &  rcFile,
uint &  ruiW,
uint &  ruiH
[static]
 

Look at the description above

Parameters:
rcFile The path to the image.
ruiW,ruiH The size of the loaded texture
Returns:
The index of the new OpenGL texture (type const GLuint)
See also:
Load()

Definition at line 67 of file texture.cpp.

References HorizontalMirror(), and Surface2Texture().

const GLuint Texture::Load const string &  rcFile  )  [static]
 

Open the specified image, read it into a SDL_surface then convert it to an OpenGL texture. Use it carefully because it doesn't handle error checking right now.

Parameters:
rcFile The path to the image.
Returns:
The index of the new OpenGL texture (type const GLuint)

Definition at line 57 of file texture.cpp.

Referenced by Renderer::DisplaySplash(), and ModelLoader::LoadOCM().

void Texture::Surface2Texture const SDL_Surface *const   psurface,
GLuint &  ruiTexture
[static]
 

Convert a SDL surface to OpenGL texture

Parameters:
psurface The SDL source surface to convert
ruiTexture A reference to a GLuint variable.
Returns:
Nothing

Definition at line 167 of file texture.cpp.

References GetCorrectSize().

Referenced by Load().


The documentation for this class was generated from the following files:
Generated on Sat Nov 11 10:21:11 2006 for OpenCity by  doxygen 1.4.2