volmetrics

view src/mesh.cc @ 21:c22866ecb7ae

frame :p
author Eleni Maria Stea <elene.mst@gmail.com>
date Tue, 25 Mar 2014 00:17:39 +0200
parents 928954bfefd7
children df4a277adb82
line source
1 #include <GL/gl.h>
2 #include "mesh.h"
4 Mesh::Mesh()
5 {
6 }
8 void Mesh::add_vertex(const Vector3 &vertex)
9 {
10 vertices.push_back(vertex);
11 }
13 void Mesh::add_normal(const Vector3 &normal)
14 {
15 normals.push_back(normal);
16 }
18 void Mesh::clear()
19 {
20 vertices.clear();
21 normals.clear();
22 }
24 bool Mesh::is_empty() const
25 {
26 return vertices.empty();
27 }
29 void Mesh::draw() const
30 {
31 size_t sz = vertices.size();
33 if(normals.size() != sz)
34 return;
36 glBegin(GL_TRIANGLES);
37 for(size_t i=0; i<sz; i++) {
38 const Vector3 &n = normals[i];
39 glNormal3f(n.x, n.y, n.z);
41 const Vector3 &v = vertices[i];
42 glVertex3f(v.x, v.y, v.z);
43 }
44 glEnd();
45 }