volmetrics

view src/mesh.cc @ 36:1df14c5ffa71

conversion to Qt
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 06 Feb 2015 22:39:51 +0200
parents 40febfed6cff
children
line source
1 #include "opengl.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 }