From de8c678961226d0a7eb1f1276e8f5e842a33c3af Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 3 May 2018 01:11:39 -0700 Subject: *: initial commit derived from whale stage code This code was used in whale [1], and prior to that was used in a smaller project called mal. Since I seemed to be doing a lot of reusing and building upon this, it seemed prudent to just stick it in a repo as a .a I could submodule in future SDL2 art projects. There are some kludges in this code currently, which will be fixed up in time. --- src/stage.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/stage.h (limited to 'src/stage.h') diff --git a/src/stage.h b/src/stage.h new file mode 100644 index 0000000..05ee3ec --- /dev/null +++ b/src/stage.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2018 Vito Caputo - + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3 as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _STAGE_H +#define _STAGE_H + +#include + +#define STAGE_NODE_NAME_MAX 16 +#define STAGE_LAYERS_MAX 10 + +typedef struct aabb_t aabb_t; +typedef struct stage_t stage_t; +typedef struct stage_node_t stage_node_t; + +typedef int (*stage_render_func_t)(SDL_Renderer *renderer, void *object, int width, int height, SDL_Texture **texture); +typedef void (*stage_free_func_t)(void *object); + +stage_t * stage_new(SDL_Renderer *renderer, float aspect_ratio); +void stage_clear(stage_t *stage); +stage_t * stage_free(stage_t *stage); +void stage_fit(const stage_t *stage, int width, int height, int *res_width, int *res_height); +void stage_render(stage_t *stage); +stage_node_t * stage_node_new(stage_t *stage, int layer, const char *name, void *object, stage_render_func_t render_func, stage_free_func_t free_func); + +void stage_get_output_size(stage_t *stage, int *res_width, int *res_height); +void stage_node_set_object(const stage_t *stage, stage_node_t *node, void *object); +void stage_node_get_object(const stage_t *stage, stage_node_t *node, void **res_object); +void stage_node_replace(const stage_t *stage, stage_node_t *node, const char *name, void *object, stage_render_func_t render_func, stage_free_func_t free_func); +stage_node_t * stage_node_free(stage_t *stage, stage_node_t *node); +void stage_node_set_alpha(const stage_t *stage, stage_node_t *node, float alpha); +void stage_node_set_aabb(const stage_t *stage, stage_node_t *node, const aabb_t *aabb); +void stage_node_get_aabb(const stage_t *stage, stage_node_t *node, aabb_t *res_aabb); +void stage_node_set_active(const stage_t *stage, stage_node_t *node); +void stage_node_set_inactive(const stage_t *stage, stage_node_t *node); +void stage_node_set_locked(const stage_t *stage, stage_node_t *node); +void stage_node_set_unlocked(const stage_t *stage, stage_node_t *node); +void stage_node_set_layer(stage_t *stage, stage_node_t *node, int layer); +void stage_node_set_angle(const stage_t *stage, stage_node_t *node, double angle); +void stage_node_get_angle(const stage_t *stage, stage_node_t *node, double *res_angle); +stage_node_t * stage_node_lookup_name(const stage_t *stage, const char *name); +stage_node_t * stage_node_lookup_cartesian(const stage_t *stage, int x, int y); + +#endif -- cgit v1.2.3