//
// Created by janco on 6/22/16.
//

#include <GL/freeglut.h>
#include "Object.h"
#include <string>

void Object::quad(int a,int b,int c,int d)
{
    glBegin(GL_QUADS);
    glColor3fv(color[a]);
    glVertex3fv(ver[a]);

    glColor3fv(color[b]);
    glVertex3fv(ver[b]);

    glColor3fv(color[c]);
    glVertex3fv(ver[c]);

    glColor3fv(color[d]);
    glVertex3fv(ver[d]);
    glEnd();
}

void Object::draw() {
    glPushMatrix();

    glTranslatef(position.x, position.y, position.z);
    glRotated(rotation.x, rotation.y, rotation.z, 1);
    glScaled(scale,scale,scale);

    quad(0,3,2,1);
    quad(2,3,7,6);
    quad(0,4,7,3);
    quad(1,2,6,5);
    quad(4,5,6,7);
    quad(0,1,5,4);

    glColor3f(1.0f, 0.0f, 0.0f);//needs to be called before RasterPos
    glRasterPos2i(-1, 2);
    void * font = GLUT_BITMAP_9_BY_15;

    for (std::string::iterator i = text.begin(); i != text.end(); ++i)
    {
        char c = *i;
        //this does nothing, color is fixed for Bitmaps when calling glRasterPos
        //glColor3f(1.0, 0.0, 1.0);
        glutBitmapCharacter(font, c);
    }
    glPopMatrix();

}

