overview wiki api reference download
 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:
gameplay::Ref

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 Texturecreate (const char *path, bool generateMipmaps=false)
static Texturecreate (Image *image, bool generateMipmaps=false)
static Texturecreate (Format format, unsigned int width, unsigned int height, const unsigned char *data, bool generateMipmaps=false, Type type=TEXTURE_2D)
static Texturecreate (TextureHandle handle, int width, int height, Format format=UNKNOWN)

Detailed Description

Defines a standard texture.


Member Enumeration Documentation

Defines a face of a Texture of Type: cube.

Defines the set of supported texture filters.

Defines the set of supported texture formats.

Defines the type of Texture in use.

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:
pathThe image resource path.
generateMipmapstrue 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:
imageThe image containing the texture data.
generateMipmapsTrue 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:
formatFormat of the texture data.
widthWidth of the texture data. If type is TEX_CUBE, then this is the cube face width.
heightHeight of the texture data. If type is TEX_CUBE, then this is the cube face height.
dataRaw 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.
generateMipmapsTrue to generate a full mipmap chain, false otherwise.
typeWhat 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:
handleNative texture handle.
widthThe width of the texture represented by 'handle'.
heightThe height of the texture represented by 'handle'.
formatOptionally, 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.

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

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.

Gets the texture type.

Returns:
The texture type.
unsigned int gameplay::Texture::getWidth ( ) const

Gets the texture width.

Returns:
The texture width.

Determines if this texture is a compressed texture.

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:
dataRaw 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