GL Studio C++ Runtime API
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)
 
TexturePaletteEntryEntry (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)
 
int TextureValid (int i)
 
void DeleteTexture (int i)
 
ImageTexture (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
sizeThe 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
iThe 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
iThe index of the texture
valthe value to set allowing non-power of two (NPOT) functionality

◆ BindTexture()

void BindTexture ( int  i)

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

Parameters
iThe index of the texture

◆ Codec() [1/2]

glsImageCodec Codec ( int  i)
Returns
CODEC that will be used to compress an inline image
Parameters
iThe 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
iThe index of the texture
valThe codec to set
reloadWhether 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
iThe 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
iThe index of the texture
val

◆ CompressionFactor() [1/2]

int CompressionFactor ( int  i)
Returns
Compression factor of the image, used only for JPEG
Parameters
iThe 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
iThe 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
iThe 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
iThe index of the texture
widthThe desired width
heightThe 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
indexThe 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
imageThe image to scale down.
desiredWidthThe target width in pixels.
desiredHeightThe 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
iThe 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
nameThe 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
iThe 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
iThe index of the texture
val

◆ Height()

int Height ( int  i)

Returns the height of the texture image in pixels

Parameters
iThe 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
iThe 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
iThe index to check.

◆ operator=()

void operator= ( TexturePalette source)

Assignment operator

Parameters
sourceThe object to copy from.

◆ PaletteSize()

void PaletteSize ( int  newSize)

Resize texture palette with the indicated number of entries

Parameters
newSizeThe 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
iThe 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
iThe index of the texture to reload

◆ SetInlineTexture()

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

Sets the texture at the given index.

Parameters
iThe index to insert at.
imageStructure containing the compressed image data.
isLoadingDeferredIf 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
iThe index of the texture to set mipmapping for
valThe 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
iThe texture index to load the texture into.
filenameThe filename to set.
optionsImage load options (e.g. reverse alpha).
glTexCompressThe GlTextureCompression setting for the new Image.
allowNPOTIf the image is allowed to be non-power of two (NPOT).
isLoadingDeferredIf 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
iThe texture index to load the texture into.
imageAn 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
iThe texture index to load the texture into.
entryImage 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
callbackA function accepting whether the texture was added/modified(true) or removed(false), the index of it, and the frame this palette belongs to.
owningFrameThe 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
iThe 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
iThe 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
iThe 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
iThe 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
iThe index to get the filename from
filenameThe filename to set

◆ TextureHeight()

int TextureHeight ( int  i)

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

Parameters
iThe 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
iThe 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
iThe 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
iThe 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
iThe 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
iThe index of the texture
val

◆ Width()

int Width ( int  i)

Returns the width of the texture image in pixels

Parameters
iThe index of the texture to get the width of
Returns
The width of the texture image in pixels

Member Data Documentation

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