#include <Texture.h>
Structors | |
Texture () | |
virtual | ~Texture () |
Accessors | |
std::string | Filename () const |
GLenum | WrapS () const |
GLenum | WrapT () const |
GLenum | MinFilter () const |
GLenum | MagFilter () const |
int | BytesPP () const |
GLint | Width () const |
GLint | Height () const |
bool | MipMapped () const |
GLuint | OpenGLId () const |
const GLfloat * | DefaultTexCoords () const |
GLint | DefaultWidth () const |
GLint | DefaultHeight () const |
void | OrthoBlit (const Pt &pt1, const Pt &pt2, const GLfloat *tex_coords=0) const |
void | OrthoBlit (const Pt &pt) const |
Mutators | |
void | Load (const std::string &filename, bool mipmap=false) |
void | Init (int width, int height, const unsigned char *image, GLenum format, GLenum type, int bytes_per_pixel, bool mipmap=false) |
void | Init (int x, int y, int width, int height, int image_width, const unsigned char *image, GLenum format, GLenum type, int bytes_per_pixel, bool mipmap=false) |
void | SetWrap (GLenum s, GLenum t) |
void | SetFilters (GLenum min, GLenum mag) |
void | Clear () |
Exceptions | |
GG_ABSTRACT_EXCEPTION (Exception) | |
GG_CONCRETE_EXCEPTION (BadFile, GG::Texture, Exception) | |
GG_CONCRETE_EXCEPTION (InvalidColorChannels, GG::Texture, Exception) | |
GG_CONCRETE_EXCEPTION (InsufficientResources, GG::Texture, Exception) |
If the dimensions of the image used to initialize the texture are not both powers of two, the texture is created with dimensions of the next largest (or equal) powers of two. The original image occupies the region near the texture's origin, and the rest is zero-initialized. This is done to prevent the image from being scaled, since textures used in a GUI almost always must maintain pixel accuracy. The original image size and corresponding texture coords are saved, and can be accessed through DefaultWidth(), DefaultHeight(), and DefaultTexCoords(), respectively. These are kept so that only the originally-loaded-image part of the texture can be used, if desired. All initialization functions first free the OpenGL texture currently in use by the texture (if any) and create a new one. When the load filename is "" or the image parameter is 0, all initialization functions fail silently, performing no initialization and allocating no memory or OpenGL texture. Serialized Textures save the filename associated with the texture when available, so the originally loaded file can be reloaded again later. If no such file exists, such as when a Texture is created from in-memory image data, the contents of the Texture are read from video memory and saved as binary data. A default-constructed Texture will have niether a filename nor raw image data.
Definition at line 55 of file Texture.h.
GG::Texture::Texture | ( | ) |
ctor
virtual GG::Texture::~Texture | ( | ) | [virtual] |
virtual dtor
std::string GG::Texture::Filename | ( | ) | const |
returns the filename from which this texture was loaded ("" if this texture was not loaded from a file)
GLenum GG::Texture::WrapS | ( | ) | const |
returns S-wrap mode associated with this opengl texture
GLenum GG::Texture::WrapT | ( | ) | const |
returns T-wrap mode associated with this opengl texture
GLenum GG::Texture::MinFilter | ( | ) | const |
returns minimization filter modes associated with this opengl texture
GLenum GG::Texture::MagFilter | ( | ) | const |
returns maximization filter modes associated with this opengl texture
int GG::Texture::BytesPP | ( | ) | const |
returns the image's color depth in bytes
GLint GG::Texture::Width | ( | ) | const |
returns width of entire texture
GLint GG::Texture::Height | ( | ) | const |
returns height of entire texture
bool GG::Texture::MipMapped | ( | ) | const |
returns true if the texture has mipmaps
GLuint GG::Texture::OpenGLId | ( | ) | const |
GLuint "name" of the opengl texture object associated with this object.
const GLfloat* GG::Texture::DefaultTexCoords | ( | ) | const |
texture coordinates to use by default when blitting this texture
GLint GG::Texture::DefaultWidth | ( | ) | const |
returns width in pixels, based on initial image (0 if texture was not loaded)
GLint GG::Texture::DefaultHeight | ( | ) | const |
returns height in pixels, based on initial image (0 if texture was not loaded)
void GG::Texture::OrthoBlit | ( | const Pt & | pt1, | |
const Pt & | pt2, | |||
const GLfloat * | tex_coords = 0 | |||
) | const |
blit any portion of texture to any place on screen, scaling as necessary
void GG::Texture::OrthoBlit | ( | const Pt & | pt | ) | const |
blit default portion of texture unscaled to pt (upper left corner)
void GG::Texture::Load | ( | const std::string & | filename, | |
bool | mipmap = false | |||
) |
frees any currently-held memory and loads a texture from file filename.
GG::Texture::BadFile | Throws if the texture creation fails. |
void GG::Texture::Init | ( | int | width, | |
int | height, | |||
const unsigned char * | image, | |||
GLenum | format, | |||
GLenum | type, | |||
int | bytes_per_pixel, | |||
bool | mipmap = false | |||
) |
frees any currently-held memory and creates a texture from supplied array image.
GG::Texture::Exception | Throws applicable subclass if the texture creation fails in one of the specified ways. |
void GG::Texture::Init | ( | int | x, | |
int | y, | |||
int | width, | |||
int | height, | |||
int | image_width, | |||
const unsigned char * | image, | |||
GLenum | format, | |||
GLenum | type, | |||
int | bytes_per_pixel, | |||
bool | mipmap = false | |||
) |
frees any currently-held memory and creates a texture from subarea of supplied array image.
GG::Texture::Exception | Throws applicable subclass if the texture creation fails in one of the specified ways. |
void GG::Texture::SetWrap | ( | GLenum | s, | |
GLenum | t | |||
) |
sets the opengl texture wrap modes associated with opengl texture m_opengl_id
void GG::Texture::SetFilters | ( | GLenum | min, | |
GLenum | mag | |||
) |
sets the opengl min/mag filter modes associated with opengl texture m_opengl_id
void GG::Texture::Clear | ( | ) |
frees the opengl texture object associated with this object
GG::Texture::GG_ABSTRACT_EXCEPTION | ( | Exception | ) |
The base class for Texture exceptions.
GG::Texture::GG_CONCRETE_EXCEPTION | ( | BadFile | , | |
GG::Texture | , | |||
Exception | ||||
) |
Thrown when valid texture data cannot be read from a file.
GG::Texture::GG_CONCRETE_EXCEPTION | ( | InvalidColorChannels | , | |
GG::Texture | , | |||
Exception | ||||
) |
Thrown when an unsupported number of color channels is requested.
GG::Texture::GG_CONCRETE_EXCEPTION | ( | InsufficientResources | , | |
GG::Texture | , | |||
Exception | ||||
) |
Thrown when GL fails to provide a requested texture object.