- Overview
- Files
- Related Pages
- Modules

Macros | Functions
Textures

## Macros
#define | TANVASTOUCH_ERROR_TEXTURE (6u << 16u)
#define | TANVASTOUCH_ERROR_TEXTURE_OFFSET_TOO_LARGE TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 1u))
#define | TANVASTOUCH_ERROR_TEXTURE_SIZE_MISMATCH TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 2u))
#define | TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_WIDTH TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 3u))
#define | TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_HEIGHT TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 4u))

## Functions
TANVASTOUCH_API int | tanvastouch_create_texture (tanvastouch_ctx *ctx, tanvastouch_resource_id *p_texture_id)
TANVASTOUCH_API int | tanvastouch_destroy_texture (tanvastouch_ctx *ctx, tanvastouch_resource_id texture_id)
TANVASTOUCH_API int | tanvastouch_set_texture_data (tanvastouch_ctx *ctx, tanvastouch_resource_id texture_id, const unsigned char *p_data, int width, int height)
TANVASTOUCH_API int | tanvastouch_get_texture_size (tanvastouch_ctx *ctx, tanvastouch_resource_id texture_id, int *p_width, int *p_height)
TANVASTOUCH_API int | tanvastouch_set_texture_data_partial (tanvastouch_ctx *ctx, tanvastouch_resource_id texture_id, const unsigned char *p_data, uint32_t length, uint32_t offset)
TANVASTOUCH_API int | tanvastouch_get_texture_data_size (tanvastouch_ctx *ctx, tanvastouch_resource_id texture_id, uint32_t *p_size)

## Detailed Description

## Macro Definition Documentation

## ◆ TANVASTOUCH_ERROR_TEXTURE

#define TANVASTOUCH_ERROR_TEXTURE (6u << 16u)

Errors specific to textures.

Since
  4.0.0

## ◆ TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_HEIGHT

#define TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_HEIGHT TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 4u))

The texture has a negative height.

Since
  4.0.0

## ◆ TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_WIDTH

#define TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_WIDTH TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 3u))

The texture has a negative width.

Since
  4.0.0

## ◆ TANVASTOUCH_ERROR_TEXTURE_OFFSET_TOO_LARGE

#define TANVASTOUCH_ERROR_TEXTURE_OFFSET_TOO_LARGE TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 1u))

An offset or length used in a set_texture_data_partial call would go out-of-bounds for the given texture.

set_texture_data_partial cannot append to or remove from a texture. To change a texture's size, set new data with set_texture_data.

Since
  4.0.0

## ◆ TANVASTOUCH_ERROR_TEXTURE_SIZE_MISMATCH

#define TANVASTOUCH_ERROR_TEXTURE_SIZE_MISMATCH TANVASTOUCH_AS(int, (TANVASTOUCH_ERROR_TEXTURE | 2u))

A size mismatch was detected when sending texture data (i.e. width * height != length).

Since
  4.0.0

## Function Documentation

## ◆ tanvastouch_create_texture()

TANVASTOUCH_API int tanvastouch_create_texture | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id * | p_texture_id
| ) |  |

Create a texture.

A texture has no initial data.

See also
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  p_texture_id | Texture ID storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_destroy_texture()

TANVASTOUCH_API int tanvastouch_destroy_texture | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | texture_id
| ) |  |

Destroy a texture.

See also
  Destructors do not clear resource IDs

Parameters

  ctx | The context to use.
  texture_id | The texture to destroy.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_texture_data_size()

TANVASTOUCH_API int tanvastouch_get_texture_data_size | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | texture_id,
|  | uint32_t * | p_size
| ) |  |

Get the size of the data inside a texture.

The size is returned in bytes.

See also
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  texture_id | The texture to modify.
  p_size | Size storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_texture_size()

TANVASTOUCH_API int tanvastouch_get_texture_size | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | texture_id,
|  | int * | p_width,
|  | int * | p_height
| ) |  |

Get a texture's dimensions.

Texture dimensions are reported in pixels.

See also
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  texture_id | The texture to query.
  p_width | Width storage.
  p_height | Height storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_texture_data()

TANVASTOUCH_API int tanvastouch_set_texture_data | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | texture_id,
|  | const unsigned char * | p_data,
|  | int | width,
|  | int | height
| ) |  |

Set a texture's data.

Texture data is an array of bytes. Each byte represents a friction value, with 0 being the natural friction of the touchscreen and 255 the highest friction achievable by the hardware. The width times the height must equal the data size.

Parameters

  ctx | The context to use.
  texture_id | The texture to modify.
  p_data | The data to set.
  width | Texture width; must be non-negative.
  height | Texture height; must be non-negative.

Returns
  In addition to the resource return values (see Resource-related API call return value), this function may also return the following errors:
  - TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_WIDTH: The width is negative.
  - TANVASTOUCH_ERROR_TEXTURE_NEGATIVE_HEIGHT: The height is negative.

## ◆ tanvastouch_set_texture_data_partial()

TANVASTOUCH_API int tanvastouch_set_texture_data_partial | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | texture_id,
|  | const unsigned char * | p_data,
|  | uint32_t | length,
|  | uint32_t | offset
| ) |  |

Replace part of a texture's data with new data.

Parameters

  ctx | The context to use.
  texture_id | The texture to modify.
  p_data | The new data.
  length | The size of the new data.
  offset | The position in the existing texture data where replacement should start.

Returns
  Resource-related API call return value