Object.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // Created by janco on 6/22/16.
  3. //
  4. #include <GL/freeglut.h>
  5. #include "Object.h"
  6. #include <string>
  7. void Object::quad(int a,int b,int c,int d)
  8. {
  9. glBegin(GL_QUADS);
  10. glColor3fv(color[a]);
  11. glVertex3fv(ver[a]);
  12. glColor3fv(color[b]);
  13. glVertex3fv(ver[b]);
  14. glColor3fv(color[c]);
  15. glVertex3fv(ver[c]);
  16. glColor3fv(color[d]);
  17. glVertex3fv(ver[d]);
  18. glEnd();
  19. }
  20. void Object::draw() {
  21. glPushMatrix();
  22. glTranslatef(position.x, position.y, position.z);
  23. glRotated(rotation.x, rotation.y, rotation.z, 1);
  24. glScaled(scale,scale,scale);
  25. quad(0,3,2,1);
  26. quad(2,3,7,6);
  27. quad(0,4,7,3);
  28. quad(1,2,6,5);
  29. quad(4,5,6,7);
  30. quad(0,1,5,4);
  31. glColor3f(1.0f, 0.0f, 0.0f);//needs to be called before RasterPos
  32. glRasterPos2i(-1, 2);
  33. void * font = GLUT_BITMAP_9_BY_15;
  34. for (std::string::iterator i = text.begin(); i != text.end(); ++i)
  35. {
  36. char c = *i;
  37. //this does nothing, color is fixed for Bitmaps when calling glRasterPos
  38. //glColor3f(1.0, 0.0, 1.0);
  39. glutBitmapCharacter(font, c);
  40. }
  41. glPopMatrix();
  42. }