#pragma once // #include #include #include #include #include #include #include /// #include #include #include #include #define LT_MAX_QUAD_RENDERER_VERTICES (1028u * 4u) #define LT_MAX_TEXTURE_RENDERER_VERTICES (1028u * 4u) #define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES (1028u * 4u) struct GLFWwindow; namespace lt { class ConstantBuffer; class Framebuffer; class RenderCommand; class Texture; class SharedContext; class Camera; class WindowResizedEvent; class Shader; class Renderer { public: struct CreateInfo { Ref quad_renderer_shader; Ref texture_renderer_shader; Ref tinted_texture_renderer_shader; }; static auto create( GLFWwindow *windowHandle, Ref sharedContext, CreateInfo create_info ) -> Scope; static void draw_quad( const math::vec3 &position, const math::vec2 &size, const math::vec4 &tint, Ref texture ) { s_context->draw_quad_impl(position, size, tint, std::move(texture)); } static void draw_quad( const math::vec3 &position, const math::vec2 &size, const math::vec4 &tint ) { s_context->draw_quad_impl(position, size, tint); } static void draw_quad(const math::vec3 &position, const math::vec2 &size, Ref texture) { s_context->draw_quad_impl(position, size, std::move(texture)); } static void draw_quad( const math::mat4 &transform, const math::vec4 &tint, const Ref &texture ) { s_context->draw_quad_impl(transform, tint, texture); } static void draw_quad(const math::mat4 &transform, const math::vec4 &tint) { s_context->draw_quad_impl(transform, tint); } static void draw_quad(const math::mat4 &transform, const Ref &texture) { s_context->draw_quad_impl(transform, texture); } static void begin_scene( Camera *camera, const math::mat4 &cameraTransform, const Ref &targetFrameBuffer = nullptr ) { s_context->begin_scene_impl(camera, cameraTransform, targetFrameBuffer); } static void end_scene() { s_context->end_scene_impl(); } void on_window_resize(const WindowResizedEvent &event); void begin_frame(); void end_frame(); private: static Renderer *s_context; QuadRendererProgram m_quad_renderer; TextureRendererProgram m_texture_renderer; TintedTextureRendererProgram m_tinted_texture_renderer; Scope m_view_projection_buffer; Scope m_render_command; Scope m_blender; Camera *m_default_framebuffer_camera { nullptr }; Ref m_target_framebuffer; bool m_should_clear_backbuffer { false }; Renderer( GLFWwindow *window_handle, const Ref &shared_context, CreateInfo create_info ); void draw_quad_impl( const math::vec3 &position, const math::vec2 &size, const math::vec4 &tint, Ref texture ); void draw_quad_impl(const math::vec3 &position, const math::vec2 &size, const math::vec4 &tint); void draw_quad_impl(const math::vec3 &position, const math::vec2 &size, Ref texture); void draw_quad_impl( const math::mat4 &transform, const math::vec4 &tint, const Ref &texture ); void draw_quad_impl(const math::mat4 &transform, const math::vec4 &tint); void draw_quad_impl(const math::mat4 &transform, const Ref &texture); void begin_scene_impl( Camera *camera, const math::mat4 &cameraTransform, const Ref &targetFrameBuffer = nullptr ); void flush_scene(); void end_scene_impl(); }; } // namespace lt