A 2D tile-based sandbox game.
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.

util.h 966B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <stdexcept>
  3. #include <stdint.h>
  4. #include "swan-common/Matrix3.h"
  5. namespace Cygnet {
  6. // I don't want every use of Cygnet to drag in OpenGL headers.
  7. using GLint = int32_t;
  8. using GLuint = uint32_t;
  9. using GLsizei = int32_t;
  10. using GLenum = uint32_t;
  11. using GLfloat = float;
  12. using Mat3gf = SwanCommon::Matrix3<GLfloat>;
  13. struct Color {
  14. float r = 0, g = 0, b = 0, a = 1;
  15. };
  16. struct ByteColor {
  17. uint8_t r = 0, g = 0, b = 0, a = 0;
  18. operator Color() { return { r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }; }
  19. };
  20. struct SDLError: public std::exception {
  21. SDLError(std::string msg): message(std::move(msg)) {}
  22. const char *what() const noexcept override { return message.c_str(); }
  23. std::string message;
  24. };
  25. struct GlError: public std::exception {
  26. GlError(std::string msg): message(std::move(msg)) {}
  27. const char *what() const noexcept override { return message.c_str(); }
  28. std::string message;
  29. };
  30. void sdlCheck(bool ok);
  31. void glCheck();
  32. }