#ifndef GL_RENDER_OBJECT_HPP_ #define GL_RENDER_OBJECT_HPP_ #include #include #include #include #include "ZydecoCommon.hpp" class GLProgram; class GLTexture; enum class glUniformType { FLOAT, DOUBLE, INT, UINT, MAT4 }; struct glUniform { public: enum glUniformType type; uint8_t quantity; void **data; }; class GLRenderObject { public: void RenderEnable(); void RenderDisable(); 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::DOUBLE; } 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 if (std::is_same::value) { uniform.type = glUniformType::MAT4; } 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)); } void AddTexture(uint64_t texture_unit, GLTexture *texture); protected: friend class Renderer; GLRenderObject(std::string gl_program_name, uint64_t render_order); ~GLRenderObject(); virtual void Render() = 0; static std::map>& GetRenderObjects(); void GLTargetSetup(); bool m_renderEnabled; private: static std::map> s_renderObjects; GLProgram *m_glProgram; uint64_t m_renderOrder; std::map m_uniforms; std::map m_textures; }; #endif /* GL_RENDER_OBJECT_HPP_ */