RandomObject.cpp 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // Created by janco on 6/22/16.
  3. //
  4. #include <GL/gl.h>
  5. #include <GL/freeglut.h>
  6. #include "RandomObject.h"
  7. RandomObject::RandomObject(){
  8. for(int i = 0; i < 100; i++){
  9. randomobject.push_back(Vec3f(rand()%200*100, rand()%200*100, rand()%200*100));
  10. }
  11. }
  12. void RandomObject::draw() {
  13. glPushMatrix();
  14. glTranslatef(position.x, position.y, position.z);
  15. glRotated(rotation.x, rotation.y, rotation.z, 1);
  16. glScaled(scale,scale,scale);
  17. glBegin(GL_TRIANGLES);
  18. glVertex3f(-3.0, -5.0, 0.0);
  19. glVertex3f(4.0, 3.0, 2.0);
  20. glVertex3f(1.5, 2.0, 6.0);
  21. glEnd();
  22. glColor3f(1.0f, 0.0f, 0.0f);//needs to be called before RasterPos
  23. glRasterPos2i(-1, 2);
  24. void * font = GLUT_BITMAP_9_BY_15;
  25. for (std::string::iterator i = text.begin(); i != text.end(); ++i)
  26. {
  27. char c = *i;
  28. //this does nothing, color is fixed for Bitmaps when calling glRasterPos
  29. //glColor3f(1.0, 0.0, 1.0);
  30. glutBitmapCharacter(font, c);
  31. }
  32. glPopMatrix();
  33. }