#ifndef GL_RENDER_OBJECT_HPP_ #define GL_RENDER_OBJECT_HPP_ #include #include #include #include #include "ZydecoCommon.hpp" class GLProgram; enum class glUniformType { FLOAT, INT, UINT }; struct glUniform { public: enum glUniformType type; uint8_t quantity; void **data; }; class GLRenderObject { private: static std::map> s_renderObjects; protected: friend class Renderer; GLRenderObject(std::string gl_program_name, uint64_t render_priority); ~GLRenderObject(); void RenderEnable(); void RenderDisable(); public: template constexpr void RenderSetUniform(std::string name, std::array data) { glUniform uniform; if (std::is_same::value) { uniform.type = glUniformType::FLOAT; } else if (std::is_same::value) { uniform.type = glUniformType::INT; } else if (std::is_same::value) { uniform.type = glUniformType::INT; } else if (std::is_same::value) { uniform.type = glUniformType::UINT; } else if (std::is_same::value) { uniform.type = glUniformType::UINT; } else { ZydecoFault("RenderSetUniform({}): Unknown data type {}", name, typeid(T).name()); } uniform.quantity = N; uniform.data = new void *[N]; std::copy(std::begin(data), std::end(data), uniform.data); m_uniforms.insert(std::pair(name, uniform)); } GLProgram *m_glProgram; uint64_t m_renderPriority; bool m_renderEnabled; std::map m_uniforms; void GLTargetSetup(); virtual void Render() = 0; static std::map>& GetRenderObjects(); }; #endif /* GL_RENDER_OBJECT_HPP_ */