summaryrefslogtreecommitdiff
path: root/src/stage.h
blob: 40f2057cbb96818aae0d277f814235cdf89eedc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 *  Copyright (C) 2018-2019 - Vito Caputo - <vcaputo@pengaru.com>
 *
 *  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 <http://www.gnu.org/licenses/>.
 */

#ifndef _STAGE_H
#define _STAGE_H

#define STAGE_NAME_MAX		16
#define STAGE_LAYERS_MAX	10

typedef struct stage_t stage_t;

typedef void (stage_prepare_func_t)(stage_t *stage, void *object, float alpha, void *render_ctxt);
typedef void (stage_render_func_t)(const stage_t *stage, void *object, float alpha, void *render_ctxt);
typedef void (stage_free_func_t)(const stage_t *stage, void *object);

typedef struct stage_ops_t {
	stage_prepare_func_t	*prepare_func;	/* pre-render object */
	stage_render_func_t	*render_func;	/* render object */
	stage_free_func_t	*free_func;	/* free object */
} stage_ops_t;

typedef struct stage_conf_t {
	stage_t			*parent, *stage;
	int			layer;
	const char		*name;
	float			alpha;
	unsigned		active:1;
	unsigned		locked:1;
	unsigned		dirty:1;
	unsigned		replace:1;
} stage_conf_t;

stage_t * stage_new(const stage_conf_t *conf, const stage_ops_t *ops, void *object);
stage_t * stage_replace(stage_t *stage, const char *name, const stage_ops_t *ops, void *object);

stage_t * stage_free(stage_t *stage);
int stage_render(stage_t *stage, void *render_ctxt);
void stage_dirty(stage_t *stage);
void stage_clear(stage_t *stage);
void stage_set_object(stage_t *stage, void *object);
void * stage_get_object(const stage_t *stage);
void stage_set_alpha(stage_t *stage, float alpha);
float stage_get_alpha(const stage_t *stage);
void stage_set_active(stage_t *stage, int active);
int stage_get_active(const stage_t *stage);
void stage_set_locked(stage_t *stage, int locked);
int stage_get_locked(const stage_t *stage);
void stage_set_layer(stage_t *stage, int layer);
stage_t * stage_lookup_name(stage_t *stage, const char *name);

#endif
© All Rights Reserved