summaryrefslogtreecommitdiffstats
path: root/Smoke/renderer_gl.c
blob: 186568deb0e44bd6be15c7b69ee41a8072776bb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713

#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif

#include <math.h>

#include <GL/gl.h>
#include <GL/glu.h>

#include <rfftw.h>


#include "funcs.h"
#include "fluids.h"
#include "palette.h"
#include "smoke.h"
#include "colormap.h"
#include "glyphs.h"
#include "isolines.h"
#include "streamlines.h"
#include "heightplots.h"
#include "flowvis.h"

#include "seedpoint.h"

#include "renderer_gl.h"


#define DEFAULT_X_POS 0.0f
#define DEFAULT_Y_POS 0.0f
#define DEFAULT_ZOOM -750.0f
#define MIN_ZOOM -100.0f
#define MAX_ZOOM -4000.0f
#define DEFAULT_ZOOM_SPEED 40

#define MIN_ZOOM -100.0f
#define MAX_ZOOM -4000.0f


#define LEGEND_X_POS -298.0f
#define LEGEND_Y_POS -295.0f
#define LEGEND_Z_POS -735.0f

float x_pos = DEFAULT_X_POS;
float y_pos = DEFAULT_Y_POS;
float z_pos = DEFAULT_ZOOM;

static int renderer_zoomspeed = DEFAULT_ZOOM_SPEED;
static int normals_render = FALSE;

static void render_legend(void)
{
  int i;
  struct color4f color;

  glDisable(GL_LIGHTING);
  glDisable(GL_DEPTH_TEST);
  glDisable(GL_BLEND);

  glLoadIdentity();
  glTranslatef(LEGEND_X_POS, LEGEND_Y_POS, LEGEND_Z_POS);

  for (i = 0; i < winWidth; i++)
  {
		float value, clamp_scaled_min, clamp_scaled_max, scale_scaled_min, scale_scaled_max;


		value = (float)((float)i/winWidth);

    color = colormap_get_color(value);


		clamp_scaled_min = colormap_get_clamp_min() *winWidth;
		clamp_scaled_max = colormap_get_clamp_max() *winWidth;

		scale_scaled_min = colormap_get_scale_min() *winWidth;
		scale_scaled_max = colormap_get_scale_max() *winWidth;

		glBegin(GL_LINES);
			if (colormap_get_scaling()) {
				glColor3f(1, 0, 0);
				glVertex2i(scale_scaled_min, winHeight -4);
				glVertex2i(scale_scaled_min, winHeight -18);
				glVertex2i(scale_scaled_max, winHeight -4);
				glVertex2i(scale_scaled_max, winHeight -18);
			}
    	if (colormap_get_clamping()) {      
  			glColor4f(0.2, 0.2, 0.2, 1.0);
	  		glVertex2i(clamp_scaled_min, winHeight -6);
		  	glVertex2i(clamp_scaled_min, winHeight -18);
			  glVertex2i(clamp_scaled_max, winHeight -6);
  			glVertex2i(clamp_scaled_max, winHeight -18);
      }
			if (!(i %20)) {
				glColor3f(0.7, 0.7, 0.7);
				glVertex2i(i -1, winHeight -6);
				glVertex2i(i -1, winHeight -22);
				glVertex2i(i, winHeight -6);
				glVertex2i(i, winHeight -22);
				glVertex2i(i +1, winHeight -6);
				glVertex2i(i +1, winHeight -22);
			} else {
        glColor3f(color.r, color.g, color.b);
				glVertex2i(i, winHeight -6);
				glVertex2i(i, winHeight -18);
			}
		glEnd();

		glBegin(GL_TRIANGLES);
    	if (colormap_get_scaling()) {
				glColor3f(1, 0, 0);
				glVertex2i(scale_scaled_min, winHeight -6);
				glVertex2i(scale_scaled_min -4, winHeight);
				glVertex2i(scale_scaled_min +4, winHeight);
				glVertex2i(scale_scaled_max, winHeight -6);
				glVertex2i(scale_scaled_max -4, winHeight);
				glVertex2i(scale_scaled_max +4, winHeight);
			}
    	if (colormap_get_clamping()) {
			  glColor3f(0.9, 0.9, 0.9);
        glVertex2i(clamp_scaled_min, winHeight -18);
        glVertex2i(clamp_scaled_min -4, winHeight -25);
        glVertex2i(clamp_scaled_min +4, winHeight -25);
        glVertex2i(clamp_scaled_max, winHeight -18);
        glVertex2i(clamp_scaled_max -4, winHeight -25);
        glVertex2i(clamp_scaled_max +4, winHeight -25);
      }
		glEnd();
	}

  glEnable(GL_BLEND);
  glEnable(GL_LIGHTING);
  glEnable(GL_DEPTH_TEST);  
}

