diff options
| author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-10 00:54:00 -0700 | 
|---|---|---|
| committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-10 14:18:28 -0700 | 
| commit | 7eceed2d2f8b99d8300ae828cb942f44f6351b03 (patch) | |
| tree | 152e314a03d003833ee9d53acecce0ad2e21ad48 /src | |
| parent | 7c359879af46c63d93ad9190a18da04bbeb492bb (diff) | |
libstage: add pass-thru pointer to stage_render()
It's common to need access to some rendering context from the
per-stage render functions, this simply plumbs an opaque pointer
from stage_render() down to the render functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/stage.c | 10 | ||||
| -rw-r--r-- | src/stage.h | 4 | 
2 files changed, 7 insertions, 7 deletions
| diff --git a/src/stage.c b/src/stage.c index a2c6e2d..44a0378 100644 --- a/src/stage.c +++ b/src/stage.c @@ -254,14 +254,14 @@ void stage_clear(stage_t *stage)  } -static void _render_stage(const stage_t *stage, float alpha) +static void _render_stage(const stage_t *stage, float alpha, void *render_ctxt)  {  	float	a = alpha * stage->alpha;  	assert(stage);  	if (stage->render) -		stage->render(stage, stage->object, a); +		stage->render(stage, stage->object, a, render_ctxt);  	for (int i = 0; i < STAGE_LAYERS_MAX; i++) {  		stage_t	*s; @@ -270,21 +270,21 @@ static void _render_stage(const stage_t *stage, float alpha)  			if (!s->active)  				continue; -			_render_stage(s, a); +			_render_stage(s, a, render_ctxt);  		}  	}  }  /* recursively render the supplied stage tree, skipping inactive branches */ -void stage_render(const stage_t *stage) +void stage_render(const stage_t *stage, void *render_ctxt)  {  	assert(stage);  	if (!stage->active)  		return; -	_render_stage(stage, 1.f); +	_render_stage(stage, 1.f, render_ctxt);  } diff --git a/src/stage.h b/src/stage.h index 31f134a..5416af6 100644 --- a/src/stage.h +++ b/src/stage.h @@ -22,14 +22,14 @@  typedef struct stage_t stage_t; -typedef void (stage_render_func_t)(const stage_t *stage, void *object, float alpha); +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 int (stage_match_func_t)(const stage_t *stage, void *object, void *key);  stage_t * stage_new(stage_t *parent, int layer, const char *name, void *object, stage_render_func_t *render_func, stage_free_func_t *free_func, stage_match_func_t *match_func);  void stage_replace(stage_t *stage, const char *name, void *object, stage_render_func_t *render_func, stage_free_func_t *free_func, stage_match_func_t *match_func);  stage_t * stage_free(stage_t *stage); -void stage_render(const stage_t *stage); +void stage_render(const stage_t *stage, void *render_ctxt);  void stage_clear(stage_t *stage);  void stage_set_object(stage_t *stage, void *object);  void * stage_get_object(const stage_t *stage); | 
