| GL Studio C++ Runtime API

Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
TexturePalette Class Reference

`#include <texture_palette.h>`

## Classes
class | DistiAttributeTexturePalette
class | DistiAttributeTexturePalette_V21

## Public Member Functions
bool | IsValidIndex (int i)
| TexturePalette (int size=0)
void | PaletteSize (int newSize)
void | operator= (TexturePalette &source)
TexturePaletteEntry * | Entry (int i)
unsigned int | size () const
unsigned int | Count () const
void | InvalidateTextures ()
int | FindAvailableSlot ()
const char * | TextureFilename (int i)
void | TextureFilename (int i, const char *filename)
bool | SetTexture (int i, const char *filename, const Image::LoadOptions &options=Image::LoadOptions(), bool glTexCompress=false, bool allowNPOT=true, bool isLoadingDeferred=true)
bool | SetTexture (int i, TexturePaletteEntry *entry)
bool | SetTexture (int i, Image *image)
bool | SetInlineTexture (int i, glsInlineImage &image, bool isLoadingDeferred=true)
bool | DisableImageSharing (int index)
int | FindTextureByName (const char *name)
TextureState_e | TextureState (int i)
int | Width (int i)
int | Height (int i)
int | TextureWidth (int i)
int | TextureHeight (int i)
float | TextureCoordX (int i)
float | TextureCoordY (int i)
void | InvalidateTexture (int i)
void | BindTexture (int i, IGlsStateManager *stateManager)
int | TextureValid (int i)
void | DeleteTexture (int i)
Image * | Texture (int i)
bool | GenerateInline (int i)
bool | UseGLTextureCompression (int i)
bool | AllowNPOT (int i)
long | CompressedSize (int i)
glsImageCodec | Codec (int i)
int | CompressionFactor (int i)
void | GenerateInline (int i, bool val)
void | UseGLTextureCompression (int i, bool val)
void | AllowNPOT (int i, bool val)
void | CompressedSize (int i, long val)
void | Codec (int i, glsImageCodec val, bool reload=true)
void | CompressionFactor (int i, int val, bool reload=true)
void | DesiredLoadSize (int i, int width, int height)
void | Reload (int i)
void | SetMipMap (int i, bool val)
void | PreviewGenerated (int i)
void | SetTexturePaletteCallback (void(*callback)(bool, int, DisplayFrame *), DisplayFrame *owningFrame)

## Static Public Member Functions
static bool | DownsizeImage (Image *image, int desiredWidth, int desiredHeight)

## Public Attributes
DynamicArray< TexturePaletteEntry > & | palette

## Detailed Description

Texture Palette class. Stores a list of textures, each with its own texture handle. This the textures to be stored separately from the objects, which allows multiple objects to share the same textures.

## Constructor & Destructor Documentation

## ◆ TexturePalette()

TexturePalette | ( | int | size = `0` | ) |
| explicit

Create a new texture palette with the indicated number of entries

Parameters

  size | The number of entries in the palette

## Member Function Documentation

## ◆ AllowNPOT() [1/2]

bool AllowNPOT | ( | int | i | ) |

Returns
  True if the image is allowed to be non power of two

Parameters

  i | The index of the texture

## ◆ AllowNPOT() [2/2]

void AllowNPOT | ( | int | i,
|  | bool | val
| ) |  |

Set True if the image is allowed to be non power of two

Parameters

  i | The index of the texture
  val | the value to set allowing non-power of two (NPOT) functionality

## ◆ BindTexture()

void BindTexture | ( | int | i,
|  | IGlsStateManager * | stateManager
| ) |  |

Bind the texture at the given index, unless it is already bound. Set as the texture to be used for texturing polygons

Parameters

  i | The index of the texture
  stateManager |

## ◆ Codec() [1/2]

glsImageCodec Codec | ( | int | i | ) |

Returns
  CODEC that will be used to compress an inline image

Parameters

  i | The index of the texture

## ◆ Codec() [2/2]

void Codec | ( | int | i,
|  | glsImageCodec | val,
|  | bool | reload = `true`
| ) |  |

Set CODEC that will be used to compress an inline image

Parameters

  i | The index of the texture
  val | The codec to set
  reload | Whether or not to reload the image

## ◆ CompressedSize() [1/2]

long CompressedSize | ( | int | i | ) |

Returns
  Size of image when compressed with currently set inline CODEC

Parameters

  i | The index of the texture

## ◆ CompressedSize() [2/2]

void CompressedSize | ( | int | i,
|  | long | val
| ) |  |

Set Size of image when compressed with currently set inline CODEC

Parameters

  i | The index of the texture
  val |

## ◆ CompressionFactor() [1/2]

int CompressionFactor | ( | int | i | ) |

Returns
  Compression factor of the image, used only for JPEG

Parameters

  i | The index of the texture

## ◆ CompressionFactor() [2/2]

void CompressionFactor | ( | int | i,
|  | int | val,
|  | bool | reload = `true`
| ) |  |

Set Compression factor of the image, used only for JPEG

Parameters

  i | The index of the texture
  val |
  reload |

