#pragma once #include "opengl/handles/shader_program_handle.hpp" #include "rendering/batches/mesh_batch.hpp" #include "assets/components/mesh_vertex_components.hpp" #include "assets/components/material_components.hpp" #include "opengl/handles/material_handle.hpp" #include #include "geometry/aabb.hpp" #include "rendering/modes/mesh_modes.hpp" #include "rendering/shader_program_lookups/mesh_lookup.hpp" #include "scene/lighting_setup.hpp" namespace rendering { class mesh_batch_renderer { public: using batch_components_type = std::pair< mesh_vertex_components::flags, material_component::flags >; using batch_type = mesh_batch; using batch_index_type = ztu::u32; using batch_id_type = batch_index_type; using id_type = std::pair; explicit mesh_batch_renderer(int render_mode_count); std::optional add( const batch_components_type& batch_component, const zgl::mesh_handle& mesh, const aabb& bounding_box, const zgl::model_matrix_handle& transform, const zgl::material_handle& material, const shader_program_lookups::mesh_lookup& shader_program_lookup ); std::optional bounding_box(id_type); bool remove(id_type mesh_id); void render( modes::mesh render_mode, const glm::mat4& vp_matrix, const glm::mat4& view_matrix, const glm::vec3& view_pos, const lighting_setup& lights ); protected: [[nodiscard]] std::pair lookup_batch(const batch_components_type& batch_components) const; private: int m_render_mode_count; std::vector> m_component_lookup{}; std::vector m_id_lookup{}; std::vector> m_batches{}; std::vector m_shader_programs{}; batch_id_type m_next_batch_id{ 0 }; }; }