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)
 
TexturePaletteEntryEntry (int i)
 
unsigned int size () const
 
unsigned int Count () 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 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 ( 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

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
unsigned int Count ( ) const

Gets the number of textures (whether valid or not) in this texture palette

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, expanding the palette to accomodate the index if needed.

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.

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
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,
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.
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,
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
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 ( ) const
inline

Gets the number of textures (whether valid or not) in this texture palette.

Deprecated:
Renamed to Count() to match DynamicArray.
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

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: