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

12345678910111213141516171819202122232425262728293031323334353637
  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 GlError: public std::exception {
  21. GlError(std::string msg): message(std::move(msg)) {}
  22. const char *what() const noexcept override { return message.c_str(); }
  23. std::string message;
  24. };
  25. void glCheck();
  26. }