diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2016-04-02 15:56:38 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2016-04-02 15:56:38 +0200 |
commit | e40ab41ae226e257d57a73c69d9bdd8d19f64cb5 (patch) | |
tree | 9f2e4af0f58b6db4ae850939999c642357301003 /src/renderer.c | |
parent | f8420e0a46e1069220dcd642bca30c3fcb8c1b91 (diff) |
Better UI (E/H switching).
Diffstat (limited to 'src/renderer.c')
-rw-r--r-- | src/renderer.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/src/renderer.c b/src/renderer.c index fb1647b..eee6e6d 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -359,39 +359,37 @@ void r_xsection_destroy(r_xsection *xsection) SDL_DestroyTexture(xsection->texture); } -int r_xsection_update(r_window *rw, r_xsection *xsection, - phy_field_info *fi, float *field, int64_t frame_index, - r_xsection_type type, float frac) +int r_xsection_update(r_window *rw, r_xsection *xsection, phy_sim *sim, + int flags, float frac) { + phy_field_info *fi = &sim->field_info; + float *field; size_t width, height, x, y, z; uint8_t *pixels; int pitch; if (xsection->frame_index && - xsection->frame_index == frame_index && - xsection->last_frac == frac && - xsection->last_type == type) + xsection->frame_index == sim->frame_index && + xsection->last_flags == flags && + xsection->last_frac == frac) return 0; // nothing's changed - printf("r_xsection_update: tick %ld\n", frame_index); - - switch (type) { - case XSECTION_XY: + if (flags & XSECTION_XY) { width = fi->width; height = fi->height; - break; - - case XSECTION_XZ: + } else if (flags & XSECTION_XZ) { width = fi->width; height = fi->depth; - break; - - case XSECTION_YZ: + } else { width = fi->height; height = fi->depth; - break; } + if (flags & XSECTION_E) + field = sim->fields[1].E; + else + field = sim->fields[1].H; + if (frac < 0.0f) frac = 0.0f; else if (frac > 1.0f) @@ -404,8 +402,7 @@ int r_xsection_update(r_window *rw, r_xsection *xsection, SDL_LockTexture(xsection->texture, NULL, (void**)&pixels, &pitch); - switch (type) { - case XSECTION_XY: + if (flags & XSECTION_XY) { z = frac * fi->depth; if (z >= fi->depth) z = fi->depth - 1; @@ -423,9 +420,7 @@ int r_xsection_update(r_window *rw, r_xsection *xsection, pixel[1] = r_float_to_u8(point[1]); pixel[2] = r_float_to_u8(point[2]); } - break; - - case XSECTION_XZ: + } else if (flags & XSECTION_XZ) { y = frac * fi->height; if (y >= fi->height) y = fi->height - 1; @@ -443,9 +438,7 @@ int r_xsection_update(r_window *rw, r_xsection *xsection, pixel[1] = r_float_to_u8(point[1]); pixel[2] = r_float_to_u8(point[2]); } - break; - - case XSECTION_YZ: + } else { x = frac * fi->width; if (x >= fi->width) x = fi->width - 1; @@ -463,16 +456,15 @@ int r_xsection_update(r_window *rw, r_xsection *xsection, pixel[1] = r_float_to_u8(point[1]); pixel[2] = r_float_to_u8(point[2]); } - break; } SDL_UnlockTexture(xsection->texture); xsection->aspect_ratio = (float)width / height; + xsection->last_flags = flags; xsection->last_frac = frac; - xsection->last_type = type; - xsection->frame_index = frame_index; + xsection->frame_index = sim->frame_index; return 0; } |