Text.cpp 496 B

12345678910111213141516171819202122232425262728293031
  1. #include "Text.h"
  2. Text::Text(const std::string &text, Vec2f position) : MenuElement(position)
  3. {
  4. this->text = text;
  5. color = Vec3f(50, 150, 150);
  6. textHeight = 14;
  7. textWidth = Util::glutTextWidth(text);
  8. }
  9. Text::~Text()
  10. {
  11. }
  12. void Text::draw()
  13. {
  14. glColor4f(color.x/255.0f, color.y/255.0f, color.z/255.0f, 1.0f);
  15. Util::glutBitmapString(text, position.x-1, position.y+textHeight);
  16. }
  17. void Text::update(int x, int y)
  18. {
  19. //Do nothing
  20. }
  21. void Text::setColor(Vec3f color)
  22. {
  23. this->color = color;
  24. }