GG: GG::Texture Class Reference

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

List of all members
GG::Texture Class Reference

`#include <Texture.h>`

## Structors
| Texture ()
virtual | ~Texture ()

## Accessors
std::string | Filename () const
GLenum | WrapS () const
GLenum | WrapT () const
GLenum | MinFilter () const
GLenum | MagFilter () const
unsigned int | BytesPP () const
X | Width () const
Y | Height () const
bool | MipMapped () const
GLuint | OpenGLId () const
const GLfloat * | DefaultTexCoords () const
X | DefaultWidth () const
Y | 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 (X width, Y height, const unsigned char *image, GLenum format, GLenum type, unsigned bytes_per_pixel, bool mipmap=false)
void | Init (X x, Y y, X width, Y height, X image_width, const unsigned char *image, GLenum format, GLenum type, unsigned 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)

## Detailed Description

This class encapsulates an OpenGL texture object.

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 65 of file Texture.h.

## Member Function Documentation

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.

Exceptions

  GG::Texture::BadFile | Throws if the texture creation fails.

void GG::Texture::Init | ( | X | width,
|  | Y | height,
|  | const unsigned char * | image,
|  | GLenum | format,
|  | GLenum | type,
|  | unsigned | bytes_per_pixel,
|  | bool | mipmap = `false`
| ) |  |

Frees any currently-held memory and creates a texture from supplied array image.

Exceptions

  GG::Texture::Exception | Throws applicable subclass if the texture creation fails in one of the specified ways.

void GG::Texture::Init | ( | X | x,
|  | Y | y,
|  | X | width,
|  | Y | height,
|  | X | image_width,
|  | const unsigned char * | image,
|  | GLenum | format,
|  | GLenum | type,
|  | unsigned int | bytes_per_pixel,
|  | bool | mipmap = `false`
| ) |  |

Frees any currently-held memory and creates a texture from subarea of supplied array image.

Exceptions

  GG::Texture::Exception | Throws applicable subclass if the texture creation fails in one of the specified ways.

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.

The documentation for this class was generated from the following file:

- Texture.h