Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cube.hpp"
- #include <windows.h> // only on windows ;)
- #include <GL/glut.h>
- Cube::Cube(float a)
- {
- this->a = a;
- angle = 0;
- }
- void Cube::draw() const
- {
- glTranslatef(0, 0, -150);
- glRotatef(angle, 0, 1, 0);
- glBegin(GL_QUADS);
- // left face
- glColor3f(0.0f, 1.0f, 0.0f);
- glVertex3f(-a/2, a/2, a/2);
- glVertex3f(-a/2,-a/2, a/2);
- glVertex3f(-a/2,-a/2,-a/2);
- glVertex3f(-a/2, a/2,-a/2);
- // right face
- glColor3f(0.0f, 0.0f, 1.0f);
- glVertex3f (a/2, a/2, a/2);
- glVertex3f( a/2,-a/2, a/2);
- glVertex3f( a/2,-a/2,-a/2);
- glVertex3f( a/2, a/2,-a/2);
- // bottom face
- glColor3f(1.0f, 1.0f, 0.0f);
- glVertex3f( a/2,-a/2, a/2);
- glVertex3f(-a/2,-a/2, a/2);
- glVertex3f(-a/2,-a/2,-a/2);
- glVertex3f( a/2,-a/2,-a/2);
- // top face
- glColor3f(1.0f,1.0f, 1.0f);
- glVertex3f( a/2, a/2, a/2);
- glVertex3f(-a/2, a/2, a/2);
- glVertex3f(-a/2, a/2,-a/2);
- glVertex3f( a/2, a/2,-a/2);
- // back face
- glColor3f(1.0f, 0.5f, 0.0f);
- glVertex3f( a/2, a/2,-a/2);
- glVertex3f(-a/2, a/2,-a/2);
- glVertex3f(-a/2,-a/2,-a/2);
- glVertex3f( a/2,-a/2,-a/2);
- // front face
- glColor3f(1.0f, 0.0f, 0.0f);
- glVertex3f( a/2, a/2, a/2);
- glVertex3f(-a/2, a/2, a/2);
- glVertex3f(-a/2,-a/2, a/2);
- glVertex3f( a/2,-a/2, a/2);
- glEnd();
- }
- void Cube::tick()
- {
- angle++;
- }
Advertisement
Add Comment
Please, Sign In to add comment