GL Studio C++ Runtime API
TexturePalette Class Reference

#include <texture_palette.h>

Classes

class  DistiAttributeTexturePalette
 
class  DistiAttributeTexturePalette_V21
 

Public Member Functions

 TexturePalette (int size=0)
 
void PaletteSize (int newSize)
 
TexturePaletteEntryEntry (int i)
 
unsigned int size (void) const
 
void InvalidateTextures (void)
 
int FindAvailableSlot (void)
 
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 SetTexture (int i, TexturePaletteEntry *entry)
 
bool SetTexture (int i, Image *image)
 
bool SetInlineTexture (int i, glsInlineImage &image)
 
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, false > 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 ( int  size = 0)

Create a new texture palette with the indicated number of entries

Parameters
sizeThe number of entries in the palette

Member Function Documentation

bool AllowNPOT ( int  i)
Returns
True if the image is allowed to be non power of two
Parameters
iThe index of the texture
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
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
glsImageCodec Codec ( int  i)
Returns
CODEC that will be used to compress an inline image
Parameters
iThe index of the texture
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
long CompressedSize ( int  i)
Returns
Size of image when compressed with currently set inline CODEC
Parameters
iThe index of the texture
void CompressedSize ( int  i,
long  val 
)

Set Size of image when compressed with currently set inline CODEC

Parameters
iThe index of the texture
val
int CompressionFactor ( int  i)
Returns
Compression factor of the image, used only for JPEG
Parameters
iThe index of the texture
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
void DeleteTexture ( int  i)

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

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

TexturePaletteEntry* Entry ( int  i)

Returns the texture palette entry at index i

int FindAvailableSlot ( void  )

Finds an unused slot in the texture palette.

Returns
The index of the first unused slot in the palette.
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
bool GenerateInline ( int  i)
Returns
True if the image is to be generated as inline code
Parameters
iThe index of the texture
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
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
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
void InvalidateTextures ( void  )

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

void PaletteSize ( int  newSize)

Resize texture palette with the indicated number of entries

Parameters
newSizeThe new number of entries in the palette
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
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
bool SetInlineTexture ( int  i,
glsInlineImage image 
)

Sets the texture at the given index

Parameters
iThe index to insert at
imageStructure containing the compressed image data
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
bool SetTexture ( int  i,
const char *  filename,
const Image::LoadOptions options = Image::LoadOptions(),
bool  glTexCompress = false,
bool  allowNPOT = 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)
Returns
TRUE if successful else FALSE
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
entryImage generation options, NULL if not setting them
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
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.
unsigned int size ( void  ) const

Gets the size of the texture palette

Returns
The size of the texture palette
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.
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
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
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
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
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_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
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
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
bool UseGLTextureCompression ( int  i)
Returns
True if the image is to be generated to use OpenGL texture compression
Parameters
iThe index of the texture
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
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

A dynamic array of TexturePaletteEntry


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