texture.h File Reference

#include "CrabClaw/types.h"
#include "CrabClaw/screen.h"

Data Structures

struct  cc_texture
 A platform-independent representation of an image. More...

Defines

#define CC_TXRFMT_ARGB1555   0x00000012
 ARGB1555 format flag.
#define CC_TXRFMT_ARGB4444   0x00000010
 ARGB4444 format flag.
#define CC_TXRFMT_ARGB8888   0x00000014
 ARGB8888 format flag.
#define CC_TXRFMT_RGB555   0x00000002
 RGB555 format flag.
#define CC_TXRFMT_RGB565   0x00000001
 RGB565 format flag.
#define CC_TXRFMT_RGBA4444   0x00000020
 RGBA4444 format flag.
#define CC_TXRFMT_RGBA5551   0x00000022
 RGBA5551 format flag.
#define CC_TXRFMT_RGBA8888   0x00000024
 RGBA8888 format flag.
#define CC_TXRFMT_XRGB8888   0x00000004
 XRGB8888 format flag.

Typedefs

typedef struct cc_texture cc_texture_t

Functions

int cc_texture_create (cc_texture_t *dst, uint32 width, uint32 height, const uint8 *pixels, uint32 fmt)
 Create a new texture from an array of pixels.
int cc_texture_create_subtexture (cc_texture_t *src, cc_texture_t *dst, uint32 x, uint32 y, uint32 width, uint32 height)
 Create a sub-texture.
int cc_texture_destroy (cc_texture_t *txr)
 Deallocate a texture.
int cc_texture_load_to_vram (cc_texture_t *txr)
 Load the pixel data to VRAM.
int cc_texture_unload_from_vram (cc_texture_t *txr)
 Remove pixel data from VRAM.

Define Documentation

#define CC_TXRFMT_ARGB1555   0x00000012

ARGB1555 format flag.

Since:
1.0.0

#define CC_TXRFMT_ARGB4444   0x00000010

ARGB4444 format flag.

Since:
1.0.0

#define CC_TXRFMT_ARGB8888   0x00000014

ARGB8888 format flag.

Since:
1.0.0

#define CC_TXRFMT_RGB555   0x00000002

RGB555 format flag.

Since:
1.0.0

#define CC_TXRFMT_RGB565   0x00000001

RGB565 format flag.

Since:
1.0.0

#define CC_TXRFMT_RGBA4444   0x00000020

RGBA4444 format flag.

Since:
1.0.0

#define CC_TXRFMT_RGBA5551   0x00000022

RGBA5551 format flag.

Since:
1.0.0

#define CC_TXRFMT_RGBA8888   0x00000024

RGBA8888 format flag.

Since:
1.0.0

#define CC_TXRFMT_XRGB8888   0x00000004

XRGB8888 format flag.

Since:
1.0.0


Typedef Documentation

typedef struct cc_texture cc_texture_t


Function Documentation

int cc_texture_create ( cc_texture_t dst,
uint32  width,
uint32  height,
const uint8 pixels,
uint32  fmt 
)

Create a new texture from an array of pixels.

This function creates a new cc_texture_t object from an array of pixels. The pixels are assumed to be of the given width and height, and in the given format.

Since:
1.0.0
Parameters:
dst The destination for the texture
width The width of the texture.
height The height of the texture.
pixels The pixel data.
fmt One of the constants texture format constants.
Returns:
0 on success, 1 on failure.

int cc_texture_create_subtexture ( cc_texture_t src,
cc_texture_t dst,
uint32  x,
uint32  y,
uint32  width,
uint32  height 
)

Create a sub-texture.

This function creates a new cc_texture_t object from an area of an existing one.

Since:
1.0.0
Parameters:
src The original texture.
dst The destination texture.
x The X coordinate of the upper-left corner of the region to copy.
y The Y coordinate of the upper-left corner of the region to copy.
width The number of pixels across to copy.
height The number of pixels down to copy.
Returns:
0 on success, 1 on failure

int cc_texture_destroy ( cc_texture_t txr  ) 

Deallocate a texture.

This function frees all memory and resources associated with a given cc_texture_t object.

Since:
1.0.0
Parameters:
txr The texture to deallocate.
Returns:
0 on success, 1 on failure.

int cc_texture_load_to_vram ( cc_texture_t txr  ) 

Load the pixel data to VRAM.

This function puts the pixel data of the specified texture into VRAM. This function may modify the pixel format of the data that is in VRAM, but will not change the data stored in the object.

Since:
1.0.0
Parameters:
txr The texture to load to VRAM.
Returns:
0 on success, 1 on failure.

int cc_texture_unload_from_vram ( cc_texture_t txr  ) 

Remove pixel data from VRAM.

This function takes pixel data out of VRAM, making it unable to be drawn until cc_texture_load_to_vram() is called again.

Since:
1.0.0
Parameters:
txr The texture to unload.
Returns:
0 on success, nonzero otherwise.

SourceForge.net Logo