#pragma once #include #include #include #include #include #include "glm/glm.hpp" namespace cbt::gfx { enum class primitive_type { triangles }; enum class index_type { uint16, uint32 }; struct attribute_desc { std::uint32_t location = 0; std::uint32_t num_components = 3; std::uint32_t offset = 0; }; struct pipeline_desc { std::span vertex_data{}; std::span index_data{}; std::vector attributes{}; std::uint32_t vertex_stride = 0; char const* vertex_shader_src = nullptr; char const* fragment_shader_src = nullptr; bool depth_test = true; primitive_type primitive = primitive_type::triangles; index_type index_type_ = index_type::uint32; }; class pipeline { public: pipeline(); explicit pipeline(pipeline_desc const& desc); pipeline(pipeline const&) = delete; pipeline(pipeline&& other) noexcept; auto operator=(pipeline const&) -> pipeline& = delete; auto operator=(pipeline&& other) noexcept -> pipeline&; ~pipeline(); auto valid() const -> bool; auto draw(glm::mat4 const& model, glm::mat4 const& view, glm::mat4 const& proj) const -> void; auto bind_texture(char const* sampler_name, std::uint32_t texture_id, std::uint32_t unit = 0) const -> void; auto bind_vec3(char const* name, glm::vec3 const& v) const -> void; auto bind_float(char const* name, float v) const -> void; private: struct impl; std::unique_ptr m_impl; }; class render_target { public: explicit render_target(int width, int height); render_target(render_target const&) = delete; render_target(render_target&& other) noexcept; auto operator=(render_target const&) -> render_target& = delete; auto operator=(render_target&& other) noexcept -> render_target&; ~render_target(); auto bind() const -> void; auto unbind() const -> void; auto color_id() const -> std::uint32_t; auto width() const -> int; auto height() const -> int; auto valid() const -> bool; auto resize(int width, int height) -> void; private: struct impl; std::unique_ptr m_impl; }; } // namespace cbt::gfx