## ◆ Count()

unsigned int Count | ( |  | ) | const

Returns
  The number of textures (whether valid or not) in this texture palette.

## ◆ DeleteTexture()

void DeleteTexture | ( | int | i | ) |

Delete the texture at the given index. Mark the index as unused.

Parameters

  i | The index of the texture

## ◆ DesiredLoadSize()

void DesiredLoadSize | ( | int | i,
|  | int | width,
|  | int | height
| ) |  |

Sets the desired load size for the image. If the loaded image is larger than the specified dimensions, it will be scaled down during the load.

Parameters

  i | The index of the texture
  width | The desired width
  height | The desired height

## ◆ DisableImageSharing()

bool DisableImageSharing | ( | int | index | ) |

Disables image sharing for the Image at the given index and ensures that the index refers to a unique Image instance. Note: If you want to disable image sharing for an Image that is not yet in a palette, you should call AllowImageSharing(false) on the Image.

Parameters

  index | The index of the texture to disable image sharing. The Image must already be loaded in the palette.

Returns
  true on success
  false on failure (Invalid index or Image could not be guarenteed unique)

## ◆ DownsizeImage()

static bool DownsizeImage | ( | Image * | image,
|  | int | desiredWidth,
|  | int | desiredHeight
| ) |  |
| static

Scales down an image to the next power-of-two size where (width <= desiredWidth || height <= desiredHeight), maintains aspect ratio.

Note
  This method may be removed from the TexturePalette in the future.

Parameters

  image | The image to scale down.
  desiredWidth | The target width in pixels.
  desiredHeight | The target height in pixels.

Returns
  True if operation is successful.

## ◆ Entry()

TexturePaletteEntry * Entry | ( | int | i | ) |

Returns
  The texture palette entry at index i, expanding the palette to accomodate the index if needed.

Parameters

  i | The index of the desired palette entry.

## ◆ FindAvailableSlot()

int FindAvailableSlot | ( |  | ) |

Finds an unused slot in the texture palette.

Returns
  The index of the first unused slot in the palette.

## ◆ FindTextureByName()

int FindTextureByName | ( | const char * | name | ) |

Finds a texture based on its filename

Parameters

  name | The filename of the texture to find

Returns
  The index if found, -1 if not found

## ◆ GenerateInline() [1/2]

bool GenerateInline | ( | int | i | ) |

Returns
  True if the image is to be generated as inline code

Parameters

  i | The index of the texture

## ◆ GenerateInline() [2/2]

void GenerateInline | ( | int | i,
|  | bool | val
| ) |  |

Set True if the image is to be generated as inline code

Parameters

  i | The index of the texture
  val |

## ◆ Height()

int Height | ( | int | i | ) |

Returns the height of the texture image in pixels

Parameters

  i | The index of the texture to get the height of

Returns
  The height of the texture image in pixels

## ◆ InvalidateTexture()

void InvalidateTexture | ( | int | i | ) |

Invalidate the texture at the given index, causing it to be rebound the next time it is referencd

Parameters

  i | The index of the texture

## ◆ InvalidateTextures()

void InvalidateTextures | ( |  | ) |

Invalidates all of the textures in the palette, forcing them to be rebound the next time they are referenced by an object.

## ◆ IsValidIndex()

bool IsValidIndex | ( | int | i | ) |

Returns
  True if the index i passed in is a valid texture index. Doesn't imply that a texture exists at that index, merely that the index is within the array bounds of the texture palette.

Parameters

  i | The index to check.

## ◆ operator=()

void operator= | ( | TexturePalette & | source | ) |

Assignment operator

Parameters

  source | The object to copy from.

## ◆ PaletteSize()

void PaletteSize | ( | int | newSize | ) |

Resize texture palette with the indicated number of entries

Parameters

  newSize | The new number of entries in the palette

## ◆ PreviewGenerated()

void PreviewGenerated | ( | int | i | ) |

Compress using the current compression settings for the texture and scale down to the DesiredLoadSize.

Parameters

  i | The index of the texture

## ◆ Reload()

void Reload | ( | int | i | ) |

Reload a texture from disk, then downsize and compress it using the current settings of the TexturePaletteEntry

Parameters

  i | The index of the texture to reload

## ◆ SetInlineTexture()

bool SetInlineTexture | ( | int | i,
|  | glsInlineImage & | image,
|  | bool | isLoadingDeferred = `true`
| ) |  |

Sets the texture at the given index.

Parameters

  i | The index to insert at.
  image | Structure containing the compressed image data.
  isLoadingDeferred | If true, the image will not be loaded from disk until bound.

Returns
  true

## ◆ SetMipMap()

void SetMipMap | ( | int | i,
|  | bool | val
| ) |  |

Set mip-mapping state for given texture

Parameters

  i | The index of the texture to set mipmapping for
  val | The mipmapping state to set

## ◆ SetTexture() [1/3]

