tavli

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/object.cc	Mon Jun 22 05:05:37 2015 +0300
     1.3 @@ -0,0 +1,45 @@
     1.4 +#include "object.h"
     1.5 +#include "opengl.h"
     1.6 +
     1.7 +Object::Object()
     1.8 +{
     1.9 +	mesh = 0;
    1.10 +}
    1.11 +
    1.12 +Object::~Object()
    1.13 +{
    1.14 +	delete mesh;
    1.15 +}
    1.16 +
    1.17 +Matrix4x4 &Object::xform()
    1.18 +{
    1.19 +	return matrix;
    1.20 +}
    1.21 +
    1.22 +const Matrix4x4 &Object::xform() const
    1.23 +{
    1.24 +	return matrix;
    1.25 +}
    1.26 +
    1.27 +void Object::set_mesh(Mesh *m)
    1.28 +{
    1.29 +	this->mesh = m;
    1.30 +}
    1.31 +
    1.32 +Mesh *Object::get_mesh() const
    1.33 +{
    1.34 +	return mesh;
    1.35 +}
    1.36 +
    1.37 +void Object::draw() const
    1.38 +{
    1.39 +	if(!mesh) return;
    1.40 +
    1.41 +	glMatrixMode(GL_MODELVIEW);
    1.42 +	glPushMatrix();
    1.43 +	glLoadTransposeMatrixf(matrix[0]);
    1.44 +
    1.45 +	mesh->draw();
    1.46 +
    1.47 +	glPopMatrix();
    1.48 +}