erebus

diff liberebus/src/erebus.cc @ 40:9d6368850fe1

minor enhancements and bugfixes to the console stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 10 Jun 2014 10:53:19 +0300
parents 5e27c85e79ca
children ed18af9da8f7
line diff
     1.1 --- a/liberebus/src/erebus.cc	Mon Jun 09 23:57:24 2014 +0300
     1.2 +++ b/liberebus/src/erebus.cc	Tue Jun 10 10:53:19 2014 +0300
     1.3 @@ -37,6 +37,7 @@
     1.4  
     1.5  	rnd_gen.seed(time(0));
     1.6  
     1.7 +	ctx->rendering = false;
     1.8  	ctx->scn = 0;
     1.9  	ctx->cur_time = 0;
    1.10  	ctx->cur_frame = 0;
    1.11 @@ -60,6 +61,12 @@
    1.12  	}
    1.13  }
    1.14  
    1.15 +void erb_clear(struct erebus *ctx)
    1.16 +{
    1.17 +	erb_end_frame(ctx);
    1.18 +	ctx->scn->clear();
    1.19 +}
    1.20 +
    1.21  void erb_setopti(struct erebus *ctx, enum erb_option opt, int val)
    1.22  {
    1.23  	ctx->options[opt].ival = val;
    1.24 @@ -158,6 +165,16 @@
    1.25  	ctx->inv_gamma = 1.0f / erb_getoptf(ctx, ERB_OPT_GAMMA);
    1.26  
    1.27  	ctx->scn->update(ctx->cur_time);
    1.28 +	ctx->rendering = true;
    1.29 +}
    1.30 +
    1.31 +void erb_end_frame(struct erebus *ctx)
    1.32 +{
    1.33 +	if(ctx->tpool) {
    1.34 +		ctx->tpool->clear_work();
    1.35 +		ctx->tpool->wait();
    1.36 +	}
    1.37 +	ctx->rendering = false;
    1.38  }
    1.39  
    1.40  int erb_render(struct erebus *ctx, long timeout)
    1.41 @@ -169,6 +186,10 @@
    1.42  
    1.43  int erb_render_rect(struct erebus *ctx, int x, int y, int width, int height, long timeout)
    1.44  {
    1.45 +	if(!ctx->rendering) {
    1.46 +		return 0;
    1.47 +	}
    1.48 +
    1.49  	while(ctx->tpool->pending()) {
    1.50  		if(timeout > 0) {
    1.51  			long wait_interval = ctx->tpool->wait(timeout);