|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

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

All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Static Public Member Functions
gameplay::Texture Class Reference

`#include <Texture.h>`

Inheritance diagram for gameplay::Texture:

List of all members.

## Classes

class | Sampler

## Public Types

enum | Format { UNKNOWN = 0, RGB = GL_RGB, RGBA = GL_RGBA, ALPHA = GL_ALPHA }
enum | Filter { NEAREST = GL_NEAREST, LINEAR = GL_LINEAR, NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR }
enum | Wrap { REPEAT = GL_REPEAT, CLAMP = GL_CLAMP_TO_EDGE }
enum | Type { TEXTURE_2D = GL_TEXTURE_2D, TEXTURE_CUBE = GL_TEXTURE_CUBE_MAP }
enum | CubeFace { POSITIVE_X, NEGATIVE_X, POSITIVE_Y, NEGATIVE_Y, POSITIVE_Z, NEGATIVE_Z }

## Public Member Functions

void | setData (const unsigned char *data)
const char * | getPath () const
Format | getFormat () const
Type | getType () const
unsigned int | getWidth () const
unsigned int | getHeight () const
void | generateMipmaps ()
bool | isMipmapped () const
bool | isCompressed () const
TextureHandle | getHandle () const

## Static Public Member Functions

static Texture * | create (const char *path, bool generateMipmaps=false)
static Texture * | create (Image *image, bool generateMipmaps=false)
static Texture * | create (Format format, unsigned int width, unsigned int height, const unsigned char *data, bool generateMipmaps=false, Type type=TEXTURE_2D)
static Texture * | create (TextureHandle handle, int width, int height, Format format=UNKNOWN)

## Detailed Description

Defines a standard texture.

## Member Enumeration Documentation

enum gameplay::Texture::CubeFace

Defines a face of a Texture of Type: cube.

enum gameplay::Texture::Filter

Defines the set of supported texture filters.

enum gameplay::Texture::Format

Defines the set of supported texture formats.

enum gameplay::Texture::Type

Defines the type of Texture in use.

enum gameplay::Texture::Wrap

Defines the set of supported texture wrapping modes.

## Member Function Documentation

static Texture* gameplay::Texture::create | ( | const char * | path,
|  | bool | generateMipmaps = `false`
| ) |  | `[static]`

Creates a texture from the given image resource.

Note that for textures that include mipmap data in the source data (such as most compressed textures), the generateMipmaps flags should NOT be set to true.

Parameters:

  path | The image resource path.
  generateMipmaps | true to auto-generate a full mipmap chain, false otherwise.

Returns:
  The new texture, or NULL if the texture could not be loaded/created.

static Texture* gameplay::Texture::create | ( | Image * | image,
|  | bool | generateMipmaps = `false`
| ) |  | `[static]`

Creates a texture from the given image.

Parameters:

  image | The image containing the texture data.
  generateMipmaps | True to generate a full mipmap chain, false otherwise.

Returns:
  The new texture, or NULL if the image is not of a supported texture format.

static Texture* gameplay::Texture::create | ( | Format | format,
|  | unsigned int | width,
|  | unsigned int | height,
|  | const unsigned char * | data,
|  | bool | generateMipmaps = `false`,
|  | Type | type = `TEXTURE_2D`
| ) |  | `[static]`

Creates a texture from the given texture data.

The data in the texture is expected to be tightly packed (no padding at the end of rows).

Parameters:

  format | Format of the texture data.
  width | Width of the texture data. If type is TEX_CUBE, then this is the cube face width.
  height | Height of the texture data. If type is TEX_CUBE, then this is the cube face height.
  data | Raw texture data (expected to be tightly packed). If the type parameter is set to TEXTURE_CUBE, then data is expected to be each face stored back contiguously within the array.
  generateMipmaps | True to generate a full mipmap chain, false otherwise.
  type | What type of Texture should be created.

Returns:
  The new texture.

static Texture* gameplay::Texture::create | ( | TextureHandle | handle,
|  | int | width,
|  | int | height,
|  | Format | format = `UNKNOWN`
| ) |  | `[static]`

Creates a texture object to wrap the specified pre-created native texture handle.

The specified TextureHandle must represent a valid texture that has been created on the underlying renderer and it should not be referenced by any other Texture object. When the returned Texture object is destroyed, the passed in TextureHandle will also be destroyed.

Parameters:

  handle | Native texture handle.
  width | The width of the texture represented by 'handle'.
  height | The height of the texture represented by 'handle'.
  format | Optionally, the format of the texture represented by 'handle'. If the format cannot be represented by any of the Texture::Format values, use a value of UNKNOWN.

Returns:
  The new texture.

void gameplay::Texture::generateMipmaps | ( |  | ) |

Generates a full mipmap chain for this texture if it isn't already mipmapped.

Format gameplay::Texture::getFormat | ( |  | ) | const

Gets the format of the texture.

Returns:
  The texture format.

TextureHandle gameplay::Texture::getHandle | ( |  | ) | const

Returns the texture handle.

Returns:
  The texture handle.

unsigned int gameplay::Texture::getHeight | ( |  | ) | const

Gets the texture height.

Returns:
  The texture height.

const char* gameplay::Texture::getPath | ( |  | ) | const

Returns the path that the texture was originally loaded from (if applicable).

Returns:
  The texture path, or an empty string if the texture was not loaded from file.

Type gameplay::Texture::getType | ( |  | ) | const

Gets the texture type.

Returns:
  The texture type.

unsigned int gameplay::Texture::getWidth | ( |  | ) | const

Gets the texture width.

Returns:
  The texture width.

bool gameplay::Texture::isCompressed | ( |  | ) | const

Determines if this texture is a compressed texture.

bool gameplay::Texture::isMipmapped | ( |  | ) | const

Determines if this texture currently contains a full mipmap chain.

Returns:
  True if this texture is currently mipmapped, false otherwise.

void gameplay::Texture::setData | ( | const unsigned char * | data | ) |

Set texture data to replace current texture image.

Parameters:

  data | Raw texture data (expected to be tightly packed). If the type parameter is set to TEXTURE_CUBE, then data is expected to be each face stored back contiguously within the array.

All Classes Functions Variables Typedefs Enumerations Enumerator