#ifndef WC3RE_RENDER_PROGRAMPROVIDER_HH__ #define WC3RE_RENDER_PROGRAMPROVIDER_HH__ #include #include "Singleton.hh" #include "GlResource.hh" namespace render { using ProgramProviderKeyType = std::tuple; } namespace std { template<> struct hash { typedef render::ProgramProviderKeyType argument_type; typedef std::size_t result_type; result_type operator()(argument_type const& s) const { const result_type h1{std::hash()(std::get<0>(s))}; const result_type h2{std::hash()(std::get<1>(s))}; return h1 ^ h2; } }; } namespace render { class ProgramProvider : public Singleton { private: ProgramProvider(); friend class Singleton; public: gl::GLuint getProgram(std::string const& vertexShader, std::string const& fragShader); private: std::unordered_map programCache_; }; } #endif