helper.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // helper.hpp
  3. // graphics
  4. //
  5. // Created by Sam Jaffe on 5/18/19.
  6. // Copyright © 2019 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <string>
  10. #include <utility>
  11. #include "game/math/math_fwd.hpp"
  12. template <typename> class flyweight;
  13. namespace graphics {
  14. class shader;
  15. class shader_program;
  16. struct uniform;
  17. namespace textures {
  18. enum class format { RGB, RGBA };
  19. unsigned int init(format, math::vec2i, void const *);
  20. }
  21. namespace shaders {
  22. enum class type : unsigned int { FRAGMENT, VERTEX };
  23. unsigned int init(type, std::string const &);
  24. unsigned int init(flyweight<shader> const & fragmentShader,
  25. flyweight<shader> const & vertexShader);
  26. void activate(unsigned int id);
  27. int uniform_location(unsigned int id, std::string const & uniform);
  28. }
  29. namespace materials {
  30. void activate(flyweight<shader_program> program,
  31. std::vector<uniform> const & uniforms);
  32. }
  33. }
  34. namespace std {
  35. template <> struct hash<graphics::shaders::type> {
  36. std::size_t operator()(graphics::shaders::type tp) const {
  37. return std::hash<unsigned int>()(static_cast<unsigned int>(tp));
  38. }
  39. };
  40. }