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 667B

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