Main Page | Modules | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

Texture Manager
[Drawing system.]


Detailed Description

texture manager

Author:
benjamin gerard

vincent penne


Files

file  texture.h
 texture manager


Data Structures

struct  texture_t
 Texture definition type. More...

struct  _texture_create_s
 Texture creation type. More...


Defines

#define TEXTURE_NAME_MAX   24
 Texture name maximum length.


Typedefs

typedef int texid_t
 Texture idetifier type.

typedef int(* texture_reader_f )(uint8 *buffer, int n, struct _texture_create_s *tc)
 Function to get texture data.

typedef _texture_create_s texture_create_t
 Texture creation type.


Functions

int texture_init (void)
 Initialize the texture manager.

void texture_shutdown (void)
 Shutdown the texture manager.

texid_t texture_get (const char *texture_name)
 Get a texture identifier by name.

texid_t texture_exist (texid_t texid)
 Check if a given texture id is valid.

texid_t texture_dup (texid_t texid, const char *name)
 Duplicate a texture.

texid_t texture_create (texture_create_t *creator)
 Create a new texture.

texid_t texture_create_flat (const char *name, int width, int height, unsigned int argb)
 Create a flat texture.

texid_t texture_create_file (const char *fname, const char *formatstr)
 Create a new texture from a image file.

int texture_destroy (texid_t texid, int force)
 Destroy a texture.

int texture_reference (texid_t texid, int count)
 Add, remove or get texture reference counter.

texture_ttexture_lock (texid_t texid, int wait)
 Get a pointer on a texture definition and make sure pixels are not twiddled.

texture_ttexture_fastlock (texid_t texid, int wait)
 Get a pointer on a texture definition without de-twiddling.

void texture_release (texture_t *t)
 Release a previously locked texture.

void texture_collector (void)
 Perform texture garbage colector.

const char * texture_formatstr (int format)
 Get texture format string.

int texture_strtoformat (const char *formatstr)
 Get texture format from a format string.

void texture_memstats ()
 Display statistics about the video memory.

int texture_twiddle (texture_t *t, int wanted)
 Twiddle or de-twiddle a texture as required.

int texture_twiddlable (texture_t *t)


Typedef Documentation

typedef int(* texture_reader_f)(uint8 *buffer, int n, struct _texture_create_s * tc)
 

Function to get texture data.

The texture_reader_f function is called by the texture_create() function to get the texture bitmap.


Function Documentation

void texture_shutdown void   ) 
 

Shutdown the texture manager.

The texture_shutdown() function free all texture without verifying that all textures has been released.

texid_t texture_get const char *  texture_name  ) 
 

Get a texture identifier by name.

Parameters:
texture_name texture name or filename.
Returns:
texture-id

texid_t texture_exist texid_t  texid  ) 
 

Check if a given texture id is valid.

Parameters:
texid texture-id to test.
Returns:
texid
Return values:
-1 on error (texture does nor exist).

texid_t texture_dup texid_t  texid,
const char *  name
 

Duplicate a texture.

The texture_dup() function duplicates a texture. Everything gets copied including texture bitmap.

Parameters:
texid texture-id to duplicate
name duplicated texture name
Returns:
texture-id
Return values:
-1 Error

texid_t texture_create texture_create_t creator  ) 
 

Create a new texture.

The texture_create() function creates a new texture from a texture_create_t creator. This creator contains the basic information for the new texture (name, dimension, format...) and a function which is call the reader that wiil be call to get texture bitmap. This reader function recieve the creator as parameter. Any supplemental information could be put after the required creator data such as FILE or memory pointer.

Parameters:
creator texture creator used to create this texture.
Returns:
texture-id
Return values:
-1 Error
See also:
texture_reader_f

texid_t texture_create_flat const char *  name,
int  width,
int  height,
unsigned int  argb
 

Create a flat texture.

Parameters:
name Name of texture.
width Width in pixel
height Height in pixel
argb Texture pixel format
Returns:
texture-id

-1 Error

texid_t texture_create_file const char *  fname,
const char *  formatstr
 

Create a new texture from a image file.

The texture_create_file() tries to load an file via the image translator LoadImageFile() function. And creates a texture with it.

Parameters:
fname Path of an image file.
formatstr Output format. 0 tries to keep original image one.
Returns:
texture-id

-1 Error

const char* texture_formatstr int  format  ) 
 

Get texture format string.

The function texture_formatstr() returns a string that describe a texture format. Currently it is only describes the "ARGB" pixel format. The returned string is 4 char long and each char gives the number of bit of a channel in this order Alpha, Red, Green and Blue.

Returns:
A string that describe the texture format.
Return values:
0565 16 bit: Alpha:0, Red:5, Green:6, Blue:5.
1555 16 bit: Alpha:1, Red:5, Green:5, Blue:5.
4444 16 bit: Alpha:4, Red:4, Green:4, Blue:4.
???? Unknown texture format.
See also:
texture_strtoformat()

int texture_strtoformat const char *  formatstr  ) 
 

Get texture format from a format string.

See also:
texture_formatstr()

int texture_twiddle texture_t t,
int  wanted
 

Twiddle or de-twiddle a texture as required.

The texture_twiddle() checks if the texture is twiddlable by calling the texture_twiddlable() function. If texture is twiddlable the fucntion performs neccessary operations to set the texture twiddle stat as wanted.

Parameters:
t texture
wanted 0:De-twiddle 1:Twiddle
Returns:
twiddled stat.
See also:
int texture_twiddlable();
Warning:
The returned stat is not neccessary the wanted one.


dcplaya documentation version 1.2 Generated on January 2004 by doxygen 1.3.5