summaryrefslogtreecommitdiffstats
path: root/Smoke/glyphs.c
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2007-12-19 15:44:23 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2007-12-19 15:44:23 (GMT)
commita60088999da4f44bf5885f431fe78eb87d643ae7 (patch)
tree27940a3cd14a7cdee60ddb0263bf1173c51df56c /Smoke/glyphs.c
parentc287b3f591fe3e10dceedfd90a5ce71b2c703988 (diff)
download2iv35-a60088999da4f44bf5885f431fe78eb87d643ae7.zip
2iv35-a60088999da4f44bf5885f431fe78eb87d643ae7.tar.gz
2iv35-a60088999da4f44bf5885f431fe78eb87d643ae7.tar.bz2
splitted up glyphs
Diffstat (limited to 'Smoke/glyphs.c')
-rw-r--r--Smoke/glyphs.c197
1 files changed, 45 insertions, 152 deletions
diff --git a/Smoke/glyphs.c b/Smoke/glyphs.c
index eca9af5..2c60aa0 100644
--- a/Smoke/glyphs.c
+++ b/Smoke/glyphs.c
@@ -1,165 +1,58 @@
-// Includes
-
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
-#include <rfftw.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include "fluids.h"
-#include "glyphs.h"
#include "funcs.h"
+#include "palette.h"
+
+#include "glyphs.h"
+
+
+static int glyphs_render = FALSE;
+
+static int glyphs_num_colors = PALETTE_MAXCOLORS;
-void render_glyph(float x_value, float y_value, float i, float j)
+static int glyphs_colormap = PALETTE_BLACKWHITE;
+
+
+void glyphs_set_render(int render_glyphs)
{
- float x0, y0, z0, x1, y1, z1, x_dev, y_dev, size, length;
- float scale = (float)((float)DIM / (float)get_var_dims()) / 6;
- double theta, in_prod;
- fftw_real wn, hn;
-
- GLuint startList = glGenLists(1);
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_FILL);
- gluQuadricNormals(qobj, GLU_SMOOTH);
- glNewList(startList, GL_COMPILE);
- gluCylinder(qobj, 10, 0.2, 8, 8, 8);
- glEndList();
-
- size = quake_root((x_value * x_value * 20) + (y_value * y_value * 20)) * 3 * scale;
-
- wn = (fftw_real)winWidth / (fftw_real)(get_var_dims() + 1); // Grid cell width
- hn = (fftw_real)winHeight / (fftw_real)(get_var_dims() + 1); // Grid cell heigh
-
- x0 = wn + (fftw_real)i * wn;
- y0 = hn + (fftw_real)j * hn;
- z0 = 0.0f;
-
- x1 = x0 + (vec_scale * x_value)/4;
- y1 = y0 + (vec_scale * y_value)/4;
- z1 = 0.0f;
-
- // inner product
- x_dev = x1 - x0;
- y_dev = y1 - y0;
- length = quake_root(x_dev * x_dev + y_dev * y_dev);
-
- x_dev = (length == 0) ? 0 : x_dev / length;
- y_dev = (length == 0) ? 1 : y_dev / length;
-
- in_prod = x_dev * 0 + y_dev * 1;
- theta = acos(in_prod) * (180/3.141592654);
- if (x1 > x0) { theta *= -1; }
-
- switch(get_glyph_sort())
- {
- default:
- case GLYPH_LINES:
- glBegin(GL_LINES);
- glVertex3f(x0, y0, z0);
- glVertex3f(x1, y1, z0);
- glEnd();
- break;
-
- case GLYPH_ARROWS:
- glPushMatrix();
- glTranslatef(x0, y0, z0);
- glRotatef(theta, 0.0, 0.0, 1.0);
- glTranslatef(-x0, -y0, -z0);
-
- glBegin(GL_TRIANGLES);
- glVertex2d(-10 * size + x0, -25 * size + y0);
- glVertex2d( 0 * size + x0, 25 * size + y0);
- glVertex2d( 10 * size + x0, -25 * size + y0);
- glEnd();
-
- glRotatef(-theta, 0.0, 0.0, 1.0);
- glPopMatrix();
- break;
-
- case GLYPH_CYLINDERS:
- x_dev = x1 - x0;
- y_dev = y1 - y0;
- length = quake_root(x_dev * x_dev + y_dev * y_dev) / 8;
-
- glPushMatrix();
-
- glTranslatef(x0, y0, -1.0);
- glRotatef(theta, 0.0, 0.0, 1.0);
- glRotatef(-90, 1.0, 0.0, 0.0);
- glScalef(length, length, length);
- glCallList(startList);
-
- glPopMatrix();
- break;
-
- case GLYPH_SPHERES:
- glPushMatrix();
-
- glTranslatef(x0, y0, -1.0);
- glRotatef(theta, 0.0, 0.0, 1.0);
- glRotatef(-90, 1.0, 0.0, 0.0);
- glScalef(length, length, length);
- glCallList(startList);
-
- glPopMatrix();
- break;
- }
-
- gluDeleteQuadric(qobj);
- glDeleteLists(startList, 1);
+ glyphs_render = render_glyphs;
}
-void draw_glyphs(void)
+int glyphs_get_render(void)
{
- int i, j, idx;
- float value, scale, idxcf, idxrf;
-
-#if 0
- if (use_glyphs)
- {
- scale = (float)((float)DIM / (float)get_var_dims());
- for (i = 0; i < get_var_dims(); i++)
- {
- for (j = 0; j < get_var_dims(); j++)
- {
- idxcf = round(j * scale) * DIM;
- idxrf = round(i * scale);
- idx = idxcf + idxrf;
-
- switch (glyph_scalar)
- {
- default:
- case SCALAR_RHO:
- value = rho[idx];
- break;
-
- case SCALAR_VEL:
- value = vec_len(vx[idx], vy[idx]);
- break;
-
- case SCALAR_FORCE:
- value = vec_len(fx[idx], fy[idx]);
- break;
- }
-
- set_colormap(scalar_col, value, FALSE, 0.5f);
- switch (glyph_vector)
- {
- default:
- case VECTOR_VEL:
- render_glyph(vx[idx], vy[idx], i, j);
- break;
-
- case VECTOR_FORCE:
- render_glyph(fx[idx], fy[idx], i, j);
- break;
- }
- }
- }
- }
-#endif
+ return glyphs_render;
+}
+
+void glyphs_set_num_colors(int num_colors)
+{
+ glyphs_num_colors = num_colors;
+}
+
+int glyphs_get_num_colors(void)
+{
+ return glyphs_num_colors;
+}
+
+void glyphs_set_map(int colormap)
+{
+ glyphs_colormap = colormap;
+}
+
+int glyphs_get_map(void)
+{
+ return glyphs_colormap;
+}
+
+
+struct color4f glyphs_get_color(float value)
+{
+ struct color4f return_value;
+
+ return_value = set_palette(glyphs_colormap, value, glyphs_num_colors);
+
+ return return_value;
}