tavli

annotate src/object.cc @ 1:3fcd7b4d631f

board mesh generation
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 22 Jun 2015 05:05:37 +0300
parents
children 893192aea099
rev   line source
nuclear@1 1 #include "object.h"
nuclear@1 2 #include "opengl.h"
nuclear@1 3
nuclear@1 4 Object::Object()
nuclear@1 5 {
nuclear@1 6 mesh = 0;
nuclear@1 7 }
nuclear@1 8
nuclear@1 9 Object::~Object()
nuclear@1 10 {
nuclear@1 11 delete mesh;
nuclear@1 12 }
nuclear@1 13
nuclear@1 14 Matrix4x4 &Object::xform()
nuclear@1 15 {
nuclear@1 16 return matrix;
nuclear@1 17 }
nuclear@1 18
nuclear@1 19 const Matrix4x4 &Object::xform() const
nuclear@1 20 {
nuclear@1 21 return matrix;
nuclear@1 22 }
nuclear@1 23
nuclear@1 24 void Object::set_mesh(Mesh *m)
nuclear@1 25 {
nuclear@1 26 this->mesh = m;
nuclear@1 27 }
nuclear@1 28
nuclear@1 29 Mesh *Object::get_mesh() const
nuclear@1 30 {
nuclear@1 31 return mesh;
nuclear@1 32 }
nuclear@1 33
nuclear@1 34 void Object::draw() const
nuclear@1 35 {
nuclear@1 36 if(!mesh) return;
nuclear@1 37
nuclear@1 38 glMatrixMode(GL_MODELVIEW);
nuclear@1 39 glPushMatrix();
nuclear@1 40 glLoadTransposeMatrixf(matrix[0]);
nuclear@1 41
nuclear@1 42 mesh->draw();
nuclear@1 43
nuclear@1 44 glPopMatrix();
nuclear@1 45 }