bool SetTexture | ( | int | i,
|  | const char * | filename,
|  | const Image::LoadOptions & | options = `Image::LoadOptions()`,
|  | bool | glTexCompress = `false`,
|  | bool | allowNPOT = `true`,
|  | bool | isLoadingDeferred = `true`
| ) |  |

Sets the texture at the given index. Attempts to load the texture from disk.

Parameters

  i | The texture index to load the texture into.
  filename | The filename to set.
  options | Image load options (e.g. reverse alpha).
  glTexCompress | The GlTextureCompression setting for the new Image.
  allowNPOT | If the image is allowed to be non-power of two (NPOT).
  isLoadingDeferred | If true, the image will not be loaded from disk until bound.

Returns
  TRUE if successful else FALSE.

## ◆ SetTexture() [2/3]

bool SetTexture | ( | int | i,
|  | Image * | image
| ) |  |

Sets the texture at the given index. Does NOT attempt to load a file.

Parameters

  i | The texture index to load the texture into.
  image | An image that will be the texture.

Returns
  TRUE if successful else FALSE.

## ◆ SetTexture() [3/3]

bool SetTexture | ( | int | i,
|  | TexturePaletteEntry * | entry
| ) |  |

Sets the texture at the given index using a TexturePaletteEntry structure. This is generally only used in the Editor.

Parameters

  i | The texture index to load the texture into.
  entry | Image generation options, NULL if not setting them.

Returns
  TRUE if successful else FALSE.

## ◆ SetTexturePaletteCallback()

void SetTexturePaletteCallback | ( | void(*)(bool, int, DisplayFrame *) | callback,
|  | DisplayFrame * | owningFrame
| ) |  |

Sets up for a callback to be used for reacting to the texture palette items and filenames to be updated.

Parameters

  callback | A function accepting whether the texture was added/modified(true) or removed(false), the index of it, and the frame this palette belongs to.
  owningFrame | The display frame that this texture palette belongs to.

## ◆ size()

unsigned int size | ( |  | ) | const
| inline

Returns
  The number of textures (whether valid or not) in this texture palette.

Deprecated:
  Renamed to Count() to match DynamicArray.

## ◆ Texture()

Image * Texture | ( | int | i | ) |

Get a pointer to the texture at the given index.

Parameters

  i | The index of the texture

Returns
  The texture at that index. NULL if there is none.

## ◆ TextureCoordX()

float TextureCoordX | ( | int | i | ) |

Returns the Texture Coordinate of the upper right corner of the image computed as (Width/TextureWidth)

Parameters

  i | The index of the texture

Returns
  The Texture Coordinate of the upper right corner of the image

## ◆ TextureCoordY()

float TextureCoordY | ( | int | i | ) |

Returns the Texture Coordinate of the upper right corner of the image computed as (Height/TextureHeight)

Parameters

  i | The index of the texture

Returns
  The Texture Coordinate of the upper right corner of the image

## ◆ TextureFilename() [1/2]

const char * TextureFilename | ( | int | i | ) |

Returns the filename associated with the texture at the given index.

Parameters

  i | The index to get the filename from

Returns
  The filename of the texture at that index

## ◆ TextureFilename() [2/2]

void TextureFilename | ( | int | i,
|  | const char * | filename
| ) |  |

Sets the filename associated with the texture at the given index.

Parameters

  i | The index to get the filename from
  filename | The filename to set

## ◆ TextureHeight()

int TextureHeight | ( | int | i | ) |

Returns the power of two height of the texture image in pixels

Parameters

  i | The index of the texture to get the power of two height of

Returns
  The power of two height of the texture image in pixels

## ◆ TextureState()

TextureState_e TextureState | ( | int | i | ) |

Gets the texture state of the texture at the given index.

Parameters

  i | The index to get the texture state from

Returns
  The state (UNUSED,VALID,INVALID) of the texture

## ◆ TextureValid()

int TextureValid | ( | int | i | ) |

Return whether or not texture is bound

Parameters

  i | The index of the texture

Returns
  boolean result of whether or not texture is bound

## ◆ TextureWidth()

int TextureWidth | ( | int | i | ) |

Returns the power of two width of the texture image in pixels

Parameters

  i | The index of the texture to get the power of two width of

Returns
  The power of two width of the texture image in pixels

## ◆ UseGLTextureCompression() [1/2]

bool UseGLTextureCompression | ( | int | i | ) |

Returns
  True if the image is to be generated to use OpenGL texture compression

Parameters

  i | The index of the texture

## ◆ UseGLTextureCompression() [2/2]

void UseGLTextureCompression | ( | int | i,
|  | bool | val
| ) |  |

Set True if the image is to be generated to use OpenGL texture compression

Parameters

  i | The index of the texture
  val |

## ◆ Width()

int Width | ( | int | i | ) |

Returns the width of the texture image in pixels

Parameters

  i | The index of the texture to get the width of

Returns
  The width of the texture image in pixels

## Member Data Documentation

## ◆ palette

DynamicArray<TexturePaletteEntry>& palette

Returns
  The list of entries for this palette.

Deprecated:
  Member data has been made private. Use accessor functions like Entry() and Count() instead.

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

- texture_palette.h