helper.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/graphics/graphics_fwd.h"
  12. #include "game/math/math_fwd.hpp"
  13. namespace graphics {
  14. struct uniform;
  15. namespace textures {
  16. enum class format { RGB, RGBA };
  17. unsigned int init(format, math::vec2i, void const *);
  18. }
  19. namespace shaders {
  20. enum class type : unsigned int { FRAGMENT, VERTEX };
  21. unsigned int init(type, std::string const &);
  22. unsigned int init(identity<shader> const & fragmentShader,
  23. identity<shader> const & vertexShader);
  24. void activate(identity<shader_program> id);
  25. int uniform_location(identity<shader_program> id,
  26. std::string const & uniform);
  27. }
  28. namespace materials {
  29. enum class uniform : unsigned int { NORMAL, DIFFUSE, SPECULAR };
  30. void activate(identity<shader_program> program,
  31. std::vector<graphics::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. template <> struct hash<graphics::materials::uniform> {
  41. std::size_t operator()(graphics::materials::uniform uf) const {
  42. return std::hash<unsigned int>()(static_cast<unsigned int>(uf));
  43. }
  44. };
  45. }