summaryrefslogtreecommitdiffstats
path: root/Smoke/renderer_gl.c
diff options
context:
space:
mode:
Diffstat (limited to 'Smoke/renderer_gl.c')
-rw-r--r--Smoke/renderer_gl.c101
1 files changed, 59 insertions, 42 deletions
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index 57ed71f..eccf8b1 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -782,7 +782,7 @@ static void render_streamlines(void)
frame_history = streamlines_get_history_scalars(j);
cell_x = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
- cell_y = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell heigh
+ cell_y = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
idx_x = round(p.x / cell_x);
idx_y = round(p.y / cell_y);
@@ -804,75 +804,92 @@ static void render_streamlines(void)
static void render_flowvis(void)
{
- int i, j, idx, DIM;
+ int i, j, k, idx, DIM, max_frame;
double px,py;
fftw_real wn, hn;
struct color4f color;
fftw_real *history;
-
DIM = fluids_get_dim();
wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
- history = flowvis_get_history(flowvis_get_hisdex());
+ glPushMatrix();
- if (flowvis_get_alpha() < 1.0f)
+ if (flowvis_get_sort() == FLOWVIS_SORT_FRAME)
{
- glEnable(GL_BLEND);
+ max_frame = 1;
}
- else
+ else // FLOWVIS_SORT_3DPLOT
{
- glDisable(GL_BLEND);
+ max_frame = HISTORY_SIZE;
}
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- for (j = 0; j < DIM - 1; j++) //draw smoke
+ for (k = 0; k < max_frame; k+=2)
{
- glBegin(GL_TRIANGLE_STRIP);
- i = 0;
- px = wn + (fftw_real)i * wn;
- py = hn + (fftw_real)j * hn;
- idx = (j * DIM) + i;
-
- color = flowvis_get_color((float)history[idx]);
- glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f((GLfloat)px, (GLfloat)py); // vertex 1
-
- for (i = 0; i < DIM - 1; i++)
- {
- px = wn + (fftw_real)i * wn;
- py = hn + (fftw_real)(j + 1) * hn;
- idx = ((j + 1) * DIM) + i;
+ if (max_frame <= 1)
+ {
+ history = flowvis_get_history(flowvis_get_hisdex());
+ if (flowvis_get_alpha() < 1.0f) { glEnable(GL_BLEND); }
+ else { glDisable(GL_BLEND); }
+ }
+ else
+ {
+ history = flowvis_get_history(k);
+ glTranslatef(0.0f, 0.0f, wn * 2);
+ glEnable(GL_BLEND);
+ }
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ for (j = 0; j < DIM - 1; j++) //draw smoke
+ {
+ glBegin(GL_TRIANGLE_STRIP);
+
+ i = 0;
+ px = wn + (fftw_real)i * wn;
+ py = hn + (fftw_real)j * hn;
+ idx = (j * DIM) + i;
+
color = flowvis_get_color((float)history[idx]);
glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f((GLfloat)px, (GLfloat)py); // vertex 2
+ glVertex2f((GLfloat)px, (GLfloat)py); // vertex 1
+
+ for (i = 0; i < DIM - 1; i++)
+ {
+ px = wn + (fftw_real)i * wn;
+ py = hn + (fftw_real)(j + 1) * hn;
+ idx = ((j + 1) * DIM) + i;
+ color = flowvis_get_color((float)history[idx]);
+ glColor4f(color.r, color.g, color.b, color.a);
+ glVertex2f((GLfloat)px, (GLfloat)py); // vertex 2
- px = wn + (fftw_real)(i + 1) * wn;
- py = hn + (fftw_real)j * hn;
- idx = (j * DIM) + (i + 1);
- color = flowvis_get_color((float)history[idx]);
- glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f((GLfloat)px, (GLfloat)py); // vertex 3
- }
+ px = wn + (fftw_real)(i + 1) * wn;
+ py = hn + (fftw_real)j * hn;
+ idx = (j * DIM) + (i + 1);
+ color = flowvis_get_color((float)history[idx]);
+ glColor4f(color.r, color.g, color.b, color.a);
+ glVertex2f((GLfloat)px, (GLfloat)py); // vertex 3
+ }
- px = wn + (fftw_real)(DIM - 1) * wn;
- py = hn + (fftw_real)(j + 1) * hn;
- idx = ((j + 1) * DIM) + (DIM - 1);
- color = flowvis_get_color((float)history[idx]);
- glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f((GLfloat)px, (GLfloat)py); // vertex 4
+ px = wn + (fftw_real)(DIM - 1) * wn;
+ py = hn + (fftw_real)(j + 1) * hn;
+ idx = ((j + 1) * DIM) + (DIM - 1);
+ color = flowvis_get_color((float)history[idx]);
+ glColor4f(color.r, color.g, color.b, color.a);
+ glVertex2f((GLfloat)px, (GLfloat)py); // vertex 4
- glEnd();
+ glEnd();
+ }
}
+ glPopMatrix();
}
void renderer_init_gl(void)
{
- float LightAmbient[] = { 0.10f, 0.10f, 0.10f, 1.0f }; // Ambient light values
+ float LightAmbient[] = { 0.20f, 0.20f, 0.20f, 1.0f }; // Ambient light values
float LightDiffuse[] = { 0.80f, 0.80f, 0.80f, 1.0f }; // Diffuse light values
float LightPosition[] = { x_pos, y_pos, -500, 1.0f }; // Position of the light source
@@ -895,7 +912,7 @@ void renderer_init_gl(void)
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
- glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.8f);
+ glMaterialf(GL_FRONT, GL_SHININESS, 9.8f);
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);