refactor: apply clang-tidy auto-fixes
This commit is contained in:
parent
834402c1b8
commit
072772957e
77 changed files with 371 additions and 326 deletions
|
@ -59,7 +59,7 @@ int main(int argc, char *argv[])
|
|||
extern auto Light::create_application() -> Light::Scope<Light::Application>;
|
||||
|
||||
// #todo: use linux specific stuff
|
||||
int main(int argc, char *argv[])
|
||||
int main(int /*argc*/, char * /*argv*/[])
|
||||
{
|
||||
auto application = Light::Scope<Light::Application> {};
|
||||
int exitCode = 0;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -20,9 +20,9 @@ struct WindowProperties
|
|||
class Window
|
||||
{
|
||||
public:
|
||||
static Scope<Window> create(std::function<void(Event &)> callback);
|
||||
static Scope<Window> create(const std::function<void(Event &)>& 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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 &
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ enum class BlendFactor : uint8_t
|
|||
class Blender
|
||||
{
|
||||
public:
|
||||
static auto create(Ref<SharedContext> sharedContext) -> Scope<Blender>;
|
||||
virtual ~Blender() = default;
|
||||
static auto create(const Ref<SharedContext>& sharedContext) -> Scope<Blender>;
|
||||
|
||||
virtual void enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0;
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@ enum class ConstantBufferIndex
|
|||
class ConstantBuffer
|
||||
{
|
||||
public:
|
||||
virtual ~ConstantBuffer() = default;
|
||||
static auto create(
|
||||
ConstantBufferIndex index,
|
||||
unsigned int size,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& sharedContext
|
||||
) -> Scope<ConstantBuffer>;
|
||||
|
||||
virtual auto map() -> void * = 0;
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
float *vertices,
|
||||
unsigned int stride,
|
||||
unsigned int count,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& sharedContext
|
||||
) -> Ref<VertexBuffer>;
|
||||
|
||||
virtual ~VertexBuffer() = default;
|
||||
|
@ -57,7 +58,7 @@ protected:
|
|||
class IndexBuffer
|
||||
{
|
||||
public:
|
||||
static auto create(unsigned int *indices, unsigned int count, Ref<SharedContext> sharedContext)
|
||||
static auto create(unsigned int *indices, unsigned int count, const Ref<SharedContext>& sharedContext)
|
||||
-> Ref<IndexBuffer>;
|
||||
|
||||
virtual ~IndexBuffer() = default;
|
||||
|
|
|
@ -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> sharedContext
|
||||
const Ref<SharedContext>& sharedContext
|
||||
) -> Ref<Framebuffer>;
|
||||
|
||||
virtual void bind_as_target(const glm::vec4 &clearColor) = 0;
|
||||
|
|
|
@ -12,7 +12,7 @@ class SharedContext;
|
|||
class RenderCommand
|
||||
{
|
||||
public:
|
||||
static auto create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||
static auto create(GLFWwindow *windowHandle, const Ref<SharedContext>& sharedContext)
|
||||
-> Scope<RenderCommand>;
|
||||
|
||||
RenderCommand(const RenderCommand &) = delete;
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#include <engine/graphics/renderer_programs/quad.hpp>
|
||||
#include <engine/graphics/renderer_programs/texture.hpp>
|
||||
#include <engine/graphics/renderer_programs/tinted_texture.hpp>
|
||||
#include <utility>
|
||||
|
||||
#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> 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> 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> 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> 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<Blender> m_blender;
|
||||
|
||||
Camera *m_default_framebuffer_camera;
|
||||
Camera *m_default_framebuffer_camera { nullptr };
|
||||
|
||||
Ref<Framebuffer> m_target_framebuffer;
|
||||
|
||||
bool m_should_clear_backbuffer;
|
||||
bool m_should_clear_backbuffer { false };
|
||||
|
||||
Renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
|
||||
Renderer(GLFWwindow *windowHandle, const Ref<SharedContext> &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> texture);
|
||||
|
||||
void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint, Ref<Texture> texture);
|
||||
void draw_quad_impl(
|
||||
const glm::mat4 &transform,
|
||||
const glm::vec4 &tint,
|
||||
const Ref<Texture> &texture
|
||||
);
|
||||
|
||||
void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint);
|
||||
|
||||
void draw_quad_impl(const glm::mat4 &transform, Ref<Texture> texture);
|
||||
void draw_quad_impl(const glm::mat4 &transform, const Ref<Texture> &texture);
|
||||
|
||||
void begin_scene_impl(
|
||||
Camera *camera,
|
||||
|
|
|
@ -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> sharedContext);
|
||||
QuadRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& 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);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ class RendererProgram
|
|||
virtual void un_map() = 0;
|
||||
|
||||
virtual void bind() = 0;
|
||||
public:
|
||||
virtual ~RendererProgram() = default;
|
||||
};
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -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> sharedContext);
|
||||
TextureRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& 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;
|
||||
};
|
||||
|
|
|
@ -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> sharedContext);
|
||||
TintedTextureRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& 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;
|
||||
};
|
||||
|
|
|
@ -20,9 +20,9 @@ public:
|
|||
};
|
||||
|
||||
static auto create(
|
||||
BasicFileHandle vertexFile,
|
||||
BasicFileHandle pixelFile,
|
||||
Ref<SharedContext> sharedContext
|
||||
const BasicFileHandle& vertexFile,
|
||||
const BasicFileHandle& pixelFile,
|
||||
const Ref<SharedContext>& sharedContext
|
||||
) -> Ref<Shader>;
|
||||
|
||||
virtual ~Shader() = default;
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
unsigned int height,
|
||||
unsigned int components,
|
||||
unsigned char *pixels,
|
||||
Ref<SharedContext> sharedContext,
|
||||
const Ref<SharedContext>& 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
|
||||
|
|
|
@ -34,10 +34,10 @@ class VertexLayout
|
|||
{
|
||||
public:
|
||||
static auto create(
|
||||
Ref<VertexBuffer> vertexBuffer,
|
||||
Ref<Shader> shader,
|
||||
const Ref<VertexBuffer>& vertexBuffer,
|
||||
const Ref<Shader>& shader,
|
||||
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& sharedContext
|
||||
) -> Ref<VertexLayout>;
|
||||
|
||||
virtual ~VertexLayout() = default;
|
||||
|
|
|
@ -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<bool, 348> m_keyboad_keys;
|
||||
std::array<bool, 348> m_keyboad_keys{};
|
||||
|
||||
std::array<bool, 8> m_mouse_buttons;
|
||||
std::array<bool, 8> 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();
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Light {
|
||||
|
||||
namespace Key {
|
||||
|
||||
namespace Light::Key {
|
||||
enum : uint16_t
|
||||
{
|
||||
/* digits */
|
||||
|
@ -179,4 +179,4 @@ enum : uint16_t
|
|||
};
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Light {
|
||||
|
||||
namespace Mouse {
|
||||
|
||||
namespace Light::Mouse {
|
||||
enum : uint8_t
|
||||
{
|
||||
Button1 = 0,
|
||||
|
@ -22,4 +22,4 @@ enum : uint8_t
|
|||
};
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Light {
|
|||
class glBlender: public Blender
|
||||
{
|
||||
public:
|
||||
virtual ~glBlender() = default;
|
||||
glBlender();
|
||||
|
||||
void enable(BlendFactor srcFactor, BlendFactor dstFactor) override;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
const std::string &filePath
|
||||
);
|
||||
|
||||
~glTexture();
|
||||
~glTexture() override;
|
||||
|
||||
void bind(unsigned int slot = 0u) override;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class glUserInterface: public UserInterface
|
|||
public:
|
||||
glUserInterface() = default;
|
||||
|
||||
~glUserInterface();
|
||||
~glUserInterface() override;
|
||||
|
||||
void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||
override;
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
void log_debug_data() override;
|
||||
|
||||
private:
|
||||
GLFWwindow *m_window_handle;
|
||||
GLFWwindow *m_window_handle{};
|
||||
};
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -22,11 +22,11 @@ class glVertexLayout: public VertexLayout
|
|||
{
|
||||
public:
|
||||
glVertexLayout(
|
||||
Ref<VertexBuffer> buffer,
|
||||
const Ref<VertexBuffer>& buffer,
|
||||
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
||||
);
|
||||
|
||||
~glVertexLayout();
|
||||
~glVertexLayout() override;
|
||||
|
||||
void bind() override;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class lWindow: public Window
|
|||
public:
|
||||
lWindow(std::function<void(Event &)> 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<void(Event &)> m_event_callback;
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ struct CameraComponent
|
|||
{
|
||||
}
|
||||
|
||||
operator SceneCamera()
|
||||
operator SceneCamera() const
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
|
||||
SceneCamera camera;
|
||||
|
||||
bool isPrimary;
|
||||
bool isPrimary{};
|
||||
};
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <engine/base/base.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <utility>
|
||||
#include <utility>
|
||||
|
||||
namespace Light {
|
||||
|
||||
|
@ -17,19 +19,19 @@ struct SpriteRendererComponent
|
|||
Ref<Texture> _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<Texture>()
|
||||
operator Ref<Texture>() const
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
|
||||
Ref<Texture> texture;
|
||||
|
||||
glm::vec4 tint;
|
||||
glm::vec4 tint{};
|
||||
};
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <engine/base/base.hpp>
|
||||
#include <utility>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<UUIDComponent>().uuid;
|
||||
}
|
||||
|
||||
auto is_valid() const -> bool
|
||||
[[nodiscard]] auto is_valid() const -> bool
|
||||
{
|
||||
return m_handle != entt::null && m_scene != nullptr;
|
||||
}
|
||||
|
|
|
@ -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::milliseconds>(
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class SceneSerializer
|
|||
public:
|
||||
SceneSerializer(const Ref<Scene> &scene);
|
||||
|
||||
void serialize(const std::string &file_path);
|
||||
void serialize(const std::string &filePath);
|
||||
|
||||
auto deserialize(const std::string &file_path) -> bool;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<decltype(PH1)>(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
|
||||
|
|
|
@ -9,7 +9,7 @@ auto Instrumentor::create() -> Scope<Instrumentor>
|
|||
return make_scope<Instrumentor>(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())
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
auto Blender::create(Ref<SharedContext> sharedContext) -> Scope<Blender>
|
||||
auto Blender::create(const Ref<SharedContext>& /*sharedContext*/) -> Scope<Blender>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Light {
|
|||
auto ConstantBuffer::create(
|
||||
ConstantBufferIndex index,
|
||||
unsigned int size,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& /*sharedContext*/
|
||||
) -> Scope<ConstantBuffer>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
|
@ -42,7 +42,7 @@ auto VertexBuffer::create(
|
|||
float *vertices,
|
||||
unsigned int stride,
|
||||
unsigned int count,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& /*sharedContext*/
|
||||
) -> Ref<VertexBuffer>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
|
@ -70,7 +70,7 @@ auto VertexBuffer::create(
|
|||
auto IndexBuffer::create(
|
||||
unsigned int *indices,
|
||||
unsigned int count,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& /*sharedContext*/
|
||||
) -> Ref<IndexBuffer>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Light {
|
|||
|
||||
auto Framebuffer::create(
|
||||
const FramebufferSpecification &specification,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& /*sharedContext*/
|
||||
) -> Ref<Framebuffer>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace Light {
|
|||
GraphicsContext *GraphicsContext::s_context = nullptr;
|
||||
|
||||
GraphicsContext::~GraphicsContext()
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
||||
auto GraphicsContext::create(GraphicsAPI api, GLFWwindow *windowHandle) -> Scope<GraphicsContext>
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
auto RenderCommand::create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||
auto RenderCommand::create(GLFWwindow *windowHandle, const Ref<SharedContext>& /*sharedContext*/)
|
||||
-> Scope<RenderCommand>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
|
|
|
@ -9,21 +9,21 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/matrix.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Light {
|
||||
|
||||
Renderer *Renderer::s_context = nullptr;
|
||||
|
||||
Renderer::Renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||
Renderer::Renderer(GLFWwindow *windowHandle, const Ref<SharedContext> &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> sharedContext)
|
|||
|
||||
auto Renderer::create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext) -> Scope<Renderer>
|
||||
{
|
||||
return make_scope<Renderer>(new Renderer(windowHandle, sharedContext));
|
||||
return make_scope<Renderer>(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> texture)
|
||||
void Renderer::draw_quad_impl(const glm::mat4 &transform, const Ref<Texture> &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> texture)
|
|||
void Renderer::draw_quad_impl(
|
||||
const glm::mat4 &transform,
|
||||
const glm::vec4 &tint,
|
||||
Ref<Texture> texture
|
||||
const Ref<Texture> &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();
|
||||
|
||||
|
|
|
@ -7,14 +7,12 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext)
|
||||
QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& 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(
|
||||
|
|
|
@ -9,15 +9,13 @@ namespace Light {
|
|||
|
||||
TextureRendererProgram::TextureRendererProgram(
|
||||
unsigned int maxVertices,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& 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(
|
||||
|
|
|
@ -9,15 +9,13 @@ namespace Light {
|
|||
|
||||
TintedTextureRendererProgram::TintedTextureRendererProgram(
|
||||
unsigned int maxVertices,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& 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(
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
namespace Light {
|
||||
|
||||
auto Shader::create(
|
||||
BasicFileHandle vertexFile,
|
||||
BasicFileHandle pixelFile,
|
||||
Ref<SharedContext> sharedContext
|
||||
const BasicFileHandle& vertexFile,
|
||||
const BasicFileHandle& pixelFile,
|
||||
const Ref<SharedContext>& /*sharedContext*/
|
||||
) -> Ref<Shader>
|
||||
{
|
||||
// load shader source
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#endif
|
||||
|
||||
#include <engine/graphics/graphics_context.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Light {
|
||||
|
||||
|
@ -15,7 +16,7 @@ auto Texture::create(
|
|||
unsigned int height,
|
||||
unsigned int components,
|
||||
unsigned char *pixels,
|
||||
Ref<SharedContext> sharedContext,
|
||||
const Ref<SharedContext>& /*sharedContext*/,
|
||||
const std::string &filePath
|
||||
) -> Ref<Texture>
|
||||
{
|
||||
|
@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
namespace Light {
|
||||
|
||||
auto VertexLayout::create(
|
||||
Ref<VertexBuffer> vertexBuffer,
|
||||
Ref<Shader> shader,
|
||||
const Ref<VertexBuffer>& vertexBuffer,
|
||||
const Ref<Shader>& /*shader*/,
|
||||
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
||||
Ref<SharedContext> sharedContext
|
||||
const Ref<SharedContext>& /*sharedContext*/
|
||||
) -> Ref<VertexLayout>
|
||||
{
|
||||
switch (GraphicsContext::get_graphics_api())
|
||||
|
|
|
@ -16,13 +16,10 @@ auto Input::create() -> Scope<Input>
|
|||
}
|
||||
|
||||
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<const ButtonPressedEvent &>(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<const ButtonReleasedEvent &>(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<const WheelScrolledEvent &>(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<const KeyPressedEvent &>(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<const KeyReleasedEvent &>(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<const SetCharEvent &>(inputEvent);
|
||||
io.AddInputCharacter(event.get_character());
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ auto LayerStack::create() -> Scope<LayerStack>
|
|||
return make_scope<LayerStack>(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)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <cmath>
|
||||
#include <engine/math/random.hpp>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <cstddef>
|
||||
#include <engine/platform/graphics/opengl/buffers.hpp>
|
||||
#include <glad/gl.h>
|
||||
|
||||
|
@ -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<GLsizeiptr>(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()
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Light {
|
|||
|
||||
void glUserInterface::platform_implementation(
|
||||
GLFWwindow *windowHandle,
|
||||
Ref<SharedContext> sharedContext
|
||||
Ref<SharedContext> /*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();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Light {
|
||||
|
||||
glVertexLayout::glVertexLayout(
|
||||
Ref<VertexBuffer> buffer,
|
||||
const Ref<VertexBuffer>& buffer,
|
||||
const std::vector<std::pair<std::string, VertexElementType>> &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 {};
|
||||
}
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
#include <engine/events/window.hpp>
|
||||
#include <engine/graphics/graphics_context.hpp>
|
||||
#include <engine/platform/os/linux/l_window.hpp>
|
||||
#include <utility>
|
||||
#include <utility>
|
||||
|
||||
namespace Light {
|
||||
|
||||
auto Window::create(std::function<void(Event &)> callback) -> Scope<Window>
|
||||
auto Window::create(const std::function<void(Event &)>& callback) -> Scope<Window>
|
||||
{
|
||||
return create_scope<lWindow>(callback);
|
||||
}
|
||||
|
||||
lWindow::lWindow(std::function<void(Event &)> 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<const WindowResizedEvent &>(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<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int /*mods*/) {
|
||||
std::function<void(Event &)> const callback = *(std::function<void(Event &)> *)
|
||||
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<void(Event &)> *)glfwGetWindowUserPointer(window);
|
||||
|
||||
auto event = WheelScrolledEvent { static_cast<float>(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<void(Event &)> *)glfwGetWindowUserPointer(window);
|
||||
|
||||
if (action == GLFW_PRESS)
|
||||
|
|
|
@ -8,7 +8,6 @@ Entity::Entity(entt::entity handle, Scene *scene): m_handle(handle), m_scene(sce
|
|||
}
|
||||
|
||||
Entity::~Entity()
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
Scene::Scene(): m_registry()
|
||||
Scene::Scene()
|
||||
{
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
||||
void Scene::on_create()
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <engine/events/mouse.hpp>
|
||||
#include <engine/graphics/graphics_context.hpp>
|
||||
#include <engine/input/key_codes.hpp>
|
||||
#include <utility>
|
||||
#include <imgui.h>
|
||||
|
||||
namespace Light {
|
||||
|
@ -38,7 +39,7 @@ auto UserInterface::create(GLFWwindow *windowHandle, Ref<SharedContext> 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<SharedContext> 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"),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <engine/utils/file_manager.hpp>
|
||||
#include <utility>
|
||||
#include <stb_image.h>
|
||||
|
||||
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))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ auto ResourceManager::create() -> Scope<ResourceManager>
|
|||
return make_scope(new ResourceManager());
|
||||
}
|
||||
|
||||
ResourceManager::ResourceManager(): m_shaders {}, m_textures {}
|
||||
ResourceManager::ResourceManager()
|
||||
{
|
||||
lt_assert(!s_context, "Repeated singleton construction");
|
||||
s_context = this;
|
||||
|
|
|
@ -19,8 +19,9 @@ struct convert<glm::vec3>
|
|||
|
||||
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<float>();
|
||||
rhs.y = node[1].as<float>();
|
||||
|
@ -44,8 +45,9 @@ struct convert<glm::vec4>
|
|||
|
||||
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<float>();
|
||||
rhs.y = node[1].as<float>();
|
||||
|
@ -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;
|
||||
|
|
|
@ -14,11 +14,11 @@ class SceneHierarchyPanel: public Panel
|
|||
public:
|
||||
SceneHierarchyPanel();
|
||||
|
||||
SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel = nullptr);
|
||||
SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> properties_panel = nullptr);
|
||||
|
||||
void on_user_interface_update();
|
||||
|
||||
void set_context(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel = nullptr);
|
||||
void set_context(Ref<Scene> context, Ref<PropertiesPanel> properties_panel = nullptr);
|
||||
|
||||
private:
|
||||
void draw_node(Entity entity, const std::string &label);
|
||||
|
|
Loading…
Add table
Reference in a new issue