7a69c29f90e00c0c84ba6f165179e9545cd87cc4
[ludumice] / src / tentacle.cc
1 #include <GL/gl.h>
2 #include "tentacle.h"
3
4 Tentacle::Tentacle()
5 {
6 }
7
8 Tentacle::~Tentacle()
9 {
10 }
11
12 bool
13 Tentacle::init()
14 {
15         for (int i=0; i<5; i++) {
16                 add_control_point(Vec3(0.5, i / 10.0, 0.0));
17         }
18         return true;
19 }
20
21 void
22 Tentacle::add_control_point(const Vec3 &point)
23 {
24         cpoints.push_back(point);
25 }
26
27 void
28 Tentacle::draw()
29 {
30         glLineWidth(2.0);
31         glBegin(GL_LINE_STRIP);
32         glColor3f(0.0, 0.0, 1.0);
33         for(size_t i=0; i<cpoints.size(); i++) {
34                 glVertex3f(cpoints[i].x, cpoints[i].y, cpoints[i].z);
35         }
36         glEnd();
37
38         // XXX DEBUG
39         glDisable(GL_DEPTH_TEST);
40         glPointSize(5.0);
41         glBegin(GL_POINTS);
42         glColor3f(1.0, 0.0, 0.0);
43         for(size_t i=0; i<cpoints.size(); i++) {
44                 glVertex3f(cpoints[i].x, cpoints[i].y, 1.0);
45         }
46         glEnd();
47         glEnable(GL_DEPTH_TEST);
48 }