diff options
Diffstat (limited to 'Smoke/renderer_gl.c')
-rw-r--r-- | Smoke/renderer_gl.c | 127 |
1 files changed, 108 insertions, 19 deletions
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index 8b81d46..1e06356 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -34,7 +34,7 @@ #define DEFAULT_ZOOM -750.0f #define MIN_ZOOM -100.0f #define MAX_ZOOM -4000.0f -#define DEFAULT_ZOOM_SPEED 40 +#define DEFAULT_ZOOM_SPEED 100 #define MIN_ZOOM -100.0f #define MAX_ZOOM -4000.0f @@ -56,10 +56,9 @@ float y_pos = DEFAULT_Y_POS; float z_pos = DEFAULT_ZOOM; static int renderer_render_grid = FALSE; - static int renderer_zoomspeed = DEFAULT_ZOOM_SPEED; - static GLuint texture; +static int grid_cell_size = 50; @@ -194,33 +193,45 @@ static void render_legend(void) glEnable(GL_DEPTH_TEST); } +int renderer_get_grid_cell_size(void) +{ + return grid_cell_size; +} + +void renderer_set_grid_cell_size(int cell_size) +{ + grid_cell_size = cell_size; +} + static void render_grid(void) { int i, DIM; - - DIM = fluids_get_dim(); + DIM = renderer_get_grid_cell_size(); glColor4f(0.0f, 0.0f, 0.5f, 0.8f); glLineWidth(1.0f); - for (i = 0; i < winWidth; i += DIM) { - if (i) { - glBegin(GL_LINES); - glVertex2i(i, 0); - glVertex2i(i, winWidth); - glEnd(); + glBegin(GL_LINES); + for (i = 0; i < winWidth; i += DIM) + { + if (i) + { + glVertex3i(i, 0, 0); + glVertex3i(i, winWidth, 0); } } - for (i = 0; i < winHeight; i += DIM) { - if (i) { - glBegin(GL_LINES); - glVertex2i(0, i); - glVertex2i(winHeight, i); - glEnd(); + for (i = 0; i < winHeight; i += DIM) + { + if (i) + { + glVertex3i(0, i, 0); + glVertex3i(winHeight, i, 0); } } + + glEnd(); } static void render_normal(void) @@ -310,7 +321,14 @@ void render_smoke(void) DIM = fluids_get_dim(); - glDisable(GL_BLEND); + if (colormap_get_alpha() < 1.0f) + { + glEnable(GL_BLEND); + } + else + { + glDisable(GL_BLEND); + } wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height @@ -367,7 +385,75 @@ void render_smoke(void) glEnd(); } - glEnable(GL_BLEND); + glDisable(GL_BLEND); +} + + +void render_grid_smoke(void) +{ + int i, j, idx, DIM; + double px, py, pz; + fftw_real wn, hn; + struct color4f color; + fftw_real *frame, *height; + + DIM = fluids_get_dim(); + + glDisable(GL_BLEND); + + wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width + hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height + + frame = smoke_get_frame(); + height = heightplots_get_frame(); + + for (j = 0; j < DIM - 1; j++) + { + glBegin(GL_LINE_STRIP); + + // horizontal lines + for (i = 0; i < DIM - 1; i++) + { + // vertex 2 + idx = ((j + 1) * DIM) + i; + + px = wn + (fftw_real)i * wn; + py = hn + (fftw_real)(j + 1) * hn; + pz = height[idx] * heightplots_get_height(); + + color = colormap_get_color(frame[idx]); + glColor4f(color.r, color.g, color.b, color.a); + + glVertex3f(px, py, pz); + + // vertex 1 + idx = (j * DIM) + i; + + px = wn + (fftw_real)i * wn; + py = hn + (fftw_real)j * hn; + pz = height[idx] * heightplots_get_height(); + + color = colormap_get_color(frame[idx]); + glColor4f(color.r, color.g, color.b, color.a); + + glVertex3f(px, py, pz); + + // vertex 3 + idx = (j * DIM) + (i + 1); + + px = wn + (fftw_real)(i + 1) * wn; + py = hn + (fftw_real)j * hn; + pz = height[idx] * heightplots_get_height(); + + color = colormap_get_color(frame[idx]); + glColor4f(color.r, color.g, color.b, color.a); + + glVertex3f(px, py, pz); + + } + + glEnd(); + } } @@ -911,6 +997,9 @@ void visualize(struct vis_data_arrays *vis_data) if (smoke_get_render()) { render_smoke(); } + else if (smoke_grid_get_render()) { + render_grid_smoke(); + } if (glyphs_get_render()) { render_glyphs(); |