Small OpenGL based c++ rendering library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glcolor.cpp 751B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "glcolor.h"
  2. GLColor::GLColor() {
  3. set(0.0f, 0.0f, 0.0f, 1.0f);
  4. setalpha = true;
  5. }
  6. GLColor::GLColor(float _r, float _g, float _b, float _a) {
  7. set(_r, _g, _b, _a);
  8. }
  9. GLColor::GLColor(const SDL_Color &c) {
  10. set(c.r/255.0f, c.g/255.0f, c.b/255.0f);
  11. setalpha = true;
  12. }
  13. void GLColor::set(float _r, float _g, float _b, float _a) {
  14. r = _r;
  15. g = _g;
  16. b = _b;
  17. a = _a;
  18. }
  19. SDL_Color GLColor::getSDLColor() {
  20. SDL_Color c = {(Uint8)(r*255.0f), (Uint8)(g*255), (Uint8)(b*255), (Uint8)(a*255)};
  21. return c;
  22. }
  23. void GLColor::print(std::string m) {
  24. std::cout << m << " Color: " << r << ", " << g << ", " << b << std::endl;
  25. }
  26. void glColorGLC(GLColor c) {
  27. if(c.setalpha) {
  28. glColor4f(c.r, c.g, c.b, c.a);
  29. } else {
  30. glColor3f(c.r, c.g, c.b);
  31. }
  32. }