erebus

changeset 15:20d6c05529f1

debugging the sphere problem
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 25 May 2014 02:00:07 +0300
parents f97dd1877f5f
children d2b6cee8ea5c
files liberebus/src/erebus.cc src/main.cc
diffstat 2 files changed, 52 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/liberebus/src/erebus.cc	Sat May 24 21:56:04 2014 +0300
     1.2 +++ b/liberebus/src/erebus.cc	Sun May 25 02:00:07 2014 +0300
     1.3 @@ -39,6 +39,9 @@
     1.4  	std::vector<bool> keystate;
     1.5  	std::vector<bool> bnstate;
     1.6  	int mouse_pos[2];
     1.7 +
     1.8 +	// debugging stuff
     1.9 +	int dbg_nodesel;
    1.10  };
    1.11  
    1.12  static void render_pixel(struct erebus *ctx, int x, int y, int sample);
    1.13 @@ -64,6 +67,8 @@
    1.14  	ctx->cur_rect = INVALID_RECT;
    1.15  
    1.16  	ctx->options[ERB_OPT_MAX_SAMPLES].x = (float)INF_SAMPLES;
    1.17 +
    1.18 +	ctx->dbg_nodesel = -1;
    1.19  	return ctx;
    1.20  }
    1.21  
    1.22 @@ -115,6 +120,8 @@
    1.23  
    1.24  	ctx->fbimg.create(xsz, ysz);
    1.25  	ctx->accum.create(xsz, ysz);
    1.26 +
    1.27 +	ctx->cur_rect = INVALID_RECT;
    1.28  }
    1.29  
    1.30  int erb_render(struct erebus *ctx, long timeout)
    1.31 @@ -215,14 +222,54 @@
    1.32  bool erb_input_keyboard(struct erebus *ctx, int key, bool pressed)
    1.33  {
    1.34  	if(!ctx) return false;
    1.35 -	if(ctx->keystate.size() <= key) ctx->keystate.resize(key < 256 ? 256 : key + 1);
    1.36 +	if((int)ctx->keystate.size() <= key) {
    1.37 +		ctx->keystate.resize(key < 256 ? 256 : key + 1);
    1.38 +	}
    1.39  
    1.40  	ctx->keystate[key] = pressed;
    1.41  
    1.42  	if(pressed) {
    1.43  		switch(key) {
    1.44 +		case '.':
    1.45 +			{
    1.46 +				int node_count = ctx->scn->get_node_count();
    1.47 +				if(node_count && ++ctx->dbg_nodesel >= node_count) {
    1.48 +					ctx->dbg_nodesel = 0;
    1.49 +				}
    1.50 +				printf("selected node: %d\n", ctx->dbg_nodesel);
    1.51 +			}
    1.52 +			break;
    1.53 +
    1.54 +		case ',':
    1.55 +			{
    1.56 +				int node_count = ctx->scn->get_node_count();
    1.57 +				if(node_count && --ctx->dbg_nodesel < 0) {
    1.58 +					ctx->dbg_nodesel = node_count - 1;
    1.59 +				}
    1.60 +				printf("selected node: %d\n", ctx->dbg_nodesel);
    1.61 +			}
    1.62 +			break;
    1.63 +
    1.64  		case '=':
    1.65  		case '-':
    1.66 +		case '0':
    1.67 +			if(ctx->dbg_nodesel != -1) {
    1.68 +				SceneNode *node = ctx->scn->get_node(ctx->dbg_nodesel);
    1.69 +				Vector3 s = node->get_scaling();
    1.70 +				switch(key) {
    1.71 +				case '=':
    1.72 +					node->set_scaling(s * 1.1);
    1.73 +					break;
    1.74 +				case '-':
    1.75 +					node->set_scaling(s * 0.9);
    1.76 +					break;
    1.77 +				case '0':
    1.78 +					node->set_scaling(Vector3(1, 1, 1));
    1.79 +					break;
    1.80 +				}
    1.81 +			}
    1.82 +			erb_begin_frame(ctx, 0);
    1.83 +			return true;
    1.84  		}
    1.85  	}
    1.86  	return false;
    1.87 @@ -231,7 +278,9 @@
    1.88  bool erb_input_mouse_button(struct erebus *ctx, int bn, bool pressed, int x, int y)
    1.89  {
    1.90  	if(!ctx) return false;
    1.91 -	if(ctx->bnstate.size() <= bn) ctx->bnstate.resize(bn < 32 ? 32 : bn + 1);
    1.92 +	if((int)ctx->bnstate.size() <= bn) {
    1.93 +		ctx->bnstate.resize(bn < 32 ? 32 : bn + 1);
    1.94 +	}
    1.95  
    1.96  	ctx->bnstate[bn] = pressed;
    1.97  	ctx->mouse_pos[0] = x;
     2.1 --- a/src/main.cc	Sat May 24 21:56:04 2014 +0300
     2.2 +++ b/src/main.cc	Sun May 25 02:00:07 2014 +0300
     2.3 @@ -199,7 +199,7 @@
     2.4  
     2.5  static void motion(int x, int y)
     2.6  {
     2.7 -	if(erb_input_mouse_move(erb, x, y)) {
     2.8 +	if(erb_input_mouse_motion(erb, x, y)) {
     2.9  		glutPostRedisplay();
    2.10  	}
    2.11  }