diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-03 18:05:51 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-03 18:05:51 (GMT) |
commit | b12d6854cbb458c3de11266efefa8fb2ea11a1cf (patch) | |
tree | 32fc00f87d0bdb7f9d024c6b174e5896fd66a0f2 | |
parent | 909340f9a5299194c582f9224f21f4f4daf56e51 (diff) | |
download | 2iv35-b12d6854cbb458c3de11266efefa8fb2ea11a1cf.zip 2iv35-b12d6854cbb458c3de11266efefa8fb2ea11a1cf.tar.gz 2iv35-b12d6854cbb458c3de11266efefa8fb2ea11a1cf.tar.bz2 |
frame passing changes
-rw-r--r-- | Smoke/colormap.h | 2 | ||||
-rw-r--r-- | Smoke/fluids.c | 16 | ||||
-rw-r--r-- | Smoke/fluids.h | 2 | ||||
-rw-r--r-- | Smoke/gtk.c | 1 | ||||
-rw-r--r-- | Smoke/renderer_gl.c | 7 | ||||
-rwxr-xr-x | Smoke/smoke.bin | bin | 626039 -> 626063 bytes | |||
-rw-r--r-- | Smoke/smoke.c | 12 | ||||
-rw-r--r-- | Smoke/smoke.h | 4 |
8 files changed, 32 insertions, 12 deletions
diff --git a/Smoke/colormap.h b/Smoke/colormap.h index 70f7a72..6d63ed1 100644 --- a/Smoke/colormap.h +++ b/Smoke/colormap.h @@ -37,6 +37,8 @@ void colormap_set_frame(fftw_real *frame); fftw_real *colormap_get_frame(void);
+void colormap_autoscale(void);
+
struct color4f colormap_get_color(float value);
#endif
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 6ea63d8..6071d36 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -17,6 +17,7 @@ #include "funcs.h" #include "fluids.h" +#include "smoke.h" #include "colormap.h" //--- SIMULATION PARAMETERS ------------------------------------------------------------------------ @@ -88,6 +89,15 @@ fftw_real *init_simulation(int n) return return_value; } +void fluids_init(int dim) +{ + size_t frame_size; + + frame_size = dim * 2*(dim/2+1)*sizeof(fftw_real); + + smoke_init(frame_size); +} + int rescale_to_winwidth(float value) { return round(value *winWidth); @@ -301,9 +311,9 @@ void calculate_height_plot(void) } } -void copy_frame(fftw_real *field, fftw_real *dataset) +void copy_frames(fftw_real *dataset) { - memcpy(field, dataset, DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)); + memcpy(smoke_get_frame(), dataset, DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)); } //do_one_simulation_step: Do one complete cycle of the simulation: @@ -321,7 +331,7 @@ void calculate_one_simulation_step(fftw_real *field) diffuse_matter(DIM, vx, vy, rho, rho0, dt); calculate_height_plot(); calculate_normal_vectors(); - copy_frame(field, rho); + copy_frames(rho); colormap_autoscale(); } } diff --git a/Smoke/fluids.h b/Smoke/fluids.h index 97fd5bf..ca2c214 100644 --- a/Smoke/fluids.h +++ b/Smoke/fluids.h @@ -73,6 +73,8 @@ extern float threshold1; extern float threshold2; extern int active_slider; +void fluids_init(int dim); + void fluids_set_calculate(int calculate); int fluids_get_calculate(void); void fluids_insert_smoke(int x, int y); diff --git a/Smoke/gtk.c b/Smoke/gtk.c index 3a1b310..bd1ab4b 100644 --- a/Smoke/gtk.c +++ b/Smoke/gtk.c @@ -877,6 +877,7 @@ main (int argc, /* Initialize the simulation */ field = init_simulation(DIM); + fluids_init(DIM); /* Initialize GTK. */ gtk_init (&argc, &argv); diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index bafc0e3..186568d 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -533,12 +533,15 @@ static void render_streamlines(void) } -void render_flowvis(fftw_real *field) +void render_flowvis(void) { int i, j, idx; double px,py; fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height struct color4f color; + fftw_real *field; + + field = smoke_get_frame(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -689,7 +692,7 @@ void visualize(fftw_real *field) } if (flowvis_get_render()) { - render_flowvis(field); + render_flowvis(); } if (normals_get_render()) { diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin Binary files differindex 90abf7d..4b0292b 100755 --- a/Smoke/smoke.bin +++ b/Smoke/smoke.bin diff --git a/Smoke/smoke.c b/Smoke/smoke.c index 539c64e..0e62854 100644 --- a/Smoke/smoke.c +++ b/Smoke/smoke.c @@ -3,6 +3,8 @@ #include <windows.h> #endif +#include <stdlib.h> + #include <rfftw.h> #include "fluids.h" @@ -12,7 +14,7 @@ static int smoke_render_smoke = TRUE; static int smoke_dataset = DATASET_RHO; -static fftw_real *smoke_field; +static fftw_real *smoke_frame; void smoke_set_render(int render_smoke) @@ -35,12 +37,12 @@ int smoke_get_dataset(void) return smoke_dataset; } -void smoke_set_field(fftw_real *field) +void smoke_init(size_t frame_size) { - smoke_field = field; + smoke_frame = malloc(frame_size); } -fftw_real *smoke_get_field(void) +fftw_real *smoke_get_frame(void) { - return smoke_field; + return smoke_frame; } diff --git a/Smoke/smoke.h b/Smoke/smoke.h index bbdcacb..f53f142 100644 --- a/Smoke/smoke.h +++ b/Smoke/smoke.h @@ -7,7 +7,7 @@ int smoke_get_render(void); void smoke_set_dataset(int dataset); int smoke_get_dataset(void); -void smoke_set_field(fftw_real *field); -fftw_real *smoke_get_field(void); +void smoke_init(size_t frame_size); +fftw_real *smoke_get_frame(void); #endif |