- Overview
- Files
- Related Pages
- Modules

- File List
- Globals

tanvastouch.h
Go to the documentation of this file.
1 /***************************************************************************************************
2 *
3 * Tanvas, Inc
4 * https://tanvas.co
5 *
6 * Copyright(c) 2019. All Rights Reserved
7 *
8 * Source code from Tanvas is supplied under the terms of a license agreement
9 * and may not be copied or disclosed except in accordance with the terms of that agreement.
10 * The various license agreements may be found at the Tanvas web site.
11 *
12 **************************************************************************************************/
13
14 #ifndef TANVAS_TANVASTOUCH_H
15 #define TANVAS_TANVASTOUCH_H
16
116 #include <stdbool.h>
117 #include <stddef.h>
118 #include <stdint.h>
119 #include <tanvas/tanvastouch_errors.h>
120
121 #ifdef __cplusplus
122 extern "C" {
123 #endif
124
125 #if defined(TANVASTOUCH_STATIC)
126 #define TANVASTOUCH_API
127 #else
128 #if defined(TANVASTOUCH_EXPORTS_DLL)
129 #ifdef _WIN32
130 #define TANVASTOUCH_API __declspec(dllexport)
131 #elif defined(__GNUC__)
132 #define TANVASTOUCH_API __attribute__((visibility("default")))
133 #else
134 #error "Don't know the convention for exporting symbols from a DLL/shared object"
135 #endif
136 #else
137 #ifdef _WIN32
138 #define TANVASTOUCH_API __declspec(dllimport)
139 #elif defined(__GNUC__)
140 #define TANVASTOUCH_API
141 #else
142 #error "Don't know the convention for importing symbols from a DLL/shared object"
143 #endif
144 #endif
145 #endif
146
158 typedef struct tanvastouch_ctx tanvastouch_ctx;
159
167 typedef uint64_t tanvastouch_resource_id;
168
179 TANVASTOUCH_API const char* tanvastouch_strerror(int err);
180
191 TANVASTOUCH_API bool tanvastouch_is_valid(tanvastouch_resource_id id);
192
251 TANVASTOUCH_API int tanvastouch_open(const char* engine_name, tanvastouch_ctx** p_ctx);
252
260 TANVASTOUCH_API int tanvastouch_close(tanvastouch_ctx* ctx);
261
269 typedef void (*tanvastouch_log_cb)(void* data, const char* str);
270
289 TANVASTOUCH_API tanvastouch_log_cb tanvastouch_set_log_cb(tanvastouch_ctx* ctx,
290 tanvastouch_log_cb cb, void* data);
291
311 TANVASTOUCH_API int tanvastouch_create_view(tanvastouch_ctx* ctx,
312 tanvastouch_resource_id* p_view_id);
313
324 TANVASTOUCH_API int tanvastouch_destroy_view(tanvastouch_ctx* ctx, tanvastouch_resource_id view_id);
325
334 TANVASTOUCH_API int tanvastouch_set_view_enabled(tanvastouch_ctx* ctx,
335 tanvastouch_resource_id view_id, bool enabled);
336
346 TANVASTOUCH_API int tanvastouch_is_view_enabled(tanvastouch_ctx* ctx,
347 tanvastouch_resource_id view_id, bool* p_enabled);
348
364 TANVASTOUCH_API int tanvastouch_set_view_position_on_desktop(tanvastouch_ctx* ctx,
365 tanvastouch_resource_id view_id,
366 float x, float y);
367
378 TANVASTOUCH_API int tanvastouch_get_view_position(tanvastouch_ctx* ctx,
379 tanvastouch_resource_id view_id, float* p_x,
380 float* p_y);
381
396 TANVASTOUCH_API int tanvastouch_set_view_size(tanvastouch_ctx* ctx, tanvastouch_resource_id view_id,
397 int width, int height);
398
410 TANVASTOUCH_API int tanvastouch_get_view_size(tanvastouch_ctx* ctx, tanvastouch_resource_id view_id,
411 int* p_width, int* p_height);
412
435 TANVASTOUCH_API int tanvastouch_add_sprite(tanvastouch_ctx* ctx, tanvastouch_resource_id view_id,
436 tanvastouch_resource_id sprite_id);
437
446 TANVASTOUCH_API int tanvastouch_remove_sprite(tanvastouch_ctx* ctx, tanvastouch_resource_id view_id,
447 tanvastouch_resource_id sprite_id);
448
459 TANVASTOUCH_API int tanvastouch_contains_sprite(tanvastouch_ctx* ctx,
460 tanvastouch_resource_id view_id,
461 tanvastouch_resource_id sprite_id,
462 bool* p_contains);
463
473 TANVASTOUCH_API int tanvastouch_get_sprite_count(tanvastouch_ctx* ctx,
474 tanvastouch_resource_id view_id, int* p_count);
475
491 TANVASTOUCH_API int tanvastouch_create_sprite(tanvastouch_ctx* ctx,
492 tanvastouch_resource_id* p_sprite_id);
493
506 TANVASTOUCH_API int tanvastouch_destroy_sprite(tanvastouch_ctx* ctx,
507 tanvastouch_resource_id sprite_id);
508
518 TANVASTOUCH_API int tanvastouch_set_sprite_enabled(tanvastouch_ctx* ctx,
519 tanvastouch_resource_id sprite_id, bool enabled);
520
530 TANVASTOUCH_API int tanvastouch_is_sprite_enabled(tanvastouch_ctx* ctx,
531 tanvastouch_resource_id sprite_id,
532 bool* p_enabled);
533
547 TANVASTOUCH_API int tanvastouch_set_sprite_position(tanvastouch_ctx* ctx,
548 tanvastouch_resource_id sprite_id, float x,
549 float y);
550
562 TANVASTOUCH_API int tanvastouch_get_sprite_position(tanvastouch_ctx* ctx,
563 tanvastouch_resource_id sprite_id, float* p_x,
564 float* p_y);
565
576 TANVASTOUCH_API int tanvastouch_set_sprite_size(tanvastouch_ctx* ctx,
577 tanvastouch_resource_id sprite_id, int width,
578 int height);
579
591 TANVASTOUCH_API int tanvastouch_get_sprite_size(tanvastouch_ctx* ctx,
592 tanvastouch_resource_id sprite_id, int* p_width,
593 int* p_height);
594
609 TANVASTOUCH_API int tanvastouch_set_sprite_rotation(tanvastouch_ctx* ctx,
610 tanvastouch_resource_id sprite_id, float theta,
611 float pivot_x, float pivot_y);
612
623 TANVASTOUCH_API int tanvastouch_get_sprite_theta(tanvastouch_ctx* ctx,
624 tanvastouch_resource_id sprite_id, float* p_theta);
625
638 TANVASTOUCH_API int tanvastouch_get_sprite_pivot(tanvastouch_ctx* ctx,
639 tanvastouch_resource_id sprite_id,
640 float* p_pivot_x, float* p_pivot_y);
641
650 TANVASTOUCH_API int tanvastouch_set_sprite_material(tanvastouch_ctx* ctx,
651 tanvastouch_resource_id sprite_id,
652 tanvastouch_resource_id material_id);
653
663 TANVASTOUCH_API int tanvastouch_get_sprite_material(tanvastouch_ctx* ctx,
664 tanvastouch_resource_id sprite_id,
665 tanvastouch_resource_id* p_material_id);
666
677 TANVASTOUCH_API int tanvastouch_remove_sprite_material(tanvastouch_ctx* ctx,
678 tanvastouch_resource_id sprite_id);
679
690 TANVASTOUCH_API int tanvastouch_set_sprite_depth(tanvastouch_ctx* ctx,
691 tanvastouch_resource_id sprite_id, float depth);
692
702 TANVASTOUCH_API int tanvastouch_get_sprite_depth(tanvastouch_ctx* ctx,
703 tanvastouch_resource_id sprite_id, float* p_depth);
704
728 TANVASTOUCH_API int tanvastouch_create_material(tanvastouch_ctx* ctx,
729 tanvastouch_resource_id* p_material_id);
730
741 TANVASTOUCH_API int tanvastouch_destroy_material(tanvastouch_ctx* ctx,
742 tanvastouch_resource_id material_id);
743
759 TANVASTOUCH_API int tanvastouch_add_material_texture(tanvastouch_ctx* ctx,
760 tanvastouch_resource_id material_id, int index,
761 tanvastouch_resource_id texture_id);
762
775 TANVASTOUCH_API int tanvastouch_remove_material_texture(tanvastouch_ctx* ctx,
776 tanvastouch_resource_id material_id,
777 int index);
778
791 TANVASTOUCH_API int tanvastouch_get_material_texture(tanvastouch_ctx* ctx,
792 tanvastouch_resource_id material_id, int index,
793 tanvastouch_resource_id* p_texture_id);
794
820 TANVASTOUCH_API int tanvastouch_set_material_uv(tanvastouch_ctx* ctx,
821 tanvastouch_resource_id material_id, int index,
822 float* p_uv);
823
837 TANVASTOUCH_API int tanvastouch_get_material_uv(tanvastouch_ctx* ctx,
838 tanvastouch_resource_id material_id, int index,
839 float* p_uv);
840
844 enum tanvastouch_wrap_mode_e {
848 tanvastouch_wrap_mode_clamp = 0,
849
853 tanvastouch_wrap_mode_tile = 1,
854 };
855
856 typedef enum tanvastouch_wrap_mode_e tanvastouch_wrap_mode;
857
867 TANVASTOUCH_API int tanvastouch_set_material_wrapping_mode(tanvastouch_ctx* ctx,
868 tanvastouch_resource_id material_id,
869 int index, int mode);
870
880 TANVASTOUCH_API int tanvastouch_get_material_wrapping_mode(tanvastouch_ctx* ctx,
881 tanvastouch_resource_id material_id,
882 int index, int* p_mode);
883
901 TANVASTOUCH_API int tanvastouch_create_texture(tanvastouch_ctx* ctx,
902 tanvastouch_resource_id* p_texture_id);
903
912 TANVASTOUCH_API int tanvastouch_destroy_texture(tanvastouch_ctx* ctx,
913 tanvastouch_resource_id texture_id);
914
932 TANVASTOUCH_API int tanvastouch_set_texture_data(tanvastouch_ctx* ctx,
933 tanvastouch_resource_id texture_id,
934 const unsigned char* p_data, int width,
935 int height);
936
949 TANVASTOUCH_API int tanvastouch_get_texture_size(tanvastouch_ctx* ctx,
950 tanvastouch_resource_id texture_id, int* p_width,
951 int* p_height);
952
963 TANVASTOUCH_API int tanvastouch_set_texture_data_partial(tanvastouch_ctx* ctx,
964 tanvastouch_resource_id texture_id,
965 const unsigned char* p_data,
966 uint32_t length, uint32_t offset);
967
979 TANVASTOUCH_API int tanvastouch_get_texture_data_size(tanvastouch_ctx* ctx,
980 tanvastouch_resource_id texture_id,
981 uint32_t* p_size);
982
985 #ifdef __cplusplus
986 } /* extern "C" */
987 #endif
988
989 #endif /* TANVAS_TANVASTOUCH_H */
tanvastouch_wrap_mode
enum tanvastouch_wrap_mode_e tanvastouch_wrap_mode
Definition: tanvastouch.h:855
tanvastouch_get_material_wrapping_mode
TANVASTOUCH_API int tanvastouch_get_material_wrapping_mode(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index, int *p_mode)
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)
tanvastouch_set_sprite_enabled
TANVASTOUCH_API int tanvastouch_set_sprite_enabled(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, bool enabled)
tanvastouch_get_sprite_material
TANVASTOUCH_API int tanvastouch_get_sprite_material(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, tanvastouch_resource_id *p_material_id)
tanvastouch_remove_sprite_material
TANVASTOUCH_API int tanvastouch_remove_sprite_material(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id)
tanvastouch_close
TANVASTOUCH_API int tanvastouch_close(tanvastouch_ctx *ctx)
tanvastouch_get_sprite_position
TANVASTOUCH_API int tanvastouch_get_sprite_position(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_x, float *p_y)
tanvastouch_is_view_enabled
TANVASTOUCH_API int tanvastouch_is_view_enabled(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, bool *p_enabled)
tanvastouch_destroy_texture
TANVASTOUCH_API int tanvastouch_destroy_texture(tanvastouch_ctx *ctx, tanvastouch_resource_id texture_id)
tanvastouch_get_sprite_theta
TANVASTOUCH_API int tanvastouch_get_sprite_theta(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_theta)
tanvastouch_ctx
struct tanvastouch_ctx tanvastouch_ctx
Definition: tanvastouch.h:157
tanvastouch_resource_id
uint64_t tanvastouch_resource_id
Definition: tanvastouch.h:166
tanvastouch_create_material
TANVASTOUCH_API int tanvastouch_create_material(tanvastouch_ctx *ctx, tanvastouch_resource_id *p_material_id)
tanvastouch_set_sprite_position
TANVASTOUCH_API int tanvastouch_set_sprite_position(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float x, float y)
tanvastouch_remove_sprite
TANVASTOUCH_API int tanvastouch_remove_sprite(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, tanvastouch_resource_id sprite_id)
tanvastouch_get_view_size
TANVASTOUCH_API int tanvastouch_get_view_size(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, int *p_width, int *p_height)
tanvastouch_set_material_uv
TANVASTOUCH_API int tanvastouch_set_material_uv(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index, float *p_uv)
tanvastouch_log_cb
void(* tanvastouch_log_cb)(void *data, const char *str)
Definition: tanvastouch.h:268
tanvastouch_get_sprite_count
TANVASTOUCH_API int tanvastouch_get_sprite_count(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, int *p_count)
tanvastouch_add_material_texture
TANVASTOUCH_API int tanvastouch_add_material_texture(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index, tanvastouch_resource_id texture_id)
tanvastouch_create_texture
TANVASTOUCH_API int tanvastouch_create_texture(tanvastouch_ctx *ctx, tanvastouch_resource_id *p_texture_id)
tanvastouch_open
TANVASTOUCH_API int tanvastouch_open(const char *engine_name, tanvastouch_ctx **p_ctx)
tanvastouch_set_sprite_material
TANVASTOUCH_API int tanvastouch_set_sprite_material(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, tanvastouch_resource_id material_id)
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)
tanvastouch_create_sprite
TANVASTOUCH_API int tanvastouch_create_sprite(tanvastouch_ctx *ctx, tanvastouch_resource_id *p_sprite_id)
tanvastouch_wrap_mode_tile
Definition: tanvastouch.h:852
tanvastouch_get_material_texture
TANVASTOUCH_API int tanvastouch_get_material_texture(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index, tanvastouch_resource_id *p_texture_id)
tanvastouch_set_material_wrapping_mode
TANVASTOUCH_API int tanvastouch_set_material_wrapping_mode(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index, int mode)
tanvastouch_destroy_view
TANVASTOUCH_API int tanvastouch_destroy_view(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id)
tanvastouch_contains_sprite
TANVASTOUCH_API int tanvastouch_contains_sprite(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, tanvastouch_resource_id sprite_id, bool *p_contains)
tanvastouch_get_sprite_pivot
TANVASTOUCH_API int tanvastouch_get_sprite_pivot(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_pivot_x, float *p_pivot_y)
tanvastouch_add_sprite
TANVASTOUCH_API int tanvastouch_add_sprite(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, tanvastouch_resource_id sprite_id)
tanvastouch_errors.h
Status codes used in the TanvasTouch Engine API.
tanvastouch_get_sprite_depth
TANVASTOUCH_API int tanvastouch_get_sprite_depth(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_depth)
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)
tanvastouch_destroy_sprite
TANVASTOUCH_API int tanvastouch_destroy_sprite(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id)
tanvastouch_create_view
TANVASTOUCH_API int tanvastouch_create_view(tanvastouch_ctx *ctx, tanvastouch_resource_id *p_view_id)
tanvastouch_set_sprite_rotation
TANVASTOUCH_API int tanvastouch_set_sprite_rotation(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float theta, float pivot_x, float pivot_y)
tanvastouch_strerror
const TANVASTOUCH_API char * tanvastouch_strerror(int err)
tanvastouch_set_view_size
TANVASTOUCH_API int tanvastouch_set_view_size(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, int width, int height)
tanvastouch_get_sprite_size
TANVASTOUCH_API int tanvastouch_get_sprite_size(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, int *p_width, int *p_height)
tanvastouch_set_view_position_on_desktop
TANVASTOUCH_API int tanvastouch_set_view_position_on_desktop(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, float x, float y)
tanvastouch_get_view_position
TANVASTOUCH_API int tanvastouch_get_view_position(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, float *p_x, float *p_y)
tanvastouch_set_view_enabled
TANVASTOUCH_API int tanvastouch_set_view_enabled(tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, bool enabled)
tanvastouch_remove_material_texture
TANVASTOUCH_API int tanvastouch_remove_material_texture(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index)
tanvastouch_set_log_cb
TANVASTOUCH_API tanvastouch_log_cb tanvastouch_set_log_cb(tanvastouch_ctx *ctx, tanvastouch_log_cb cb, void *data)
tanvastouch_set_sprite_depth
TANVASTOUCH_API int tanvastouch_set_sprite_depth(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float depth)
tanvastouch_wrap_mode_clamp
Definition: tanvastouch.h:847
tanvastouch_set_sprite_size
TANVASTOUCH_API int tanvastouch_set_sprite_size(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, int width, int height)
tanvastouch_destroy_material
TANVASTOUCH_API int tanvastouch_destroy_material(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id)
tanvastouch_is_valid
TANVASTOUCH_API bool tanvastouch_is_valid(tanvastouch_resource_id id)
tanvastouch_get_material_uv
TANVASTOUCH_API int tanvastouch_get_material_uv(tanvastouch_ctx *ctx, tanvastouch_resource_id material_id, int index, float *p_uv)
tanvastouch_wrap_mode_e
tanvastouch_wrap_mode_e
Definition: tanvastouch.h:843
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)
tanvastouch_is_sprite_enabled
TANVASTOUCH_API int tanvastouch_is_sprite_enabled(tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, bool *p_enabled)