summaryrefslogtreecommitdiffstats
path: root/Smoke/seedpoint.c
blob: 4c0703868d2305493a929836f9b93fd6212488c8 (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
// 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 "seedpoint.h"
#include "renderer_gl.h"

struct point seedpoints[MAX_SEEDPOINTS];
int cur_seedpoint;

void create_seedpoint(float mx, float my)
{
  if (cur_seedpoint >= MAX_SEEDPOINTS) return;

  seedpoints[cur_seedpoint].x = mx;
  seedpoints[cur_seedpoint].y = my;
  seedpoints[cur_seedpoint].z = -725.0f;
  cur_seedpoint++;

} // create_seedpoint

void delete_seedpoint(int seedpoint_nr)
{
  int i = seedpoint_nr;

  for (i; i < cur_seedpoint; i++)
  {
    seedpoints[i].x = seedpoints[i+1].x;
    seedpoints[i].y = seedpoints[i+1].y;
    seedpoints[i].z = seedpoints[i+1].z;
  }

  for (i; i < MAX_SEEDPOINTS; i++)
  {
    seedpoints[i].x = 0.0f;
    seedpoints[i].y = 0.0f;
    seedpoints[i].z = 0.0f;
  }

} // delete_seedpoint

void render_seedpoints(void)
{
  int i;
  GLuint lid = glGenLists(1);
  GLUquadricObj *qobj = gluNewQuadric();

  gluQuadricDrawStyle(qobj, GLU_FILL);
  gluQuadricNormals(qobj, GLU_SMOOTH);
  gluQuadricOrientation(qobj, GLU_INSIDE);
  gluQuadricTexture(qobj, GL_TRUE);

  glNewList(lid, GL_COMPILE);
    gluSphere(qobj, 10.0f, 16, 16);
  glEndList();

  for (i = 0; i < cur_seedpoint; i++)
  {
    float color_scale = (float)i/MAX_SEEDPOINTS;

    glColor3f(color_scale, 1.0f - color_scale, 0.0f);

    glPushMatrix();
      glLoadIdentity();
      glTranslatef(seedpoints[i].x - (winWidth/2), -(seedpoints[i].y - (winHeight/2)), seedpoints[i].z);
      glCallList(lid);
    glPopMatrix();
  }

  gluDeleteQuadric(qobj);
  glDeleteLists(lid, 1);

}

int get_cur_seedpoint(void)
{
  return cur_seedpoint;
}

void set_cur_seedpoint(int seed_nr)
{
  cur_seedpoint = seed_nr;
}

struct point get_seedpoint(int index)
{
  struct point p;

  p.x = seedpoints[index].x;
  p.y = seedpoints[index].y;
  p.z = seedpoints[index].z;

  return p;
}