static void render_normal(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
  float normal_scale = 10.0f;

  glDisable(GL_LIGHTING);
  glBegin(GL_LINES);
  glColor3f(1.0f, 0.2f, 0.0f);

  for (j = 0; j < DIM - 1; j++)
  {
    for (i = 0; i < DIM; i++)
    {
      idx = (j * DIM) + i;
      px = wn + (fftw_real)i * wn;
		  py = hn + (fftw_real)(j + 1) * hn;

      glVertex3f(px, py, height_array[idx]);
      glVertex3f(px + normal_array[idx].x * normal_scale,
                 py + normal_array[idx].y * normal_scale,
                 height_array[idx] + normal_array[idx].z * normal_scale);
    }
  }
  glEnable(GL_LIGHTING);
  glEnd();
}


static void render_smoke(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;

  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 = colormap_get_color(get_dataset(idx));
    glColor4f(color.r, color.g, color.b, color.a);
    glNormal3f(normal_array[idx].x, normal_array[idx].y, normal_array[idx].z);
	  glVertex3f(px, py, height_array[idx]); // 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;
      get_dataset(idx);
      color = colormap_get_color(get_dataset(idx));
      glColor4f(color.r, color.g, color.b, color.a);
      glNormal3f(normal_array[idx].x, normal_array[idx].y, normal_array[idx].z);
      glVertex3f(px, py, height_array[idx]); // vertex 2

		  px = wn + (fftw_real)(i + 1) * wn;
		  py = hn + (fftw_real)j * hn;
		  idx = (j * DIM) + (i + 1);
		  color = colormap_get_color(get_dataset(idx));
      glColor4f(color.r, color.g, color.b, color.a);
      glNormal3f(normal_array[idx].x, normal_array[idx].y, normal_array[idx].z);
		  glVertex3f(px, py, height_array[idx]); // vertex 3
	  }

	  px = wn + (fftw_real)(DIM - 1) * wn;
	  py = hn + (fftw_real)(j + 1) * hn;
	  idx = ((j + 1) * DIM) + (DIM - 1);
	  color = colormap_get_color(get_dataset(idx));
    glColor4f(color.r, color.g, color.b, color.a);
    glNormal3f(normal_array[idx].x, normal_array[idx].y, normal_array[idx].z);
	  glVertex3f(px, py, height_array[idx]); // vertex 4

	  glEnd();
  }
}


static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, float i, float j)
{
  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;

  size = quake_root((x_value * x_value * 20) + (y_value * y_value * 20)) * 5 * 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:
      if (size < 0.08f) return;

      glPushMatrix();
      
        glTranslatef(x0, y0, z0);
        glRotatef(theta, 0.0, 0.0, 1.0);
        glTranslatef(-x0, -y0, -z0);

        glBegin(GL_TRIANGLE_STRIP);
          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) / 16;

      if (length < 0.5f) return;

      glPushMatrix();
      
        glTranslatef(x0, y0, z0);
        glRotatef(theta, 0.0, 0.0, 1.0);
        glRotatef(-90, 1.0, 0.0, 0.0);
        glScalef(length, length, length);
        gluCylinder(qobj, 10, 0.2, 8, 8, 8);

      glPopMatrix();
      break;
  }
}

static void render_glyphs(void)
{
  int i, j, idx;
  float value, scale, idxcf, idxrf;
  struct color4f color;

  GLUquadricObj *qobj = gluNewQuadric();
  gluQuadricDrawStyle(qobj, GLU_FILL);
  gluQuadricNormals(qobj, GLU_SMOOTH);

  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_len2f(vx[idx], vy[idx]);
          break;

        case SCALAR_FORCE:
          value = vec_len2f(fx[idx], fy[idx]);
          break;
      }
      color = glyphs_get_color(value);
      glColor4f(color.r, color.b, color.g, color.a);

      switch (glyph_vector)
      {
        default:
        case VECTOR_VEL:
          render_glyph(qobj, vx[idx], vy[idx], i, j);
          break;

        case VECTOR_FORCE:
          render_glyph(qobj, fx[idx], fy[idx], i, j);
          break;
      }
    }
  }

  gluDeleteQuadric(qobj);
}


