diff --git a/modules/engine/include/engine/base/entrypoint.hpp b/modules/engine/include/engine/base/entrypoint.hpp index b80784a..1fa29db 100644 --- a/modules/engine/include/engine/base/entrypoint.hpp +++ b/modules/engine/include/engine/base/entrypoint.hpp @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) extern auto Light::create_application() -> Light::Scope; // #todo: use linux specific stuff -int main(int argc, char *argv[]) +int main(int /*argc*/, char * /*argv*/[]) { auto application = Light::Scope {}; int exitCode = 0; diff --git a/modules/engine/include/engine/camera/camera.hpp b/modules/engine/include/engine/camera/camera.hpp index 5bd2f0f..f9f5f93 100644 --- a/modules/engine/include/engine/camera/camera.hpp +++ b/modules/engine/include/engine/camera/camera.hpp @@ -10,12 +10,12 @@ class Camera public: Camera() = default; - auto get_projection() const -> const glm::mat4 & + [[nodiscard]] auto get_projection() const -> const glm::mat4 & { return m_projection; } - auto get_background_color() const -> const glm::vec4 & + [[nodiscard]] auto get_background_color() const -> const glm::vec4 & { return m_background_color; } @@ -26,7 +26,7 @@ public: } protected: - glm::mat4 m_projection; + glm::mat4 m_projection{}; private: glm::vec4 m_background_color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); diff --git a/modules/engine/include/engine/camera/ortho.hpp b/modules/engine/include/engine/camera/ortho.hpp index 90d37ca..42dd064 100644 --- a/modules/engine/include/engine/camera/ortho.hpp +++ b/modules/engine/include/engine/camera/ortho.hpp @@ -21,17 +21,17 @@ public: void on_resize(const glm::vec2 &size); - auto get_view() const -> const glm::mat4 & + [[nodiscard]] auto get_view() const -> const glm::mat4 & { return m_view; } - auto get_projection() const -> const glm::mat4 & + [[nodiscard]] auto get_projection() const -> const glm::mat4 & { return m_projection; } - auto get_clear_color() const -> const glm::vec4 & + [[nodiscard]] auto get_clear_color() const -> const glm::vec4 & { return m_clear_color; } @@ -47,9 +47,9 @@ private: const glm::vec3 m_up; - glm::mat4 m_projection; + glm::mat4 m_projection{}; - glm::mat4 m_view; + glm::mat4 m_view{}; glm::vec4 m_clear_color; }; diff --git a/modules/engine/include/engine/camera/scene.hpp b/modules/engine/include/engine/camera/scene.hpp index 7f31fcf..9810096 100644 --- a/modules/engine/include/engine/camera/scene.hpp +++ b/modules/engine/include/engine/camera/scene.hpp @@ -50,37 +50,37 @@ public: void set_perspective_near_plane(float nearPlane); - auto get_orthographic_size() const -> float + [[nodiscard]] auto get_orthographic_size() const -> float { return m_orthographic_specification.size; } - auto get_orthographic_far_plane() const -> float + [[nodiscard]] auto get_orthographic_far_plane() const -> float { return m_orthographic_specification.far_plane; } - auto get_orthographic_near_plane() const -> float + [[nodiscard]] auto get_orthographic_near_plane() const -> float { return m_orthographic_specification.near_plane; } - auto get_perspective_vertical_fov() const -> float + [[nodiscard]] auto get_perspective_vertical_fov() const -> float { return m_perspective_specification.vertical_fov; } - auto get_perspective_far_plane() const -> float + [[nodiscard]] auto get_perspective_far_plane() const -> float { return m_perspective_specification.far_plane; } - auto get_perspective_near_plane() const -> float + [[nodiscard]] auto get_perspective_near_plane() const -> float { return m_perspective_specification.near_plane; } - auto get_projection_type() const -> ProjectionType + [[nodiscard]] auto get_projection_type() const -> ProjectionType { return m_projection_type; } @@ -93,7 +93,7 @@ private: float m_aspect_ratio; - ProjectionType m_projection_type; + ProjectionType m_projection_type{ProjectionType::Orthographic}; void calculate_projection(); }; diff --git a/modules/engine/include/engine/core/window.hpp b/modules/engine/include/engine/core/window.hpp index 3ff4832..9708eba 100644 --- a/modules/engine/include/engine/core/window.hpp +++ b/modules/engine/include/engine/core/window.hpp @@ -20,9 +20,9 @@ struct WindowProperties class Window { public: - static Scope create(std::function callback); + static Scope create(const std::function& callback); - Window(): m_graphics_context(nullptr), m_properties {}, b_Closed(false) + Window(): m_graphics_context(nullptr), m_properties {} { } @@ -55,37 +55,37 @@ public: virtual void set_visibility(bool visible, bool toggle = false) = 0; - auto get_graphics_context() const -> GraphicsContext * + [[nodiscard]] auto get_graphics_context() const -> GraphicsContext * { return m_graphics_context.get(); } - auto get_properties() const -> const WindowProperties & + [[nodiscard]] auto get_properties() const -> const WindowProperties & { return m_properties; } - auto get_title() const -> const std::string & + [[nodiscard]] auto get_title() const -> const std::string & { return m_properties.title; } - auto get_size() const -> const glm::uvec2 & + [[nodiscard]] auto get_size() const -> const glm::uvec2 & { return m_properties.size; } - auto is_closed() const -> bool + [[nodiscard]] auto is_closed() const -> bool { return b_Closed; } - auto is_v_sync() const -> bool + [[nodiscard]] auto is_v_sync() const -> bool { return m_properties.vsync; } - auto is_visible() const -> bool + [[nodiscard]] auto is_visible() const -> bool { return m_properties.visible; } @@ -95,7 +95,7 @@ protected: WindowProperties m_properties; - bool b_Closed; + bool b_Closed{false}; }; } // namespace Light diff --git a/modules/engine/include/engine/debug/instrumentor.hpp b/modules/engine/include/engine/debug/instrumentor.hpp index 37c4fe0..b555206 100644 --- a/modules/engine/include/engine/debug/instrumentor.hpp +++ b/modules/engine/include/engine/debug/instrumentor.hpp @@ -37,7 +37,7 @@ private: std::ofstream m_output_file_stream; - unsigned int m_current_session_count; + unsigned int m_current_session_count{0u}; Instrumentor(); diff --git a/modules/engine/include/engine/events/char.hpp b/modules/engine/include/engine/events/char.hpp index fba8329..d530118 100644 --- a/modules/engine/include/engine/events/char.hpp +++ b/modules/engine/include/engine/events/char.hpp @@ -13,12 +13,12 @@ public: { } - auto get_character() const -> int + [[nodiscard]] auto get_character() const -> int { return m_character; } - auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "CharSet: " << m_character; diff --git a/modules/engine/include/engine/events/event.hpp b/modules/engine/include/engine/events/event.hpp index 18d2c50..edd957b 100644 --- a/modules/engine/include/engine/events/event.hpp +++ b/modules/engine/include/engine/events/event.hpp @@ -55,11 +55,11 @@ public: virtual ~Event() = default; - virtual auto get_event_type() const -> EventType = 0; + [[nodiscard]] virtual auto get_event_type() const -> EventType = 0; - virtual auto get_info_lt_log() const -> std::string = 0; + [[nodiscard]] virtual auto get_info_lt_log() const -> std::string = 0; - virtual auto has_category(EventCategory category) const -> bool = 0; + [[nodiscard]] virtual auto has_category(EventCategory category) const -> bool = 0; friend auto operator<<(std::ostream &os, const Event &e) -> std::ostream & { diff --git a/modules/engine/include/engine/events/keyboard.hpp b/modules/engine/include/engine/events/keyboard.hpp index 31b3f15..3e2385d 100644 --- a/modules/engine/include/engine/events/keyboard.hpp +++ b/modules/engine/include/engine/events/keyboard.hpp @@ -13,12 +13,12 @@ public: { } - auto get_key() const -> int + [[nodiscard]] auto get_key() const -> int { return m_key; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "KeyPressed: " << m_key; @@ -40,12 +40,12 @@ public: { } - auto get_key() const -> int + [[nodiscard]] auto get_key() const -> int { return m_key; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "KeyRepeated: " << m_key; @@ -67,12 +67,12 @@ public: { } - auto get_key() const -> int + [[nodiscard]] auto get_key() const -> int { return m_key; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "KeyReleased: " << m_key; diff --git a/modules/engine/include/engine/events/mouse.hpp b/modules/engine/include/engine/events/mouse.hpp index 1e44c13..a112f73 100644 --- a/modules/engine/include/engine/events/mouse.hpp +++ b/modules/engine/include/engine/events/mouse.hpp @@ -14,22 +14,22 @@ public: { } - auto get_position() const -> const glm::vec2 & + [[nodiscard]] auto get_position() const -> const glm::vec2 & { return m_position; } - auto get_x() const -> float + [[nodiscard]] auto get_x() const -> float { return m_position.x; } - auto get_y() const -> float + [[nodiscard]] auto get_y() const -> float { return m_position.y; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "MouseMoved: " << m_position.x << ", " << m_position.y; @@ -51,12 +51,12 @@ public: { } - auto get_offset() const -> float + [[nodiscard]] auto get_offset() const -> float { return m_offset; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "WheelScrolled: " << m_offset; @@ -78,12 +78,12 @@ public: { } - auto get_button() const -> int + [[nodiscard]] auto get_button() const -> int { return m_button; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "ButtonPressed: " << m_button; @@ -105,12 +105,12 @@ public: { } - auto get_button() const -> int + [[nodiscard]] auto get_button() const -> int { return m_button; } - virtual auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "ButtonReleased: " << m_button; diff --git a/modules/engine/include/engine/events/window.hpp b/modules/engine/include/engine/events/window.hpp index 00fe178..91547b0 100644 --- a/modules/engine/include/engine/events/window.hpp +++ b/modules/engine/include/engine/events/window.hpp @@ -10,7 +10,7 @@ namespace Light { class WindowClosedEvent: public Event { public: - auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { return "WindowClosedEvent"; } @@ -27,12 +27,12 @@ public: { } - auto get_position() const -> const glm::ivec2 & + [[nodiscard]] auto get_position() const -> const glm::ivec2 & { return m_position; } - auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "WindwoMoved: " << m_position.x << ", " << m_position.y; @@ -55,12 +55,12 @@ public: { } - auto get_size() const -> const glm::uvec2 & + [[nodiscard]] auto get_size() const -> const glm::uvec2 & { return m_size; } - auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { std::stringstream ss; ss << "WindowResized: " << m_size.x << ", " << m_size.y; @@ -78,7 +78,7 @@ private: class WindowLostFocusEvent: public Event { public: - auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { return "WindowLostFocus"; } @@ -91,7 +91,7 @@ public: class WindowGainFocusEvent: public Event { public: - auto get_info_lt_log() const -> std::string override + [[nodiscard]] auto get_info_lt_log() const -> std::string override { return "WindowGainFocus"; } diff --git a/modules/engine/include/engine/graphics/blender.hpp b/modules/engine/include/engine/graphics/blender.hpp index 87df726..3dd8d5d 100644 --- a/modules/engine/include/engine/graphics/blender.hpp +++ b/modules/engine/include/engine/graphics/blender.hpp @@ -37,7 +37,8 @@ enum class BlendFactor : uint8_t class Blender { public: - static auto create(Ref sharedContext) -> Scope; +virtual ~Blender() = default; + static auto create(const Ref& sharedContext) -> Scope; virtual void enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; diff --git a/modules/engine/include/engine/graphics/buffers.hpp b/modules/engine/include/engine/graphics/buffers.hpp index 2c47541..eff7243 100644 --- a/modules/engine/include/engine/graphics/buffers.hpp +++ b/modules/engine/include/engine/graphics/buffers.hpp @@ -14,10 +14,11 @@ enum class ConstantBufferIndex class ConstantBuffer { public: +virtual ~ConstantBuffer() = default; static auto create( ConstantBufferIndex index, unsigned int size, - Ref sharedContext + const Ref& sharedContext ) -> Scope; virtual auto map() -> void * = 0; @@ -37,7 +38,7 @@ public: float *vertices, unsigned int stride, unsigned int count, - Ref sharedContext + const Ref& sharedContext ) -> Ref; virtual ~VertexBuffer() = default; @@ -57,7 +58,7 @@ protected: class IndexBuffer { public: - static auto create(unsigned int *indices, unsigned int count, Ref sharedContext) + static auto create(unsigned int *indices, unsigned int count, const Ref& sharedContext) -> Ref; virtual ~IndexBuffer() = default; diff --git a/modules/engine/include/engine/graphics/framebuffer.hpp b/modules/engine/include/engine/graphics/framebuffer.hpp index f4765fb..695a62a 100644 --- a/modules/engine/include/engine/graphics/framebuffer.hpp +++ b/modules/engine/include/engine/graphics/framebuffer.hpp @@ -9,9 +9,9 @@ class SharedContext; struct FramebufferSpecification { - unsigned int width; + unsigned int width{}; - unsigned int height; + unsigned int height{}; unsigned int samples = 1; }; @@ -19,9 +19,10 @@ struct FramebufferSpecification class Framebuffer { public: +virtual ~Framebuffer() = default; static auto create( const FramebufferSpecification &specification, - Ref sharedContext + const Ref& sharedContext ) -> Ref; virtual void bind_as_target(const glm::vec4 &clearColor) = 0; diff --git a/modules/engine/include/engine/graphics/render_command.hpp b/modules/engine/include/engine/graphics/render_command.hpp index fc5faba..3bce766 100644 --- a/modules/engine/include/engine/graphics/render_command.hpp +++ b/modules/engine/include/engine/graphics/render_command.hpp @@ -12,7 +12,7 @@ class SharedContext; class RenderCommand { public: - static auto create(GLFWwindow *windowHandle, Ref sharedContext) + static auto create(GLFWwindow *windowHandle, const Ref& sharedContext) -> Scope; RenderCommand(const RenderCommand &) = delete; diff --git a/modules/engine/include/engine/graphics/renderer.hpp b/modules/engine/include/engine/graphics/renderer.hpp index ff0be54..1970296 100644 --- a/modules/engine/include/engine/graphics/renderer.hpp +++ b/modules/engine/include/engine/graphics/renderer.hpp @@ -4,10 +4,11 @@ #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 +#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; @@ -35,7 +36,7 @@ public: Ref texture ) { - s_context->draw_quad_impl(position, size, tint, texture); + s_context->draw_quad_impl(position, size, tint, std::move(texture)); } static void draw_quad(const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint) @@ -45,12 +46,12 @@ public: static void draw_quad(const glm::vec3 &position, const glm::vec2 &size, Ref texture) { - s_context->draw_quad_impl(position, size, texture); + s_context->draw_quad_impl(position, size, std::move(texture)); } static void draw_quad(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture) { - s_context->draw_quad_impl(transform, tint, texture); + s_context->draw_quad_impl(transform, tint, std::move(texture)); } static void draw_quad(const glm::mat4 &transform, const glm::vec4 &tint) @@ -60,7 +61,7 @@ public: static void draw_quad(const glm::mat4 &transform, Ref texture) { - s_context->draw_quad_impl(transform, texture); + s_context->draw_quad_impl(transform, std::move(texture)); } static void begin_scene( @@ -98,13 +99,13 @@ private: Scope m_blender; - Camera *m_default_framebuffer_camera; + Camera *m_default_framebuffer_camera { nullptr }; Ref m_target_framebuffer; - bool m_should_clear_backbuffer; + bool m_should_clear_backbuffer { false }; - Renderer(GLFWwindow *windowHandle, Ref sharedContext); + Renderer(GLFWwindow *windowHandle, const Ref &sharedContext); void draw_quad_impl( const glm::vec3 &position, @@ -117,11 +118,15 @@ private: void draw_quad_impl(const glm::vec3 &position, const glm::vec2 &size, Ref texture); - void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture); + void draw_quad_impl( + const glm::mat4 &transform, + const glm::vec4 &tint, + const Ref &texture + ); void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint); - void draw_quad_impl(const glm::mat4 &transform, Ref texture); + void draw_quad_impl(const glm::mat4 &transform, const Ref &texture); void begin_scene_impl( Camera *camera, diff --git a/modules/engine/include/engine/graphics/renderer_programs/quad.hpp b/modules/engine/include/engine/graphics/renderer_programs/quad.hpp index 51a8982..c1dd5df 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/quad.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/quad.hpp @@ -16,13 +16,14 @@ class SharedContext; class QuadRendererProgram: RendererProgram { public: +virtual ~QuadRendererProgram() = default; struct QuadVertexData { glm::vec4 position; glm::vec4 tint; }; - QuadRendererProgram(unsigned int maxVertices, Ref sharedContext); + QuadRendererProgram(unsigned int maxVertices, const Ref& sharedContext); auto advance() -> bool; @@ -37,12 +38,12 @@ public: return m_map_current; } - auto get_quad_count() const -> unsigned int + [[nodiscard]] auto get_quad_count() const -> unsigned int { return m_quad_count; } - constexpr auto get_vertex_size() const -> unsigned int + [[nodiscard]] constexpr auto get_vertex_size() const -> unsigned int { return sizeof(QuadVertexData); } diff --git a/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp b/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp index 3ff0c5c..fe674f4 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp @@ -13,6 +13,8 @@ class RendererProgram virtual void un_map() = 0; virtual void bind() = 0; +public: +virtual ~RendererProgram() = default; }; } // namespace Light diff --git a/modules/engine/include/engine/graphics/renderer_programs/texture.hpp b/modules/engine/include/engine/graphics/renderer_programs/texture.hpp index e0ded45..e9ebedb 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/texture.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/texture.hpp @@ -16,6 +16,7 @@ class SharedContext; class TextureRendererProgram: RendererProgram { public: +virtual ~TextureRendererProgram() = default; struct TextureVertexData { glm::vec4 position; @@ -23,7 +24,7 @@ public: glm::vec2 texcoord; }; - TextureRendererProgram(unsigned int maxVertices, Ref sharedContext); + TextureRendererProgram(unsigned int maxVertices, const Ref& sharedContext); auto advance() -> bool; @@ -38,12 +39,12 @@ public: return m_map_current; } - auto get_quad_count() const -> unsigned int + [[nodiscard]] auto get_quad_count() const -> unsigned int { return m_quad_count; } - constexpr auto get_vertex_size() const -> unsigned int + [[nodiscard]] constexpr auto get_vertex_size() const -> unsigned int { return sizeof(TextureVertexData); } @@ -61,7 +62,7 @@ private: TextureVertexData *m_map_end = nullptr; - unsigned int m_quad_count; + unsigned int m_quad_count{0u}; unsigned int m_max_vertices; }; diff --git a/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp b/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp index 84c4152..2fff668 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp @@ -16,6 +16,7 @@ class SharedContext; class TintedTextureRendererProgram: RendererProgram { public: +virtual ~TintedTextureRendererProgram() = default; struct TintedTextureVertexData { glm::vec4 position; @@ -25,7 +26,7 @@ public: glm::vec2 texcoord; }; - TintedTextureRendererProgram(unsigned int maxVertices, Ref sharedContext); + TintedTextureRendererProgram(unsigned int maxVertices, const Ref& sharedContext); auto advance() -> bool; @@ -40,12 +41,12 @@ public: return m_map_current; } - auto get_quad_count() const -> unsigned int + [[nodiscard]] auto get_quad_count() const -> unsigned int { return m_quad_count; } - constexpr auto get_vertex_size() const -> unsigned int + [[nodiscard]] constexpr auto get_vertex_size() const -> unsigned int { return sizeof(TintedTextureVertexData); } @@ -63,7 +64,7 @@ private: TintedTextureVertexData *m_map_end = nullptr; - unsigned int m_quad_count; + unsigned int m_quad_count{0u}; unsigned int m_max_vertices; }; diff --git a/modules/engine/include/engine/graphics/shader.hpp b/modules/engine/include/engine/graphics/shader.hpp index 21c568e..0982cab 100644 --- a/modules/engine/include/engine/graphics/shader.hpp +++ b/modules/engine/include/engine/graphics/shader.hpp @@ -20,9 +20,9 @@ public: }; static auto create( - BasicFileHandle vertexFile, - BasicFileHandle pixelFile, - Ref sharedContext + const BasicFileHandle& vertexFile, + const BasicFileHandle& pixelFile, + const Ref& sharedContext ) -> Ref; virtual ~Shader() = default; diff --git a/modules/engine/include/engine/graphics/texture.hpp b/modules/engine/include/engine/graphics/texture.hpp index daebfbd..9d9ef75 100644 --- a/modules/engine/include/engine/graphics/texture.hpp +++ b/modules/engine/include/engine/graphics/texture.hpp @@ -14,7 +14,7 @@ public: unsigned int height, unsigned int components, unsigned char *pixels, - Ref sharedContext, + const Ref& sharedContext, const std::string &filePath ); @@ -28,7 +28,7 @@ public: virtual auto get_texture() -> void * = 0; - auto GetFilePath() const -> const std::string & + [[nodiscard]] auto GetFilePath() const -> const std::string & { return m_file_path; } @@ -36,7 +36,7 @@ public: protected: std::string m_file_path; - Texture(const std::string &filePath); + Texture(std::string filePath); }; } // namespace Light diff --git a/modules/engine/include/engine/graphics/vertex_layout.hpp b/modules/engine/include/engine/graphics/vertex_layout.hpp index 27fd5a1..be55c94 100644 --- a/modules/engine/include/engine/graphics/vertex_layout.hpp +++ b/modules/engine/include/engine/graphics/vertex_layout.hpp @@ -34,10 +34,10 @@ class VertexLayout { public: static auto create( - Ref vertexBuffer, - Ref shader, + const Ref& vertexBuffer, + const Ref& shader, const std::vector> &elements, - Ref sharedContext + const Ref& sharedContext ) -> Ref; virtual ~VertexLayout() = default; diff --git a/modules/engine/include/engine/input/input.hpp b/modules/engine/include/engine/input/input.hpp index 7209389..a6b5c85 100644 --- a/modules/engine/include/engine/input/input.hpp +++ b/modules/engine/include/engine/input/input.hpp @@ -31,19 +31,19 @@ public: return s_context->m_mouse_buttons[code]; } - static auto get_mouse_position(int code) -> const glm::vec2 & + static auto get_mouse_position(int /*code*/) -> const glm::vec2 & { return s_context->m_mouse_position; } void on_event(const Event &inputEvent); - auto is_receiving_input_events() const -> bool + [[nodiscard]] auto is_receiving_input_events() const -> bool { return m_user_interface_events; } - auto is_receiving_game_events() const -> bool + [[nodiscard]] auto is_receiving_game_events() const -> bool { return m_game_events; } @@ -51,19 +51,19 @@ public: private: static Input *s_context; - std::array m_keyboad_keys; + std::array m_keyboad_keys{}; - std::array m_mouse_buttons; + std::array m_mouse_buttons{}; glm::vec2 m_mouse_position; glm::vec2 m_mouse_delta; - float m_mouse_wheel_delta; + float m_mouse_wheel_delta{}; - bool m_user_interface_events; + bool m_user_interface_events{true}; - bool m_game_events; + bool m_game_events{true}; Input(); diff --git a/modules/engine/include/engine/input/key_codes.hpp b/modules/engine/include/engine/input/key_codes.hpp index 887ed2a..ce6e247 100644 --- a/modules/engine/include/engine/input/key_codes.hpp +++ b/modules/engine/include/engine/input/key_codes.hpp @@ -2,9 +2,9 @@ #include -namespace Light { -namespace Key { + +namespace Light::Key { enum : uint16_t { /* digits */ @@ -179,4 +179,4 @@ enum : uint16_t }; } -} // namespace Light + diff --git a/modules/engine/include/engine/input/mouse_codes.hpp b/modules/engine/include/engine/input/mouse_codes.hpp index 6840792..01d00d5 100644 --- a/modules/engine/include/engine/input/mouse_codes.hpp +++ b/modules/engine/include/engine/input/mouse_codes.hpp @@ -2,9 +2,9 @@ #include -namespace Light { -namespace Mouse { + +namespace Light::Mouse { enum : uint8_t { Button1 = 0, @@ -22,4 +22,4 @@ enum : uint8_t }; } -} // namespace Light + diff --git a/modules/engine/include/engine/layer/layer.hpp b/modules/engine/include/engine/layer/layer.hpp index d07af59..2f77b77 100644 --- a/modules/engine/include/engine/layer/layer.hpp +++ b/modules/engine/include/engine/layer/layer.hpp @@ -24,11 +24,11 @@ class WindowGainFocusEvent; class Layer { public: - Layer(const std::string &name); + Layer(std::string name); virtual ~Layer() = default; - auto get_name() const -> const std::string & + [[nodiscard]] auto get_name() const -> const std::string & { return m_layer_name; } @@ -49,67 +49,67 @@ public: protected: std::string m_layer_name; - virtual auto on_mouse_moved(const MouseMovedEvent &event) -> bool + virtual auto on_mouse_moved(const MouseMovedEvent & /*event*/) -> bool { return false; } - virtual auto on_button_pressed(const ButtonPressedEvent &event) -> bool + virtual auto on_button_pressed(const ButtonPressedEvent & /*event*/) -> bool { return false; } - virtual auto on_button_released(const ButtonReleasedEvent &event) -> bool + virtual auto on_button_released(const ButtonReleasedEvent & /*event*/) -> bool { return false; } - virtual auto on_wheel_scrolled(const WheelScrolledEvent &event) -> bool + virtual auto on_wheel_scrolled(const WheelScrolledEvent & /*event*/) -> bool { return false; } - virtual auto on_key_pressed(const KeyPressedEvent &event) -> bool + virtual auto on_key_pressed(const KeyPressedEvent & /*event*/) -> bool { return false; } - virtual auto on_key_repeat(const KeyRepeatEvent &event) -> bool + virtual auto on_key_repeat(const KeyRepeatEvent & /*event*/) -> bool { return false; } - virtual auto on_key_released(const KeyReleasedEvent &event) -> bool + virtual auto on_key_released(const KeyReleasedEvent & /*event*/) -> bool { return false; } - virtual auto on_set_char(const SetCharEvent &event) -> bool + virtual auto on_set_char(const SetCharEvent & /*event*/) -> bool { return false; } - virtual auto on_window_closed(const WindowClosedEvent &event) -> bool + virtual auto on_window_closed(const WindowClosedEvent & /*event*/) -> bool { return false; } - virtual auto on_window_resized(const WindowResizedEvent &event) -> bool + virtual auto on_window_resized(const WindowResizedEvent & /*event*/) -> bool { return false; } - virtual auto on_window_moved(const WindowMovedEvent &event) -> bool + virtual auto on_window_moved(const WindowMovedEvent & /*event*/) -> bool { return false; } - virtual auto on_window_lost_focus(const WindowLostFocusEvent &event) -> bool + virtual auto on_window_lost_focus(const WindowLostFocusEvent & /*event*/) -> bool { return false; } - virtual auto on_window_gain_focus(const WindowGainFocusEvent &event) -> bool + virtual auto on_window_gain_focus(const WindowGainFocusEvent & /*event*/) -> bool { return false; } diff --git a/modules/engine/include/engine/math/random.hpp b/modules/engine/include/engine/math/random.hpp index 2e870c3..20895c1 100644 --- a/modules/engine/include/engine/math/random.hpp +++ b/modules/engine/include/engine/math/random.hpp @@ -7,8 +7,8 @@ #include -namespace Light { -namespace Math { + +namespace Light::Math { auto rand(int min, int max, int decimals = 0) -> float; @@ -16,5 +16,5 @@ auto rand_vec2(int min, int max, int decimals = 0) -> glm::vec2; auto rand_vec3(int min, int max, int decimals = 0) -> glm::vec3; -} // namespace Math -} // namespace Light +} // namespace Light::Math + diff --git a/modules/engine/include/engine/platform/graphics/opengl/blender.hpp b/modules/engine/include/engine/platform/graphics/opengl/blender.hpp index 3e02e63..ebf412d 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/blender.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/blender.hpp @@ -8,6 +8,7 @@ namespace Light { class glBlender: public Blender { public: +virtual ~glBlender() = default; glBlender(); void enable(BlendFactor srcFactor, BlendFactor dstFactor) override; diff --git a/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp b/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp index f567061..cb83c89 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp @@ -10,7 +10,7 @@ class glConstantBuffer: public ConstantBuffer public: glConstantBuffer(ConstantBufferIndex index, unsigned int size); - ~glConstantBuffer(); + virtual ~glConstantBuffer(); void bind() override; @@ -29,7 +29,7 @@ class glVertexBuffer: public VertexBuffer public: glVertexBuffer(float *vertices, unsigned int stride, unsigned int count); - ~glVertexBuffer(); + ~glVertexBuffer() override; void bind() override; @@ -48,7 +48,7 @@ class glIndexBuffer: public IndexBuffer public: glIndexBuffer(unsigned int *indices, unsigned int count); - ~glIndexBuffer(); + ~glIndexBuffer() override; void bind() override; diff --git a/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp b/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp index 743bbf9..0866204 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp @@ -10,7 +10,7 @@ class glFramebuffer: public Framebuffer public: glFramebuffer(const FramebufferSpecification &specification); - ~glFramebuffer(); + virtual ~glFramebuffer(); void bind_as_target(const glm::vec4 &clearColor) override; diff --git a/modules/engine/include/engine/platform/graphics/opengl/shader.hpp b/modules/engine/include/engine/platform/graphics/opengl/shader.hpp index f43d811..59f69dc 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/shader.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/shader.hpp @@ -11,16 +11,16 @@ class glShader: public Shader public: glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile); - ~glShader(); + ~glShader() override; void bind() override; void un_bind() override; private: - unsigned int compile_shader(std::string source, Shader::Stage stage); + unsigned int compile_shader(const std::string& source, Shader::Stage stage); - unsigned int m_shader_id; + unsigned int m_shader_id{0u}; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/texture.hpp b/modules/engine/include/engine/platform/graphics/opengl/texture.hpp index cf7c3cd..2571b79 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/texture.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/texture.hpp @@ -16,7 +16,7 @@ public: const std::string &filePath ); - ~glTexture(); + ~glTexture() override; void bind(unsigned int slot = 0u) override; diff --git a/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp b/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp index 986b4cc..0a17c16 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp @@ -12,7 +12,7 @@ class glUserInterface: public UserInterface public: glUserInterface() = default; - ~glUserInterface(); + ~glUserInterface() override; void platform_implementation(GLFWwindow *windowHandle, Ref sharedContext) override; @@ -24,7 +24,7 @@ public: void log_debug_data() override; private: - GLFWwindow *m_window_handle; + GLFWwindow *m_window_handle{}; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp b/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp index 4d873df..c662719 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp @@ -22,11 +22,11 @@ class glVertexLayout: public VertexLayout { public: glVertexLayout( - Ref buffer, + const Ref& buffer, const std::vector> &elements ); - ~glVertexLayout(); + ~glVertexLayout() override; void bind() override; diff --git a/modules/engine/include/engine/platform/os/linux/l_window.hpp b/modules/engine/include/engine/platform/os/linux/l_window.hpp index 203eb01..b40ba38 100644 --- a/modules/engine/include/engine/platform/os/linux/l_window.hpp +++ b/modules/engine/include/engine/platform/os/linux/l_window.hpp @@ -15,7 +15,7 @@ class lWindow: public Window public: lWindow(std::function callback); - ~lWindow(); + ~lWindow() override; void poll_events() override; @@ -33,7 +33,7 @@ public: void set_visibility(bool visible, bool toggle = false) override; private: - GLFWwindow *m_handle; + GLFWwindow *m_handle{nullptr}; std::function m_event_callback; diff --git a/modules/engine/include/engine/scene/components/camera.hpp b/modules/engine/include/engine/scene/components/camera.hpp index b5c25d3..b8d805c 100644 --- a/modules/engine/include/engine/scene/components/camera.hpp +++ b/modules/engine/include/engine/scene/components/camera.hpp @@ -18,14 +18,14 @@ struct CameraComponent { } - operator SceneCamera() + operator SceneCamera() const { return camera; } SceneCamera camera; - bool isPrimary; + bool isPrimary{}; }; } // namespace Light diff --git a/modules/engine/include/engine/scene/components/scriptable_entity.hpp b/modules/engine/include/engine/scene/components/scriptable_entity.hpp index ba8d88d..0da6670 100644 --- a/modules/engine/include/engine/scene/components/scriptable_entity.hpp +++ b/modules/engine/include/engine/scene/components/scriptable_entity.hpp @@ -14,7 +14,7 @@ public: virtual ~NativeScript() = default; - auto get_uid() const -> unsigned int + [[nodiscard]] auto get_uid() const -> unsigned int { return m_unique_identifier; } diff --git a/modules/engine/include/engine/scene/components/sprite_renderer.hpp b/modules/engine/include/engine/scene/components/sprite_renderer.hpp index 2c9af24..b06b69a 100644 --- a/modules/engine/include/engine/scene/components/sprite_renderer.hpp +++ b/modules/engine/include/engine/scene/components/sprite_renderer.hpp @@ -2,6 +2,8 @@ #include #include +#include +#include namespace Light { @@ -17,19 +19,19 @@ struct SpriteRendererComponent Ref _texture, const glm::vec4 &_tint = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) ) - : texture(_texture) + : texture(std::move(std::move(_texture))) , tint(_tint) { } - operator Ref() + operator Ref() const { return texture; } Ref texture; - glm::vec4 tint; + glm::vec4 tint{}; }; } // namespace Light diff --git a/modules/engine/include/engine/scene/components/tag.hpp b/modules/engine/include/engine/scene/components/tag.hpp index 4612936..45cdf61 100644 --- a/modules/engine/include/engine/scene/components/tag.hpp +++ b/modules/engine/include/engine/scene/components/tag.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace Light { @@ -10,11 +11,11 @@ struct TagComponent TagComponent(const TagComponent &) = default; - TagComponent(const std::string &_tag): tag(_tag) + TagComponent(std::string _tag): tag(std::move(_tag)) { } - operator std::string() + operator std::string() const { return tag; } diff --git a/modules/engine/include/engine/scene/components/transform.hpp b/modules/engine/include/engine/scene/components/transform.hpp index 7e29dea..da18f28 100644 --- a/modules/engine/include/engine/scene/components/transform.hpp +++ b/modules/engine/include/engine/scene/components/transform.hpp @@ -25,7 +25,7 @@ struct TransformComponent { } - auto get_transform() const -> glm::mat4 + [[nodiscard]] auto get_transform() const -> glm::mat4 { return glm::translate(translation) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(scale); diff --git a/modules/engine/include/engine/scene/entity.hpp b/modules/engine/include/engine/scene/entity.hpp index 57793c3..353db51 100644 --- a/modules/engine/include/engine/scene/entity.hpp +++ b/modules/engine/include/engine/scene/entity.hpp @@ -10,7 +10,7 @@ namespace Light { class Entity { public: - Entity(entt::entity handle = entt::null, Scene *registry = nullptr); + Entity(entt::entity handle = entt::null, Scene *scene = nullptr); ~Entity(); @@ -43,7 +43,7 @@ public: return get_component().uuid; } - auto is_valid() const -> bool + [[nodiscard]] auto is_valid() const -> bool { return m_handle != entt::null && m_scene != nullptr; } diff --git a/modules/engine/include/engine/time/timer.hpp b/modules/engine/include/engine/time/timer.hpp index df4661a..f1238c2 100644 --- a/modules/engine/include/engine/time/timer.hpp +++ b/modules/engine/include/engine/time/timer.hpp @@ -10,7 +10,7 @@ class Timer public: Timer(); - auto get_elapsed_time() const -> float + [[nodiscard]] auto get_elapsed_time() const -> float { return (std::chrono::duration_cast( std::chrono::steady_clock::now() - m_start @@ -35,7 +35,7 @@ public: void update(); - auto get_delta_time() const -> float + [[nodiscard]] auto get_delta_time() const -> float { return m_delta_time; } diff --git a/modules/engine/include/engine/utils/file_manager.hpp b/modules/engine/include/engine/utils/file_manager.hpp index 1ddb6de..0689e37 100644 --- a/modules/engine/include/engine/utils/file_manager.hpp +++ b/modules/engine/include/engine/utils/file_manager.hpp @@ -7,12 +7,13 @@ namespace Light { class BasicFileHandle { public: +virtual ~BasicFileHandle() = default; BasicFileHandle( uint8_t *data = nullptr, uint32_t size = 0ull, - const std::string &path = "", - const std::string &name = "", - const std::string &extension = "" + std::string path = "", + std::string name = "", + std::string extension = "" ); virtual void release(); @@ -22,7 +23,7 @@ public: return m_data; } - auto get_size() -> uint32_t + auto get_size() const -> uint32_t { return m_size; } @@ -47,7 +48,7 @@ public: return m_name + '.' + m_extension; } - auto is_valid() const -> bool + [[nodiscard]] auto is_valid() const -> bool { return !!m_data; } @@ -74,6 +75,7 @@ private: class ImageFileHandle: public BasicFileHandle { public: +virtual ~ImageFileHandle() = default; ImageFileHandle( uint8_t *data, uint32_t size, @@ -95,22 +97,22 @@ public: void release() override; - auto get_width() const -> uint32_t + [[nodiscard]] auto get_width() const -> uint32_t { return m_width; } - auto get_height() const -> uint32_t + [[nodiscard]] auto get_height() const -> uint32_t { return m_height; } - auto get_components() const -> uint32_t + [[nodiscard]] auto get_components() const -> uint32_t { return m_components; } - auto get_desired_components() const -> uint32_t + [[nodiscard]] auto get_desired_components() const -> uint32_t { return m_desired_components; } diff --git a/modules/engine/include/engine/utils/serializer.hpp b/modules/engine/include/engine/utils/serializer.hpp index bcd43a0..f26e8df 100644 --- a/modules/engine/include/engine/utils/serializer.hpp +++ b/modules/engine/include/engine/utils/serializer.hpp @@ -12,7 +12,7 @@ class SceneSerializer public: SceneSerializer(const Ref &scene); - void serialize(const std::string &file_path); + void serialize(const std::string &filePath); auto deserialize(const std::string &file_path) -> bool; diff --git a/modules/engine/src/camera/scene.cpp b/modules/engine/src/camera/scene.cpp index c3cd2ed..080fd09 100644 --- a/modules/engine/src/camera/scene.cpp +++ b/modules/engine/src/camera/scene.cpp @@ -4,10 +4,10 @@ namespace Light { SceneCamera::SceneCamera() - : m_orthographic_specification { 1000.0f, -1.0f, 10000.0f } - , m_perspective_specification { glm::radians(45.0f), 0.01f, 10000.0f } + : m_orthographic_specification { .size=1000.0f, .near_plane=-1.0f, .far_plane=10000.0f } + , m_perspective_specification { .vertical_fov=glm::radians(45.0f), .near_plane=0.01f, .far_plane=10000.0f } , m_aspect_ratio(16.0f / 9.0f) - , m_projection_type(ProjectionType::Orthographic) + { calculate_projection(); } diff --git a/modules/engine/src/core/application.cpp b/modules/engine/src/core/application.cpp index 78d46c6..79f87ba 100644 --- a/modules/engine/src/core/application.cpp +++ b/modules/engine/src/core/application.cpp @@ -26,20 +26,20 @@ Application::Application() log_debug_data(); m_instrumentor = Instrumentor::create(); - m_instrumentor->begin_session("Logs/ProfileResults_Startup.json"); + Light::Instrumentor::begin_session("Logs/ProfileResults_Startup.json"); m_layer_stack = LayerStack::create(); m_input = Input::create(); m_resource_manager = ResourceManager::create(); - m_window = Window::create(std::bind(&Application::on_event, this, std::placeholders::_1)); + m_window = Window::create([this](auto && PH1) { on_event(std::forward(PH1)); }); } Application::~Application() { log_trc("Application::~Application()"); - m_instrumentor->end_session(); + Light::Instrumentor::end_session(); } void Application::game_loop() @@ -54,8 +54,8 @@ void Application::game_loop() // reveal window m_window->set_visibility(true); - m_instrumentor->end_session(); - m_instrumentor->begin_session("Logs/ProfileResults_GameLoop.json"); + Light::Instrumentor::end_session(); + Light::Instrumentor::begin_session("Logs/ProfileResults_GameLoop.json"); /* game loop */ auto delta_timer = DeltaTimer {}; @@ -65,8 +65,9 @@ void Application::game_loop() // update layers lt_profile_scope("game_loop::update"); - for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++) - (*it)->on_update(delta_timer.get_delta_time()); + for (auto & it : *m_layer_stack) { + it->on_update(delta_timer.get_delta_time()); +} } { @@ -74,8 +75,9 @@ void Application::game_loop() lt_profile_scope("game_loop::Render"); m_window->get_graphics_context()->get_renderer()->begin_frame(); - for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++) - (*it)->on_render(); + for (auto & it : *m_layer_stack) { + it->on_render(); +} m_window->get_graphics_context()->get_renderer()->end_frame(); } @@ -85,8 +87,9 @@ void Application::game_loop() lt_profile_scope("game_loop::UserInterface"); m_window->get_graphics_context()->get_user_interface()->begin(); - for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++) - (*it)->on_user_interface_update(); + for (auto & it : *m_layer_stack) { + it->on_user_interface_update(); +} m_window->get_graphics_context()->get_user_interface()->end(); } @@ -101,8 +104,8 @@ void Application::game_loop() delta_timer.update(); } - m_instrumentor->end_session(); - m_instrumentor->begin_session("Logs/ProfileResults_Termination.json"); + Light::Instrumentor::end_session(); + Light::Instrumentor::begin_session("Logs/ProfileResults_Termination.json"); } void Application::quit() @@ -117,10 +120,11 @@ void Application::on_event(const Event &event) { m_window->on_event(event); - if (event.get_event_type() == EventType::WindowResized) + if (event.get_event_type() == EventType::WindowResized) { m_window->get_graphics_context()->get_renderer()->on_window_resize( (const WindowResizedEvent &)event ); +} } // input diff --git a/modules/engine/src/debug/instrumentor.cpp b/modules/engine/src/debug/instrumentor.cpp index 10bbeca..c524757 100644 --- a/modules/engine/src/debug/instrumentor.cpp +++ b/modules/engine/src/debug/instrumentor.cpp @@ -9,7 +9,7 @@ auto Instrumentor::create() -> Scope return make_scope(new Instrumentor); } -Instrumentor::Instrumentor(): m_current_session_count(0u) +Instrumentor::Instrumentor() { // #todo: maintenance lt_assert( @@ -29,8 +29,9 @@ void Instrumentor::begin_session_impl(const std::string &outputPath) void Instrumentor::end_session_impl() { - if (m_current_session_count == 0u) + if (m_current_session_count == 0u) { log_wrn("0 profiling for the ended session"); +} m_current_session_count = 0u; @@ -41,14 +42,15 @@ void Instrumentor::end_session_impl() void Instrumentor::submit_scope_profile_impl(const ScopeProfileResult &profileResult) { - if (m_current_session_count++ == 0u) + if (m_current_session_count++ == 0u) { m_output_file_stream << "{"; - else + } else { m_output_file_stream << ",{"; +} - m_output_file_stream << "\"name\":\"" << profileResult.name << "\","; - m_output_file_stream << "\"cat\": \"scope\","; - m_output_file_stream << "\"ph\": \"X\","; + m_output_file_stream << R"("name":")" << profileResult.name << "\","; + m_output_file_stream << R"("cat": "scope",)"; + m_output_file_stream << R"("ph": "X",)"; m_output_file_stream << "\"ts\":" << profileResult.start << ","; m_output_file_stream << "\"dur\":" << profileResult.duration << ","; m_output_file_stream << "\"pid\":0,"; @@ -57,7 +59,7 @@ void Instrumentor::submit_scope_profile_impl(const ScopeProfileResult &profileRe } InstrumentorTimer::InstrumentorTimer(const std::string &scopeName) - : m_result({ scopeName, 0, 0, 0 }) + : m_result({ .name=scopeName, .start=0, .duration=0, .threadID=0 }) , m_start(std::chrono::steady_clock::now()) { } diff --git a/modules/engine/src/graphics/blender.cpp b/modules/engine/src/graphics/blender.cpp index d8add76..b17f9a8 100644 --- a/modules/engine/src/graphics/blender.cpp +++ b/modules/engine/src/graphics/blender.cpp @@ -10,7 +10,7 @@ namespace Light { -auto Blender::create(Ref sharedContext) -> Scope +auto Blender::create(const Ref& /*sharedContext*/) -> Scope { switch (GraphicsContext::get_graphics_api()) { diff --git a/modules/engine/src/graphics/buffers.cpp b/modules/engine/src/graphics/buffers.cpp index a633b4b..7f71719 100644 --- a/modules/engine/src/graphics/buffers.cpp +++ b/modules/engine/src/graphics/buffers.cpp @@ -14,7 +14,7 @@ namespace Light { auto ConstantBuffer::create( ConstantBufferIndex index, unsigned int size, - Ref sharedContext + const Ref& /*sharedContext*/ ) -> Scope { switch (GraphicsContext::get_graphics_api()) @@ -42,7 +42,7 @@ auto VertexBuffer::create( float *vertices, unsigned int stride, unsigned int count, - Ref sharedContext + const Ref& /*sharedContext*/ ) -> Ref { switch (GraphicsContext::get_graphics_api()) @@ -70,7 +70,7 @@ auto VertexBuffer::create( auto IndexBuffer::create( unsigned int *indices, unsigned int count, - Ref sharedContext + const Ref& /*sharedContext*/ ) -> Ref { switch (GraphicsContext::get_graphics_api()) diff --git a/modules/engine/src/graphics/framebuffer.cpp b/modules/engine/src/graphics/framebuffer.cpp index c7e9a23..c4651f0 100644 --- a/modules/engine/src/graphics/framebuffer.cpp +++ b/modules/engine/src/graphics/framebuffer.cpp @@ -12,7 +12,7 @@ namespace Light { auto Framebuffer::create( const FramebufferSpecification &specification, - Ref sharedContext + const Ref& /*sharedContext*/ ) -> Ref { switch (GraphicsContext::get_graphics_api()) diff --git a/modules/engine/src/graphics/graphics_context.cpp b/modules/engine/src/graphics/graphics_context.cpp index 98c0560..9f3bd3c 100644 --- a/modules/engine/src/graphics/graphics_context.cpp +++ b/modules/engine/src/graphics/graphics_context.cpp @@ -18,8 +18,7 @@ namespace Light { GraphicsContext *GraphicsContext::s_context = nullptr; GraphicsContext::~GraphicsContext() -{ -} += default; auto GraphicsContext::create(GraphicsAPI api, GLFWwindow *windowHandle) -> Scope { diff --git a/modules/engine/src/graphics/render_command.cpp b/modules/engine/src/graphics/render_command.cpp index 57d8955..f573b76 100644 --- a/modules/engine/src/graphics/render_command.cpp +++ b/modules/engine/src/graphics/render_command.cpp @@ -10,7 +10,7 @@ namespace Light { -auto RenderCommand::create(GLFWwindow *windowHandle, Ref sharedContext) +auto RenderCommand::create(GLFWwindow *windowHandle, const Ref& /*sharedContext*/) -> Scope { switch (GraphicsContext::get_graphics_api()) diff --git a/modules/engine/src/graphics/renderer.cpp b/modules/engine/src/graphics/renderer.cpp index a27bbb6..2991b32 100644 --- a/modules/engine/src/graphics/renderer.cpp +++ b/modules/engine/src/graphics/renderer.cpp @@ -9,21 +9,21 @@ #include #include #include +#include namespace Light { Renderer *Renderer::s_context = nullptr; -Renderer::Renderer(GLFWwindow *windowHandle, Ref sharedContext) +Renderer::Renderer(GLFWwindow *windowHandle, const Ref &sharedContext) : m_quad_renderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext) , m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext) , m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext) , m_view_projection_buffer(nullptr) , m_render_command(nullptr) , m_blender(nullptr) - , m_default_framebuffer_camera(nullptr) , m_target_framebuffer(nullptr) - , m_should_clear_backbuffer(false) + { lt_assert(!s_context, "An instance of 'renderer' already exists, do not construct this class!"); s_context = this; @@ -41,7 +41,7 @@ Renderer::Renderer(GLFWwindow *windowHandle, Ref sharedContext) auto Renderer::create(GLFWwindow *windowHandle, Ref sharedContext) -> Scope { - return make_scope(new Renderer(windowHandle, sharedContext)); + return make_scope(new Renderer(windowHandle, std::move(sharedContext))); } void Renderer::on_window_resize(const WindowResizedEvent &event) @@ -62,7 +62,7 @@ void Renderer::draw_quad_impl( glm::translate(glm::mat4(1.0f), position) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }), tint, - texture + std::move(texture) ); } @@ -90,7 +90,7 @@ void Renderer::draw_quad_impl( draw_quad( glm::translate(glm::mat4(1.0f), position) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }), - texture + std::move(texture) ); } //======================================== DRAW_QUAD ========================================// @@ -127,7 +127,7 @@ void Renderer::draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint) //==================== DRAW_QUAD_TINT ====================// //==================== DRAW_QUAD_TEXTURE ====================// -void Renderer::draw_quad_impl(const glm::mat4 &transform, Ref texture) +void Renderer::draw_quad_impl(const glm::mat4 &transform, const Ref &texture) { // #todo: implement a proper binding lt_assert(texture, "Texture passed to renderer::draw_quad_impl"); @@ -163,7 +163,7 @@ void Renderer::draw_quad_impl(const glm::mat4 &transform, Ref texture) void Renderer::draw_quad_impl( const glm::mat4 &transform, const glm::vec4 &tint, - Ref texture + const Ref &texture ) { // #todo: implement a proper binding @@ -229,7 +229,9 @@ void Renderer::begin_scene_impl( m_target_framebuffer = targetFrameBuffer; if (targetFrameBuffer) + { targetFrameBuffer->bind_as_target(camera->get_background_color()); + } else { m_default_framebuffer_camera = camera; @@ -237,7 +239,7 @@ void Renderer::begin_scene_impl( } // update view projection buffer - glm::mat4 *map = (glm::mat4 *)m_view_projection_buffer->map(); + auto *map = (glm::mat4 *)m_view_projection_buffer->map(); map[0] = camera->get_projection() * glm::inverse(cameraTransform); m_view_projection_buffer->un_map(); diff --git a/modules/engine/src/graphics/renderer_programs/quad.cpp b/modules/engine/src/graphics/renderer_programs/quad.cpp index b82164a..840c43e 100644 --- a/modules/engine/src/graphics/renderer_programs/quad.cpp +++ b/modules/engine/src/graphics/renderer_programs/quad.cpp @@ -7,14 +7,12 @@ namespace Light { -QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref sharedContext) +QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, const Ref& sharedContext) : m_shader(nullptr) , m_index_buffer(nullptr) , m_vertex_layout(nullptr) - , m_map_current(nullptr) - , m_map_end(nullptr) - , m_quad_count(0u) - , m_max_vertices(maxVertices) + , + m_max_vertices(maxVertices) { // #todo: don't use relative path ResourceManager::load_shader( diff --git a/modules/engine/src/graphics/renderer_programs/texture.cpp b/modules/engine/src/graphics/renderer_programs/texture.cpp index 32560c2..a123de9 100644 --- a/modules/engine/src/graphics/renderer_programs/texture.cpp +++ b/modules/engine/src/graphics/renderer_programs/texture.cpp @@ -9,15 +9,13 @@ namespace Light { TextureRendererProgram::TextureRendererProgram( unsigned int maxVertices, - Ref sharedContext + const Ref& sharedContext ) : m_shader(nullptr) , m_index_buffer(nullptr) , m_vertex_layout(nullptr) - , m_map_current(nullptr) - , m_map_end(nullptr) - , m_quad_count(0u) - , m_max_vertices(maxVertices) + , + m_max_vertices(maxVertices) { // #todo: don't use relative path ResourceManager::load_shader( diff --git a/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp b/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp index 5f55d65..a1187ae 100644 --- a/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp +++ b/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp @@ -9,15 +9,13 @@ namespace Light { TintedTextureRendererProgram::TintedTextureRendererProgram( unsigned int maxVertices, - Ref sharedContext + const Ref& sharedContext ) : m_shader(nullptr) , m_index_buffer(nullptr) , m_vertex_layout(nullptr) - , m_map_current(nullptr) - , m_map_end(nullptr) - , m_quad_count(0u) - , m_max_vertices(maxVertices) + , + m_max_vertices(maxVertices) { // #todo: don't use relative path ResourceManager::load_shader( diff --git a/modules/engine/src/graphics/shader.cpp b/modules/engine/src/graphics/shader.cpp index e0c32f3..d140d0b 100644 --- a/modules/engine/src/graphics/shader.cpp +++ b/modules/engine/src/graphics/shader.cpp @@ -11,9 +11,9 @@ namespace Light { auto Shader::create( - BasicFileHandle vertexFile, - BasicFileHandle pixelFile, - Ref sharedContext + const BasicFileHandle& vertexFile, + const BasicFileHandle& pixelFile, + const Ref& /*sharedContext*/ ) -> Ref { // load shader source diff --git a/modules/engine/src/graphics/texture.cpp b/modules/engine/src/graphics/texture.cpp index 05ea1ca..297bd1a 100644 --- a/modules/engine/src/graphics/texture.cpp +++ b/modules/engine/src/graphics/texture.cpp @@ -7,6 +7,7 @@ #endif #include +#include namespace Light { @@ -15,7 +16,7 @@ auto Texture::create( unsigned int height, unsigned int components, unsigned char *pixels, - Ref sharedContext, + const Ref& /*sharedContext*/, const std::string &filePath ) -> Ref { @@ -44,7 +45,7 @@ auto Texture::create( } } -Texture::Texture(const std::string &filePath): m_file_path(filePath) +Texture::Texture(std::string filePath): m_file_path(std::move(filePath)) { } diff --git a/modules/engine/src/graphics/vertex_layout.cpp b/modules/engine/src/graphics/vertex_layout.cpp index b283025..6aa8a25 100644 --- a/modules/engine/src/graphics/vertex_layout.cpp +++ b/modules/engine/src/graphics/vertex_layout.cpp @@ -11,10 +11,10 @@ namespace Light { auto VertexLayout::create( - Ref vertexBuffer, - Ref shader, + const Ref& vertexBuffer, + const Ref& /*shader*/, const std::vector> &elements, - Ref sharedContext + const Ref& /*sharedContext*/ ) -> Ref { switch (GraphicsContext::get_graphics_api()) diff --git a/modules/engine/src/input/input.cpp b/modules/engine/src/input/input.cpp index ad8857b..b0a72cc 100644 --- a/modules/engine/src/input/input.cpp +++ b/modules/engine/src/input/input.cpp @@ -16,13 +16,10 @@ auto Input::create() -> Scope } Input::Input() - : m_keyboad_keys {} - , m_mouse_buttons {} - , m_mouse_position {} + : + m_mouse_position {} , m_mouse_delta {} - , m_mouse_wheel_delta {} - , m_user_interface_events(true) - , m_game_events(true) + { lt_assert( !s_context, @@ -43,9 +40,10 @@ void Input::receieve_game_events_impl(bool receive, bool toggle /*= false*/) auto prev = m_game_events; m_game_events = toggle ? !m_user_interface_events : receive; - if (m_game_events != prev) + if (m_game_events != prev) { restart_input_state(); } +} void Input::restart_input_state() { @@ -73,54 +71,62 @@ void Input::on_event(const Event &inputEvent) m_mouse_position = event.get_position(); } - if (m_user_interface_events) + if (m_user_interface_events) { io.MousePos = ImVec2(event.get_x(), event.get_y()); +} return; } case EventType::ButtonPressed: { - const auto &event = (const ButtonPressedEvent &)inputEvent; + const auto &event = dynamic_cast(inputEvent); - if (m_game_events) + if (m_game_events) { m_mouse_buttons[event.get_button()] = true; +} - if (m_user_interface_events) + if (m_user_interface_events) { io.MouseDown[event.get_button()] = true; +} return; } case EventType::ButtonReleased: { - const auto &event = (const ButtonReleasedEvent &)inputEvent; + const auto &event = dynamic_cast(inputEvent); - if (m_game_events) + if (m_game_events) { m_mouse_buttons[event.get_button()] = false; +} - if (m_user_interface_events) + if (m_user_interface_events) { io.MouseDown[event.get_button()] = false; +} return; } case EventType::WheelScrolled: { - const auto &event = (const WheelScrolledEvent &)inputEvent; + const auto &event = dynamic_cast(inputEvent); - if (m_game_events) + if (m_game_events) { m_mouse_wheel_delta = event.get_offset(); +} - if (m_user_interface_events) + if (m_user_interface_events) { io.MouseWheel = event.get_offset(); +} return; } //** KEYBOARD_EVENTS **// case EventType::KeyPressed: { - const auto &event = (const KeyPressedEvent &)inputEvent; + const auto &event = dynamic_cast(inputEvent); - if (m_game_events) + if (m_game_events) { m_keyboad_keys[event.get_key()] = true; +} if (m_user_interface_events) { @@ -133,13 +139,15 @@ void Input::on_event(const Event &inputEvent) } case EventType::KeyReleased: { - const auto &event = (const KeyReleasedEvent &)inputEvent; + const auto &event = dynamic_cast(inputEvent); - if (m_game_events) + if (m_game_events) { m_keyboad_keys[event.get_key()] = false; +} - if (m_user_interface_events) + if (m_user_interface_events) { io.KeysDown[event.get_key()] = false; +} return; } @@ -147,7 +155,7 @@ void Input::on_event(const Event &inputEvent) { if (m_user_interface_events) { - const auto &event = (const SetCharEvent &)inputEvent; + const auto &event = dynamic_cast(inputEvent); io.AddInputCharacter(event.get_character()); } diff --git a/modules/engine/src/layer/layer.cpp b/modules/engine/src/layer/layer.cpp index 96471df..5251001 100644 --- a/modules/engine/src/layer/layer.cpp +++ b/modules/engine/src/layer/layer.cpp @@ -7,7 +7,7 @@ namespace Light { -Layer::Layer(const std::string &name): m_layer_name(name) +Layer::Layer(std::string name): m_layer_name(std::move(name)) { } diff --git a/modules/engine/src/layer/layer_stack.cpp b/modules/engine/src/layer/layer_stack.cpp index a5e32f8..fd58804 100644 --- a/modules/engine/src/layer/layer_stack.cpp +++ b/modules/engine/src/layer/layer_stack.cpp @@ -14,7 +14,7 @@ auto LayerStack::create() -> Scope return make_scope(new LayerStack()); } -LayerStack::LayerStack(): m_layers {}, m_begin(), m_end() +LayerStack::LayerStack() { lt_assert( !s_context, @@ -25,9 +25,10 @@ LayerStack::LayerStack(): m_layers {}, m_begin(), m_end() LayerStack::~LayerStack() { - for (auto *layer : m_layers) + for (auto *layer : m_layers) { delete layer; } +} void LayerStack::attach_layer_impl(Layer *layer) { diff --git a/modules/engine/src/math/random.cpp b/modules/engine/src/math/random.cpp index fc14fed..8cabdc1 100644 --- a/modules/engine/src/math/random.cpp +++ b/modules/engine/src/math/random.cpp @@ -1,8 +1,8 @@ #include #include -namespace Light { -namespace Math { + +namespace Light::Math { auto rand(int min, int max, int decimals /* = 0 */) -> float { @@ -37,5 +37,5 @@ auto rand_vec3(int min, int max, int decimals /* = 0 */) -> glm::vec3 return { r1, r2, r3 }; } -} // namespace Math -} // namespace Light +} // namespace Light::Math + diff --git a/modules/engine/src/platform/graphics/opengl/buffers.cpp b/modules/engine/src/platform/graphics/opengl/buffers.cpp index 933a6ef..1062a87 100644 --- a/modules/engine/src/platform/graphics/opengl/buffers.cpp +++ b/modules/engine/src/platform/graphics/opengl/buffers.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -41,7 +42,12 @@ glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned in : m_buffer_id(NULL) { glCreateBuffers(1, &m_buffer_id); - glNamedBufferData(m_buffer_id, stride * count, vertices, GL_DYNAMIC_DRAW); + glNamedBufferData( + m_buffer_id, + static_cast(stride * count), + vertices, + GL_DYNAMIC_DRAW + ); } glVertexBuffer::~glVertexBuffer() @@ -108,7 +114,9 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffe // delete indices if (!hasIndices) + { delete[] indices; + } } glIndexBuffer::~glIndexBuffer() diff --git a/modules/engine/src/platform/graphics/opengl/graphics_context.cpp b/modules/engine/src/platform/graphics/opengl/graphics_context.cpp index 1d90a98..dd44674 100644 --- a/modules/engine/src/platform/graphics/opengl/graphics_context.cpp +++ b/modules/engine/src/platform/graphics/opengl/graphics_context.cpp @@ -70,9 +70,9 @@ void glGraphicsContext::set_debug_message_callback() unsigned int type, unsigned int id, unsigned int severity, - int length, + int /*length*/, const char *message, - const void *userParam) { + const void * /*userParam*/) { switch (severity) { case GL_DEBUG_SEVERITY_HIGH: diff --git a/modules/engine/src/platform/graphics/opengl/shader.cpp b/modules/engine/src/platform/graphics/opengl/shader.cpp index 5778c61..e4a1fd7 100644 --- a/modules/engine/src/platform/graphics/opengl/shader.cpp +++ b/modules/engine/src/platform/graphics/opengl/shader.cpp @@ -6,16 +6,16 @@ namespace Light { -glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_shader_id(0u) +glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile) { // create m_shader_id = glCreateProgram(); - std::string vertexSource(vertexFile.get_data(), vertexFile.get_data() + vertexFile.get_size()); - std::string pixelSource(pixelFile.get_data(), pixelFile.get_data() + pixelFile.get_size()); + std::string const vertexSource(vertexFile.get_data(), vertexFile.get_data() + vertexFile.get_size()); + std::string const pixelSource(pixelFile.get_data(), pixelFile.get_data() + pixelFile.get_size()); - unsigned int vertexShader = compile_shader(vertexSource, Shader::Stage::VERTEX); - unsigned int pixelShader = compile_shader(pixelSource, Shader::Stage::PIXEL); + unsigned int const vertexShader = compile_shader(vertexSource, Shader::Stage::VERTEX); + unsigned int const pixelShader = compile_shader(pixelSource, Shader::Stage::PIXEL); // attach shaders glAttachShader(m_shader_id, vertexShader); @@ -68,7 +68,7 @@ void glShader::un_bind() // return result; // } -auto glShader::compile_shader(std::string source, Shader::Stage stage) -> unsigned int +auto glShader::compile_shader(const std::string& source, Shader::Stage stage) -> unsigned int { // &(address of) needs an lvalue const auto *lvalue_source = source.c_str(); @@ -80,7 +80,7 @@ auto glShader::compile_shader(std::string source, Shader::Stage stage) -> unsign ); // compile - glShaderSource(shader, 1, &lvalue_source, NULL); + glShaderSource(shader, 1, &lvalue_source, nullptr); glCompileShader(shader); // check diff --git a/modules/engine/src/platform/graphics/opengl/user_interface.cpp b/modules/engine/src/platform/graphics/opengl/user_interface.cpp index 4d4ddab..b8ed810 100644 --- a/modules/engine/src/platform/graphics/opengl/user_interface.cpp +++ b/modules/engine/src/platform/graphics/opengl/user_interface.cpp @@ -9,7 +9,7 @@ namespace Light { void glUserInterface::platform_implementation( GLFWwindow *windowHandle, - Ref sharedContext + Ref /*sharedContext*/ ) { m_window_handle = windowHandle; @@ -23,8 +23,9 @@ glUserInterface::~glUserInterface() // #todo: handle this in a better way auto &io = ImGui::GetIO(); - if (io.IniFilename == "default_gui_layout.ini") + if (io.IniFilename == "default_gui_layout.ini") { io.IniFilename = "user_gui_layout.ini"; +} ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); diff --git a/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp b/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp index 03e5986..2cba45f 100644 --- a/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp +++ b/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp @@ -5,7 +5,7 @@ namespace Light { glVertexLayout::glVertexLayout( - Ref buffer, + const Ref& buffer, const std::vector> &elements ) : m_array_id(NULL) @@ -73,32 +73,32 @@ auto glVertexLayout::get_element_desc(VertexElementType type, unsigned int offse switch (type) { /* byte */ - case Light::VertexElementType::Byte1: return { GL_BYTE, 1u, sizeof(GLbyte), offset }; - case Light::VertexElementType::Byte2: return { GL_BYTE, 1u, sizeof(GLbyte), offset }; - case Light::VertexElementType::Byte4: return { GL_BYTE, 1u, sizeof(GLbyte), offset }; + case Light::VertexElementType::Byte1: return { .type=GL_BYTE, .count=1u, .typeSize=sizeof(GLbyte), .offset=offset }; + case Light::VertexElementType::Byte2: return { .type=GL_BYTE, .count=1u, .typeSize=sizeof(GLbyte), .offset=offset }; + case Light::VertexElementType::Byte4: return { .type=GL_BYTE, .count=1u, .typeSize=sizeof(GLbyte), .offset=offset }; /* ubyte */ - case Light::VertexElementType::UByte1: return { GL_UNSIGNED_BYTE, 1u, sizeof(GLubyte), offset }; - case Light::VertexElementType::UByte2: return { GL_UNSIGNED_BYTE, 2u, sizeof(GLubyte), offset }; - case Light::VertexElementType::UByte4: return { GL_UNSIGNED_BYTE, 4u, sizeof(GLubyte), offset }; + case Light::VertexElementType::UByte1: return { .type=GL_UNSIGNED_BYTE, .count=1u, .typeSize=sizeof(GLubyte), .offset=offset }; + case Light::VertexElementType::UByte2: return { .type=GL_UNSIGNED_BYTE, .count=2u, .typeSize=sizeof(GLubyte), .offset=offset }; + case Light::VertexElementType::UByte4: return { .type=GL_UNSIGNED_BYTE, .count=4u, .typeSize=sizeof(GLubyte), .offset=offset }; /* int */ - case VertexElementType::Int1: return { GL_INT, 1u, sizeof(GLint), offset }; - case VertexElementType::Int2: return { GL_INT, 2u, sizeof(GLint), offset }; - case VertexElementType::Int3: return { GL_INT, 3u, sizeof(GLint), offset }; - case VertexElementType::Int4: return { GL_INT, 4u, sizeof(GLint), offset }; + case VertexElementType::Int1: return { .type=GL_INT, .count=1u, .typeSize=sizeof(GLint), .offset=offset }; + case VertexElementType::Int2: return { .type=GL_INT, .count=2u, .typeSize=sizeof(GLint), .offset=offset }; + case VertexElementType::Int3: return { .type=GL_INT, .count=3u, .typeSize=sizeof(GLint), .offset=offset }; + case VertexElementType::Int4: return { .type=GL_INT, .count=4u, .typeSize=sizeof(GLint), .offset=offset }; /* uint */ - case VertexElementType::UInt1: return { GL_UNSIGNED_INT, 1u, sizeof(GLuint), offset }; - case VertexElementType::UInt2: return { GL_UNSIGNED_INT, 2u, sizeof(GLuint), offset }; - case VertexElementType::UInt3: return { GL_UNSIGNED_INT, 3u, sizeof(GLuint), offset }; - case VertexElementType::UInt4: return { GL_UNSIGNED_INT, 4u, sizeof(GLuint), offset }; + case VertexElementType::UInt1: return { .type=GL_UNSIGNED_INT, .count=1u, .typeSize=sizeof(GLuint), .offset=offset }; + case VertexElementType::UInt2: return { .type=GL_UNSIGNED_INT, .count=2u, .typeSize=sizeof(GLuint), .offset=offset }; + case VertexElementType::UInt3: return { .type=GL_UNSIGNED_INT, .count=3u, .typeSize=sizeof(GLuint), .offset=offset }; + case VertexElementType::UInt4: return { .type=GL_UNSIGNED_INT, .count=4u, .typeSize=sizeof(GLuint), .offset=offset }; /* float */ - case VertexElementType::Float1: return { GL_FLOAT, 1u, sizeof(GLfloat), offset }; - case VertexElementType::Float2: return { GL_FLOAT, 2u, sizeof(GLfloat), offset }; - case VertexElementType::Float3: return { GL_FLOAT, 3u, sizeof(GLfloat), offset }; - case VertexElementType::Float4: return { GL_FLOAT, 4u, sizeof(GLfloat), offset }; + case VertexElementType::Float1: return { .type=GL_FLOAT, .count=1u, .typeSize=sizeof(GLfloat), .offset=offset }; + case VertexElementType::Float2: return { .type=GL_FLOAT, .count=2u, .typeSize=sizeof(GLfloat), .offset=offset }; + case VertexElementType::Float3: return { .type=GL_FLOAT, .count=3u, .typeSize=sizeof(GLfloat), .offset=offset }; + case VertexElementType::Float4: return { .type=GL_FLOAT, .count=4u, .typeSize=sizeof(GLfloat), .offset=offset }; default: lt_assert(false, "Invalid 'VertexElementType'"); return {}; } diff --git a/modules/engine/src/platform/os/linux/l_window.cpp b/modules/engine/src/platform/os/linux/l_window.cpp index 4a17ff9..37c7056 100644 --- a/modules/engine/src/platform/os/linux/l_window.cpp +++ b/modules/engine/src/platform/os/linux/l_window.cpp @@ -6,17 +6,19 @@ #include #include #include +#include +#include namespace Light { -auto Window::create(std::function callback) -> Scope +auto Window::create(const std::function& callback) -> Scope { return create_scope(callback); } lWindow::lWindow(std::function callback) - : m_handle(nullptr) - , m_event_callback(callback) + : + m_event_callback(std::move(std::move(callback))) { // init glfw lt_assert(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'"); @@ -57,7 +59,7 @@ void lWindow::on_event(const Event &event) case EventType::WindowClosed: b_Closed = true; break; /* resized */ - case EventType::WindowResized: on_window_resize((const WindowResizedEvent &)event); break; + case EventType::WindowResized: on_window_resize(dynamic_cast(event)); break; } } @@ -112,11 +114,12 @@ void lWindow::set_visibility(bool visible, bool toggle) { m_properties.visible = toggle ? !m_properties.visible : visible; - if (m_properties.visible) + if (m_properties.visible) { glfwShowWindow(m_handle); - else + } else { glfwHideWindow(m_handle); } +} void lWindow::bind_glfw_events() { @@ -130,8 +133,8 @@ void lWindow::bind_glfw_events() callback(event); }); - glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int mods) { - std::function callback = *(std::function *) + glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int /*mods*/) { + std::function const callback = *(std::function *) glfwGetWindowUserPointer(window); if (action == GLFW_PRESS) @@ -146,7 +149,7 @@ void lWindow::bind_glfw_events() } }); - glfwSetScrollCallback(m_handle, [](GLFWwindow *window, double xoffset, double yoffset) { + glfwSetScrollCallback(m_handle, [](GLFWwindow *window, double /*xoffset*/, double yoffset) { auto callback = *(std::function *)glfwGetWindowUserPointer(window); auto event = WheelScrolledEvent { static_cast(yoffset) }; @@ -155,7 +158,7 @@ void lWindow::bind_glfw_events() glfwSetKeyCallback( m_handle, - [](GLFWwindow *window, int key, int scancode, int action, int mods) { + [](GLFWwindow *window, int key, int /*scancode*/, int action, int /*mods*/) { auto callback = *(std::function *)glfwGetWindowUserPointer(window); if (action == GLFW_PRESS) diff --git a/modules/engine/src/scene/entity.cpp b/modules/engine/src/scene/entity.cpp index 5079f3d..5920001 100644 --- a/modules/engine/src/scene/entity.cpp +++ b/modules/engine/src/scene/entity.cpp @@ -8,7 +8,6 @@ Entity::Entity(entt::entity handle, Scene *scene): m_handle(handle), m_scene(sce } Entity::~Entity() -{ -} += default; } // namespace Light diff --git a/modules/engine/src/scene/scene.cpp b/modules/engine/src/scene/scene.cpp index 7e44951..8583b1a 100644 --- a/modules/engine/src/scene/scene.cpp +++ b/modules/engine/src/scene/scene.cpp @@ -6,13 +6,12 @@ namespace Light { -Scene::Scene(): m_registry() +Scene::Scene() { } Scene::~Scene() -{ -} += default; void Scene::on_create() { diff --git a/modules/engine/src/user_interface/user_interface.cpp b/modules/engine/src/user_interface/user_interface.cpp index 6c00829..b3175a3 100644 --- a/modules/engine/src/user_interface/user_interface.cpp +++ b/modules/engine/src/user_interface/user_interface.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace Light { @@ -38,7 +39,7 @@ auto UserInterface::create(GLFWwindow *windowHandle, Ref sharedCo return nullptr; } - scopeUserInterface->init(windowHandle, sharedContext); + scopeUserInterface->init(windowHandle, std::move(sharedContext)); return std::move(scopeUserInterface); } @@ -74,15 +75,16 @@ void UserInterface::init(GLFWwindow *windowHandle, Ref sharedCont io.ConfigFlags |= ImGuiBackendFlags_RendererHasViewports; // #todo: handle this in a better way - if (std::filesystem::exists("user_gui_layout.ini")) + if (std::filesystem::exists("user_gui_layout.ini")) { io.IniFilename = "user_gui_layout.ini"; - else + } else { io.IniFilename = "default_gui_layout.ini"; +} // style ImGui::StyleColorsDark(); - platform_implementation(windowHandle, sharedContext); + platform_implementation(windowHandle, std::move(sharedContext)); // keyboard map io.KeyMap[ImGuiKey_Tab] = Key::Tab; @@ -127,11 +129,11 @@ void UserInterface::dockspace_begin() ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); - ImGui::Begin("Dockspace", (bool *)0, s_context->m_dockspace_flags); + ImGui::Begin("Dockspace", (bool *)nullptr, s_context->m_dockspace_flags); ImGui::PopStyleVar(3); ImGuiStyle &style = ImGui::GetStyle(); - float minWinSizeX = style.WindowMinSize.x; + float const minWinSizeX = style.WindowMinSize.x; style.WindowMinSize.x = 370.0f; ImGui::DockSpace( ImGui::GetID("MyDockSpace"), diff --git a/modules/engine/src/utils/file_manager.cpp b/modules/engine/src/utils/file_manager.cpp index 94612a8..81ed290 100644 --- a/modules/engine/src/utils/file_manager.cpp +++ b/modules/engine/src/utils/file_manager.cpp @@ -1,5 +1,6 @@ #define STB_IMAGE_IMPLEMENTATION #include +#include #include namespace Light { @@ -7,15 +8,15 @@ namespace Light { BasicFileHandle::BasicFileHandle( uint8_t *data, uint32_t size, - const std::string &path, - const std::string &name, - const std::string &extension + std::string path, + std::string name, + std::string extension ) : m_data(data) , m_size(size) - , m_path(path) - , m_name(name) - , m_extension(extension) + , m_path(std::move(path)) + , m_name(std::move(name)) + , m_extension(std::move(extension)) { } diff --git a/modules/engine/src/utils/resource_manager.cpp b/modules/engine/src/utils/resource_manager.cpp index 03cd106..6172dfb 100644 --- a/modules/engine/src/utils/resource_manager.cpp +++ b/modules/engine/src/utils/resource_manager.cpp @@ -13,7 +13,7 @@ auto ResourceManager::create() -> Scope return make_scope(new ResourceManager()); } -ResourceManager::ResourceManager(): m_shaders {}, m_textures {} +ResourceManager::ResourceManager() { lt_assert(!s_context, "Repeated singleton construction"); s_context = this; diff --git a/modules/engine/src/utils/serializer.cpp b/modules/engine/src/utils/serializer.cpp index f47f2ea..0a50ac8 100644 --- a/modules/engine/src/utils/serializer.cpp +++ b/modules/engine/src/utils/serializer.cpp @@ -19,8 +19,9 @@ struct convert static auto decode(const Node &node, glm::vec3 &rhs) -> bool { - if (!node.IsSequence() || node.size() != 3) + if (!node.IsSequence() || node.size() != 3) { return false; +} rhs.x = node[0].as(); rhs.y = node[1].as(); @@ -44,8 +45,9 @@ struct convert static auto decode(const Node &node, glm::vec4 &rhs) -> bool { - if (!node.IsSequence() || node.size() != 4) + if (!node.IsSequence() || node.size() != 4) { return false; +} rhs.x = node[0].as(); rhs.y = node[1].as(); @@ -221,12 +223,12 @@ auto SceneSerializer::deserialize(const std::string &file_path) -> bool return false; } -void SceneSerializer::serialize_binary(const std::string &filePath) +void SceneSerializer::serialize_binary(const std::string & /*filePath*/) { log_err("NO_IMPLEMENT"); } -auto SceneSerializer::deserialize_binary(const std::string &filePath) -> bool +auto SceneSerializer::deserialize_binary(const std::string & /*filePath*/) -> bool { log_err("NO_IMPLEMENT"); return false; diff --git a/modules/mirror/include/mirror/panel/scene_hierarchy.hpp b/modules/mirror/include/mirror/panel/scene_hierarchy.hpp index 9f484e7..0d4a8c2 100644 --- a/modules/mirror/include/mirror/panel/scene_hierarchy.hpp +++ b/modules/mirror/include/mirror/panel/scene_hierarchy.hpp @@ -14,11 +14,11 @@ class SceneHierarchyPanel: public Panel public: SceneHierarchyPanel(); - SceneHierarchyPanel(Ref context, Ref propertiesPanel = nullptr); + SceneHierarchyPanel(Ref context, Ref properties_panel = nullptr); void on_user_interface_update(); - void set_context(Ref context, Ref propertiesPanel = nullptr); + void set_context(Ref context, Ref properties_panel = nullptr); private: void draw_node(Entity entity, const std::string &label);