static void render_isolines(void)
{
  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

  int count;
  float iso_scale;

  if (isolines_nr) {
    iso_scale = (float)(fabs(threshold1 - threshold2) / (float)isolines_nr);
  } else {
    iso_scale = 0.0f;
  }

  for (count = 0; count < isolines_nr; count++)
  {
    int idx;
    int i, j;
    float v0, v1, v2, v3;
    float x0, y0, x1, y1, x_offset, y_offset;
    int state = 0;
    static int prev_state = 0;
    struct color4f color;
    float threshold, max;

    v0 = v1 = v2 = v3 = 0.0f;
    x0 = y0 = x1 = y1 = 0.0f;
    
    threshold = min(threshold1, threshold2) + count * iso_scale;

    glDisable(GL_LIGHTING);
    glBegin(GL_LINES);

    for (i = 0; i < DIM - 1; i++)
    {
      for (j = 0; j < DIM - 1; j++)
      {
        state = 0;
        idx = (j * DIM) + i;
        color = isolines_get_color(get_dataset(idx));
        //glColor4f(color.r, color.g, color.b, color.a);
        glColor3f(1.0f, 0.0f, 0.0f);

        v0 = get_dataset(idx + DIM);
        v1 = get_dataset(idx + 1 + DIM);
        v2 = get_dataset(idx + 1);
        v3 = get_dataset(idx);

        if (v0 >= threshold) { state += 1; }
        if (v1 >= threshold) { state += 2; }
        if (v2 >= threshold) { state += 4; }
        if (v3 >= threshold) { state += 8; }

        x_offset = wn + (fftw_real)i * wn;
        y_offset = hn + (fftw_real)j * hn;

        switch (state)
        {
          case 5:
          case 10:
            //y0 = 0.5f * hn;
            //x1 = 0.5f * wn;
            x0 = 0;
            y0 = (threshold / max(v3, v0)) * hn;
            x1 = (threshold / max(v1, v0)) * wn;
            y1 = hn;

            glVertex3i(x_offset + x0, y_offset + y0, 5.0f);
            glVertex3i(x_offset + x1, y_offset + y1, 5.0f);
            // no break !!
          case 4:
          case 11:
            //x0 = 0.5f * wn;
            //y1 = 0.5f * hn;
            x0 = (threshold / max(v3, v2)) * wn;
            y0 = 0;
            x1 = wn;
            y1 = (threshold / max(v2, v1)) * hn;
            break;
          case 6:
          case 9:
            //x0 = 0.5f * wn;
            //x1 = 0.5f * wn;
            x0 = (threshold / max(v3, v2)) * wn;
            y0 = 0;
            x1 = (threshold / max(v1, v0)) * wn;
            y1 = hn;
            break;
          case 7:
          case 8:
            //x0 = 0.5f * wn;
            //y1 = 0.5f * hn;
            x0 = (threshold / max(v3, v2)) * wn;
            y0 = 0;
            x1 = 0;
            y1 = (threshold / max(v3, v0)) * hn;
            break;
          case 3:
          case 12:
            //y0 = 0.5f * hn;
            //y1 = 0.5f * hn;
            x0 = 0;
            y0 = (threshold / max(v3, v0)) * hn;
            x1 = wn;
            y1 = (threshold / max(v2, v1)) * hn;
            break;
          case 2:
          case 13:
            //x0 = 0.5f * wn;
            //y1 = 0.5f * hn;
            x0 = (threshold  / max(v1, v0)) * wn;
            y0 = hn;
            x1 = wn;
            y1 = (threshold / max(v2, v1)) * hn;
            break;
          case 1:
          case 14:
            //y0 = 0.5f * hn;
            //x1 = 0.5f * wn;
            x0 = 0;
            y0 = (threshold / max(v3, v0)) * hn;
            x1 = (threshold / max(v1, v0)) * wn;
            y1 = hn;
            break;
          case 0: case 15: default:
            x0 = y0 = x1 = y1 = 0.0f;
            break;
        }

        // draw line
        glVertex3i(x_offset + x0, y_offset + y0, 5.0f);
        glVertex3i(x_offset + x1, y_offset + y1, 5.0f);
      }
    }

    glEnd();
  }
  glEnable(GL_LIGHTING);
}


static void render_streamlines(void)
{
  int i, j, k, l, idx;
  float v;
  struct point p;
  int *frame_history;
  fftw_real cell_x, cell_y;

  i = j = k = l = 0;

  for (i = 0; i < get_cur_seedpoint(); i++)
  {
    p = get_seedpoint(i);

    while (j < DIM)
    {
      frame_history = frame_hist[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_x = round(p.x / cell_x);
      cell_y = round(p.y / cell_y);

      idx = cell_x + (cell_y * DIM) + (j * DIM * DIM);
      //v = frame_history[idx];

      j++;
    }
  }
}


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);

  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;
		
	  glColor3f(field[idx],field[idx],field[idx]);
	  glVertex2f(px,py);
						
	  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(field[idx]);
      glColor4f(color.r, color.g, color.b, color.a);      
      glVertex2f(px, py);
		  px = wn + (fftw_real)(i + 1) * wn;
		  py = hn + (fftw_real)j * hn;
		  idx = (j * DIM) + (i + 1);
		  color = flowvis_get_color(field[idx]);
      glColor4f(color.r, color.g, color.b, color.a);
		  glVertex2f(px, py);
	  }

	  px = wn + (fftw_real)(DIM - 1) * wn;
	  py = hn + (fftw_real)(j + 1) * hn;
	  idx = ((j + 1) * DIM) + (DIM - 1);
	  color = flowvis_get_color(field[idx]);
    glColor4f(color.r, color.g, color.b, color.a);
	  glVertex2f(px, py);
	  glEnd();
  }
}


void renderer_init_gl(void)
{
  float LightAmbient[]  = { 0.10f, 0.10f,  0.10f, 1.00f }; // Ambient light values
  float LightDiffuse[]  = { 0.40f, 0.40f,  0.40f, 0.00f }; // Diffuse light values
  float LightPosition[] = { -300.0f, -300.0f, -300.0f,  1.00f }; // Position of the light source

  glShadeModel(GL_SMOOTH);                           // Enable smooth shading
  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);              // Black background
  glClearDepth(1.0f);                                // Depth buffer setup
  glDepthFunc(GL_LESS);                              // The type of depth testing to do
  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really nice perspective calculations
  glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);           // Really nice point smoothing
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glEnable(GL_COLOR_MATERIAL);

  glLightfv(GL_LIGHT0, GL_AMBIENT,  LightAmbient);
  glLightfv(GL_LIGHT0, GL_DIFFUSE,  LightDiffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
}


void renderer_set_zoomspeed(int zoomspeed)
{
  renderer_zoomspeed = zoomspeed;
}

int renderer_get_zoomspeed(void)
{
  return renderer_zoomspeed;
}

void renderer_zoom_in(void)
{
  if ((z_pos +renderer_zoomspeed) < MIN_ZOOM) {
    z_pos += renderer_zoomspeed;
  }
}

void renderer_zoom_out(void)
{
  if ((z_pos -renderer_zoomspeed) > MAX_ZOOM) {
    z_pos -= renderer_zoomspeed;
  }
}

void renderer_reset_zoom(void)
{
  z_pos =  DEFAULT_ZOOM;
}

void renderer_reset_pos(void)
{
  x_pos = DEFAULT_X_POS;
  y_pos = DEFAULT_Y_POS;
}

void renderer_reset_yaw(void)
{
  x_rot = 0.0f;
}

void renderer_reset_pitch(void)
{
  y_rot = 0.0f;
}

void renderer_reset_roll(void)
{
  z_rot = 0.0f;
}


//visualize: This is the main visualization function
void visualize(fftw_real *field)
{

  // Rotate field
  glLoadIdentity();
  glTranslatef(x_pos, y_pos, z_pos);
  glRotatef(x_rot, 1.0f, 0.0f, 0.0f);
  glRotatef(y_rot, 0.0f, 1.0f, 0.0f);
  glRotatef(z_rot, 0.0f, 0.0f, 1.0f);
  
  glTranslatef(-winWidth/2, -winHeight/2, 0.0f);

  if (isolines_get_render()) {
      render_isolines();
  }

  if (smoke_get_render()) {
	  render_smoke();
  }

  if (glyphs_get_render()) {
    render_glyphs();
  }

  render_seedpoints();

  if (streamlines_get_render()) {
    render_streamlines();
  }

  if (flowvis_get_render()) {
    render_flowvis();
  }

  if (normals_get_render()) {
    render_normal();
  }

	render_legend();
}

int normals_get_render(void)
{
  return normals_render;
}

void normals_set_render(int normals)
{
  normals_render = normals;
}