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>;
|
extern auto Light::create_application() -> Light::Scope<Light::Application>;
|
||||||
|
|
||||||
// #todo: use linux specific stuff
|
// #todo: use linux specific stuff
|
||||||
int main(int argc, char *argv[])
|
int main(int /*argc*/, char * /*argv*/[])
|
||||||
{
|
{
|
||||||
auto application = Light::Scope<Light::Application> {};
|
auto application = Light::Scope<Light::Application> {};
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
|
|
|
@ -10,12 +10,12 @@ class Camera
|
||||||
public:
|
public:
|
||||||
Camera() = default;
|
Camera() = default;
|
||||||
|
|
||||||
auto get_projection() const -> const glm::mat4 &
|
[[nodiscard]] auto get_projection() const -> const glm::mat4 &
|
||||||
{
|
{
|
||||||
return m_projection;
|
return m_projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_background_color() const -> const glm::vec4 &
|
[[nodiscard]] auto get_background_color() const -> const glm::vec4 &
|
||||||
{
|
{
|
||||||
return m_background_color;
|
return m_background_color;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
glm::mat4 m_projection;
|
glm::mat4 m_projection{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
glm::vec4 m_background_color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
|
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);
|
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;
|
return m_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_projection() const -> const glm::mat4 &
|
[[nodiscard]] auto get_projection() const -> const glm::mat4 &
|
||||||
{
|
{
|
||||||
return m_projection;
|
return m_projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_clear_color() const -> const glm::vec4 &
|
[[nodiscard]] auto get_clear_color() const -> const glm::vec4 &
|
||||||
{
|
{
|
||||||
return m_clear_color;
|
return m_clear_color;
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ private:
|
||||||
|
|
||||||
const glm::vec3 m_up;
|
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;
|
glm::vec4 m_clear_color;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,37 +50,37 @@ public:
|
||||||
|
|
||||||
void set_perspective_near_plane(float nearPlane);
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
return m_perspective_specification.near_plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_projection_type() const -> ProjectionType
|
[[nodiscard]] auto get_projection_type() const -> ProjectionType
|
||||||
{
|
{
|
||||||
return m_projection_type;
|
return m_projection_type;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ private:
|
||||||
|
|
||||||
float m_aspect_ratio;
|
float m_aspect_ratio;
|
||||||
|
|
||||||
ProjectionType m_projection_type;
|
ProjectionType m_projection_type{ProjectionType::Orthographic};
|
||||||
|
|
||||||
void calculate_projection();
|
void calculate_projection();
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,9 +20,9 @@ struct WindowProperties
|
||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
public:
|
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;
|
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();
|
return m_graphics_context.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_properties() const -> const WindowProperties &
|
[[nodiscard]] auto get_properties() const -> const WindowProperties &
|
||||||
{
|
{
|
||||||
return m_properties;
|
return m_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_title() const -> const std::string &
|
[[nodiscard]] auto get_title() const -> const std::string &
|
||||||
{
|
{
|
||||||
return m_properties.title;
|
return m_properties.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_size() const -> const glm::uvec2 &
|
[[nodiscard]] auto get_size() const -> const glm::uvec2 &
|
||||||
{
|
{
|
||||||
return m_properties.size;
|
return m_properties.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_closed() const -> bool
|
[[nodiscard]] auto is_closed() const -> bool
|
||||||
{
|
{
|
||||||
return b_Closed;
|
return b_Closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_v_sync() const -> bool
|
[[nodiscard]] auto is_v_sync() const -> bool
|
||||||
{
|
{
|
||||||
return m_properties.vsync;
|
return m_properties.vsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_visible() const -> bool
|
[[nodiscard]] auto is_visible() const -> bool
|
||||||
{
|
{
|
||||||
return m_properties.visible;
|
return m_properties.visible;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ protected:
|
||||||
|
|
||||||
WindowProperties m_properties;
|
WindowProperties m_properties;
|
||||||
|
|
||||||
bool b_Closed;
|
bool b_Closed{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
|
|
||||||
std::ofstream m_output_file_stream;
|
std::ofstream m_output_file_stream;
|
||||||
|
|
||||||
unsigned int m_current_session_count;
|
unsigned int m_current_session_count{0u};
|
||||||
|
|
||||||
Instrumentor();
|
Instrumentor();
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_character() const -> int
|
[[nodiscard]] auto get_character() const -> int
|
||||||
{
|
{
|
||||||
return m_character;
|
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;
|
std::stringstream ss;
|
||||||
ss << "CharSet: " << m_character;
|
ss << "CharSet: " << m_character;
|
||||||
|
|
|
@ -55,11 +55,11 @@ public:
|
||||||
|
|
||||||
virtual ~Event() = default;
|
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 &
|
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;
|
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;
|
std::stringstream ss;
|
||||||
ss << "KeyPressed: " << m_key;
|
ss << "KeyPressed: " << m_key;
|
||||||
|
@ -40,12 +40,12 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_key() const -> int
|
[[nodiscard]] auto get_key() const -> int
|
||||||
{
|
{
|
||||||
return m_key;
|
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;
|
std::stringstream ss;
|
||||||
ss << "KeyRepeated: " << m_key;
|
ss << "KeyRepeated: " << m_key;
|
||||||
|
@ -67,12 +67,12 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_key() const -> int
|
[[nodiscard]] auto get_key() const -> int
|
||||||
{
|
{
|
||||||
return m_key;
|
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;
|
std::stringstream ss;
|
||||||
ss << "KeyReleased: " << m_key;
|
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;
|
return m_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_x() const -> float
|
[[nodiscard]] auto get_x() const -> float
|
||||||
{
|
{
|
||||||
return m_position.x;
|
return m_position.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_y() const -> float
|
[[nodiscard]] auto get_y() const -> float
|
||||||
{
|
{
|
||||||
return m_position.y;
|
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;
|
std::stringstream ss;
|
||||||
ss << "MouseMoved: " << m_position.x << ", " << m_position.y;
|
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;
|
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;
|
std::stringstream ss;
|
||||||
ss << "WheelScrolled: " << m_offset;
|
ss << "WheelScrolled: " << m_offset;
|
||||||
|
@ -78,12 +78,12 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_button() const -> int
|
[[nodiscard]] auto get_button() const -> int
|
||||||
{
|
{
|
||||||
return m_button;
|
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;
|
std::stringstream ss;
|
||||||
ss << "ButtonPressed: " << m_button;
|
ss << "ButtonPressed: " << m_button;
|
||||||
|
@ -105,12 +105,12 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_button() const -> int
|
[[nodiscard]] auto get_button() const -> int
|
||||||
{
|
{
|
||||||
return m_button;
|
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;
|
std::stringstream ss;
|
||||||
ss << "ButtonReleased: " << m_button;
|
ss << "ButtonReleased: " << m_button;
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Light {
|
||||||
class WindowClosedEvent: public Event
|
class WindowClosedEvent: public Event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto get_info_lt_log() const -> std::string override
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
||||||
{
|
{
|
||||||
return "WindowClosedEvent";
|
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;
|
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;
|
std::stringstream ss;
|
||||||
ss << "WindwoMoved: " << m_position.x << ", " << m_position.y;
|
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;
|
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;
|
std::stringstream ss;
|
||||||
ss << "WindowResized: " << m_size.x << ", " << m_size.y;
|
ss << "WindowResized: " << m_size.x << ", " << m_size.y;
|
||||||
|
@ -78,7 +78,7 @@ private:
|
||||||
class WindowLostFocusEvent: public Event
|
class WindowLostFocusEvent: public Event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto get_info_lt_log() const -> std::string override
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
||||||
{
|
{
|
||||||
return "WindowLostFocus";
|
return "WindowLostFocus";
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
class WindowGainFocusEvent: public Event
|
class WindowGainFocusEvent: public Event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto get_info_lt_log() const -> std::string override
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
||||||
{
|
{
|
||||||
return "WindowGainFocus";
|
return "WindowGainFocus";
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ enum class BlendFactor : uint8_t
|
||||||
class Blender
|
class Blender
|
||||||
{
|
{
|
||||||
public:
|
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;
|
virtual void enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0;
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,11 @@ enum class ConstantBufferIndex
|
||||||
class ConstantBuffer
|
class ConstantBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~ConstantBuffer() = default;
|
||||||
static auto create(
|
static auto create(
|
||||||
ConstantBufferIndex index,
|
ConstantBufferIndex index,
|
||||||
unsigned int size,
|
unsigned int size,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
) -> Scope<ConstantBuffer>;
|
) -> Scope<ConstantBuffer>;
|
||||||
|
|
||||||
virtual auto map() -> void * = 0;
|
virtual auto map() -> void * = 0;
|
||||||
|
@ -37,7 +38,7 @@ public:
|
||||||
float *vertices,
|
float *vertices,
|
||||||
unsigned int stride,
|
unsigned int stride,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
) -> Ref<VertexBuffer>;
|
) -> Ref<VertexBuffer>;
|
||||||
|
|
||||||
virtual ~VertexBuffer() = default;
|
virtual ~VertexBuffer() = default;
|
||||||
|
@ -57,7 +58,7 @@ protected:
|
||||||
class IndexBuffer
|
class IndexBuffer
|
||||||
{
|
{
|
||||||
public:
|
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>;
|
-> Ref<IndexBuffer>;
|
||||||
|
|
||||||
virtual ~IndexBuffer() = default;
|
virtual ~IndexBuffer() = default;
|
||||||
|
|
|
@ -9,9 +9,9 @@ class SharedContext;
|
||||||
|
|
||||||
struct FramebufferSpecification
|
struct FramebufferSpecification
|
||||||
{
|
{
|
||||||
unsigned int width;
|
unsigned int width{};
|
||||||
|
|
||||||
unsigned int height;
|
unsigned int height{};
|
||||||
|
|
||||||
unsigned int samples = 1;
|
unsigned int samples = 1;
|
||||||
};
|
};
|
||||||
|
@ -19,9 +19,10 @@ struct FramebufferSpecification
|
||||||
class Framebuffer
|
class Framebuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~Framebuffer() = default;
|
||||||
static auto create(
|
static auto create(
|
||||||
const FramebufferSpecification &specification,
|
const FramebufferSpecification &specification,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
) -> Ref<Framebuffer>;
|
) -> Ref<Framebuffer>;
|
||||||
|
|
||||||
virtual void bind_as_target(const glm::vec4 &clearColor) = 0;
|
virtual void bind_as_target(const glm::vec4 &clearColor) = 0;
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SharedContext;
|
||||||
class RenderCommand
|
class RenderCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static auto create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
static auto create(GLFWwindow *windowHandle, const Ref<SharedContext>& sharedContext)
|
||||||
-> Scope<RenderCommand>;
|
-> Scope<RenderCommand>;
|
||||||
|
|
||||||
RenderCommand(const RenderCommand &) = delete;
|
RenderCommand(const RenderCommand &) = delete;
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
#include <engine/graphics/renderer_programs/quad.hpp>
|
#include <engine/graphics/renderer_programs/quad.hpp>
|
||||||
#include <engine/graphics/renderer_programs/texture.hpp>
|
#include <engine/graphics/renderer_programs/texture.hpp>
|
||||||
#include <engine/graphics/renderer_programs/tinted_texture.hpp>
|
#include <engine/graphics/renderer_programs/tinted_texture.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#define LT_MAX_QUAD_RENDERER_VERTICES 1028u * 4u
|
#define LT_MAX_QUAD_RENDERER_VERTICES (1028u * 4u)
|
||||||
#define LT_MAX_TEXTURE_RENDERER_VERTICES 1028u * 4u
|
#define LT_MAX_TEXTURE_RENDERER_VERTICES (1028u * 4u)
|
||||||
#define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES 1028u * 4u
|
#define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES (1028u * 4u)
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ public:
|
||||||
Ref<Texture> texture
|
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)
|
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)
|
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)
|
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)
|
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)
|
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(
|
static void begin_scene(
|
||||||
|
@ -98,13 +99,13 @@ private:
|
||||||
|
|
||||||
Scope<Blender> m_blender;
|
Scope<Blender> m_blender;
|
||||||
|
|
||||||
Camera *m_default_framebuffer_camera;
|
Camera *m_default_framebuffer_camera { nullptr };
|
||||||
|
|
||||||
Ref<Framebuffer> m_target_framebuffer;
|
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(
|
void draw_quad_impl(
|
||||||
const glm::vec3 &position,
|
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::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, 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(
|
void begin_scene_impl(
|
||||||
Camera *camera,
|
Camera *camera,
|
||||||
|
|
|
@ -16,13 +16,14 @@ class SharedContext;
|
||||||
class QuadRendererProgram: RendererProgram
|
class QuadRendererProgram: RendererProgram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~QuadRendererProgram() = default;
|
||||||
struct QuadVertexData
|
struct QuadVertexData
|
||||||
{
|
{
|
||||||
glm::vec4 position;
|
glm::vec4 position;
|
||||||
glm::vec4 tint;
|
glm::vec4 tint;
|
||||||
};
|
};
|
||||||
|
|
||||||
QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
|
QuadRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& sharedContext);
|
||||||
|
|
||||||
auto advance() -> bool;
|
auto advance() -> bool;
|
||||||
|
|
||||||
|
@ -37,12 +38,12 @@ public:
|
||||||
return m_map_current;
|
return m_map_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_quad_count() const -> unsigned int
|
[[nodiscard]] auto get_quad_count() const -> unsigned int
|
||||||
{
|
{
|
||||||
return m_quad_count;
|
return m_quad_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto get_vertex_size() const -> unsigned int
|
[[nodiscard]] constexpr auto get_vertex_size() const -> unsigned int
|
||||||
{
|
{
|
||||||
return sizeof(QuadVertexData);
|
return sizeof(QuadVertexData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ class RendererProgram
|
||||||
virtual void un_map() = 0;
|
virtual void un_map() = 0;
|
||||||
|
|
||||||
virtual void bind() = 0;
|
virtual void bind() = 0;
|
||||||
|
public:
|
||||||
|
virtual ~RendererProgram() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -16,6 +16,7 @@ class SharedContext;
|
||||||
class TextureRendererProgram: RendererProgram
|
class TextureRendererProgram: RendererProgram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~TextureRendererProgram() = default;
|
||||||
struct TextureVertexData
|
struct TextureVertexData
|
||||||
{
|
{
|
||||||
glm::vec4 position;
|
glm::vec4 position;
|
||||||
|
@ -23,7 +24,7 @@ public:
|
||||||
glm::vec2 texcoord;
|
glm::vec2 texcoord;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
|
TextureRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& sharedContext);
|
||||||
|
|
||||||
auto advance() -> bool;
|
auto advance() -> bool;
|
||||||
|
|
||||||
|
@ -38,12 +39,12 @@ public:
|
||||||
return m_map_current;
|
return m_map_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_quad_count() const -> unsigned int
|
[[nodiscard]] auto get_quad_count() const -> unsigned int
|
||||||
{
|
{
|
||||||
return m_quad_count;
|
return m_quad_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto get_vertex_size() const -> unsigned int
|
[[nodiscard]] constexpr auto get_vertex_size() const -> unsigned int
|
||||||
{
|
{
|
||||||
return sizeof(TextureVertexData);
|
return sizeof(TextureVertexData);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +62,7 @@ private:
|
||||||
|
|
||||||
TextureVertexData *m_map_end = nullptr;
|
TextureVertexData *m_map_end = nullptr;
|
||||||
|
|
||||||
unsigned int m_quad_count;
|
unsigned int m_quad_count{0u};
|
||||||
|
|
||||||
unsigned int m_max_vertices;
|
unsigned int m_max_vertices;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,7 @@ class SharedContext;
|
||||||
class TintedTextureRendererProgram: RendererProgram
|
class TintedTextureRendererProgram: RendererProgram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~TintedTextureRendererProgram() = default;
|
||||||
struct TintedTextureVertexData
|
struct TintedTextureVertexData
|
||||||
{
|
{
|
||||||
glm::vec4 position;
|
glm::vec4 position;
|
||||||
|
@ -25,7 +26,7 @@ public:
|
||||||
glm::vec2 texcoord;
|
glm::vec2 texcoord;
|
||||||
};
|
};
|
||||||
|
|
||||||
TintedTextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
|
TintedTextureRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& sharedContext);
|
||||||
|
|
||||||
auto advance() -> bool;
|
auto advance() -> bool;
|
||||||
|
|
||||||
|
@ -40,12 +41,12 @@ public:
|
||||||
return m_map_current;
|
return m_map_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_quad_count() const -> unsigned int
|
[[nodiscard]] auto get_quad_count() const -> unsigned int
|
||||||
{
|
{
|
||||||
return m_quad_count;
|
return m_quad_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto get_vertex_size() const -> unsigned int
|
[[nodiscard]] constexpr auto get_vertex_size() const -> unsigned int
|
||||||
{
|
{
|
||||||
return sizeof(TintedTextureVertexData);
|
return sizeof(TintedTextureVertexData);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +64,7 @@ private:
|
||||||
|
|
||||||
TintedTextureVertexData *m_map_end = nullptr;
|
TintedTextureVertexData *m_map_end = nullptr;
|
||||||
|
|
||||||
unsigned int m_quad_count;
|
unsigned int m_quad_count{0u};
|
||||||
|
|
||||||
unsigned int m_max_vertices;
|
unsigned int m_max_vertices;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,9 +20,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto create(
|
static auto create(
|
||||||
BasicFileHandle vertexFile,
|
const BasicFileHandle& vertexFile,
|
||||||
BasicFileHandle pixelFile,
|
const BasicFileHandle& pixelFile,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
) -> Ref<Shader>;
|
) -> Ref<Shader>;
|
||||||
|
|
||||||
virtual ~Shader() = default;
|
virtual ~Shader() = default;
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
unsigned int components,
|
unsigned int components,
|
||||||
unsigned char *pixels,
|
unsigned char *pixels,
|
||||||
Ref<SharedContext> sharedContext,
|
const Ref<SharedContext>& sharedContext,
|
||||||
const std::string &filePath
|
const std::string &filePath
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
virtual auto get_texture() -> void * = 0;
|
virtual auto get_texture() -> void * = 0;
|
||||||
|
|
||||||
auto GetFilePath() const -> const std::string &
|
[[nodiscard]] auto GetFilePath() const -> const std::string &
|
||||||
{
|
{
|
||||||
return m_file_path;
|
return m_file_path;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
std::string m_file_path;
|
std::string m_file_path;
|
||||||
|
|
||||||
Texture(const std::string &filePath);
|
Texture(std::string filePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -34,10 +34,10 @@ class VertexLayout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static auto create(
|
static auto create(
|
||||||
Ref<VertexBuffer> vertexBuffer,
|
const Ref<VertexBuffer>& vertexBuffer,
|
||||||
Ref<Shader> shader,
|
const Ref<Shader>& shader,
|
||||||
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
) -> Ref<VertexLayout>;
|
) -> Ref<VertexLayout>;
|
||||||
|
|
||||||
virtual ~VertexLayout() = default;
|
virtual ~VertexLayout() = default;
|
||||||
|
|
|
@ -31,19 +31,19 @@ public:
|
||||||
return s_context->m_mouse_buttons[code];
|
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;
|
return s_context->m_mouse_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_event(const Event &inputEvent);
|
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;
|
return m_user_interface_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_receiving_game_events() const -> bool
|
[[nodiscard]] auto is_receiving_game_events() const -> bool
|
||||||
{
|
{
|
||||||
return m_game_events;
|
return m_game_events;
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,19 @@ public:
|
||||||
private:
|
private:
|
||||||
static Input *s_context;
|
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_position;
|
||||||
|
|
||||||
glm::vec2 m_mouse_delta;
|
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();
|
Input();
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace Light {
|
|
||||||
|
|
||||||
namespace Key {
|
|
||||||
|
namespace Light::Key {
|
||||||
enum : uint16_t
|
enum : uint16_t
|
||||||
{
|
{
|
||||||
/* digits */
|
/* digits */
|
||||||
|
@ -179,4 +179,4 @@ enum : uint16_t
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Light
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace Light {
|
|
||||||
|
|
||||||
namespace Mouse {
|
|
||||||
|
namespace Light::Mouse {
|
||||||
enum : uint8_t
|
enum : uint8_t
|
||||||
{
|
{
|
||||||
Button1 = 0,
|
Button1 = 0,
|
||||||
|
@ -22,4 +22,4 @@ enum : uint8_t
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Light
|
|
||||||
|
|
|
@ -24,11 +24,11 @@ class WindowGainFocusEvent;
|
||||||
class Layer
|
class Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Layer(const std::string &name);
|
Layer(std::string name);
|
||||||
|
|
||||||
virtual ~Layer() = default;
|
virtual ~Layer() = default;
|
||||||
|
|
||||||
auto get_name() const -> const std::string &
|
[[nodiscard]] auto get_name() const -> const std::string &
|
||||||
{
|
{
|
||||||
return m_layer_name;
|
return m_layer_name;
|
||||||
}
|
}
|
||||||
|
@ -49,67 +49,67 @@ public:
|
||||||
protected:
|
protected:
|
||||||
std::string m_layer_name;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_button_pressed(const ButtonPressedEvent &event) -> bool
|
virtual auto on_button_pressed(const ButtonPressedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_button_released(const ButtonReleasedEvent &event) -> bool
|
virtual auto on_button_released(const ButtonReleasedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_wheel_scrolled(const WheelScrolledEvent &event) -> bool
|
virtual auto on_wheel_scrolled(const WheelScrolledEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_key_pressed(const KeyPressedEvent &event) -> bool
|
virtual auto on_key_pressed(const KeyPressedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_key_repeat(const KeyRepeatEvent &event) -> bool
|
virtual auto on_key_repeat(const KeyRepeatEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_key_released(const KeyReleasedEvent &event) -> bool
|
virtual auto on_key_released(const KeyReleasedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_set_char(const SetCharEvent &event) -> bool
|
virtual auto on_set_char(const SetCharEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_window_closed(const WindowClosedEvent &event) -> bool
|
virtual auto on_window_closed(const WindowClosedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_window_resized(const WindowResizedEvent &event) -> bool
|
virtual auto on_window_resized(const WindowResizedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_window_moved(const WindowMovedEvent &event) -> bool
|
virtual auto on_window_moved(const WindowMovedEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_window_lost_focus(const WindowLostFocusEvent &event) -> bool
|
virtual auto on_window_lost_focus(const WindowLostFocusEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual auto on_window_gain_focus(const WindowGainFocusEvent &event) -> bool
|
virtual auto on_window_gain_focus(const WindowGainFocusEvent & /*event*/) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace Light {
|
|
||||||
namespace Math {
|
namespace Light::Math {
|
||||||
|
|
||||||
auto rand(int min, int max, int decimals = 0) -> float;
|
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;
|
auto rand_vec3(int min, int max, int decimals = 0) -> glm::vec3;
|
||||||
|
|
||||||
} // namespace Math
|
} // namespace Light::Math
|
||||||
} // namespace Light
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Light {
|
||||||
class glBlender: public Blender
|
class glBlender: public Blender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~glBlender() = default;
|
||||||
glBlender();
|
glBlender();
|
||||||
|
|
||||||
void enable(BlendFactor srcFactor, BlendFactor dstFactor) override;
|
void enable(BlendFactor srcFactor, BlendFactor dstFactor) override;
|
||||||
|
|
|
@ -10,7 +10,7 @@ class glConstantBuffer: public ConstantBuffer
|
||||||
public:
|
public:
|
||||||
glConstantBuffer(ConstantBufferIndex index, unsigned int size);
|
glConstantBuffer(ConstantBufferIndex index, unsigned int size);
|
||||||
|
|
||||||
~glConstantBuffer();
|
virtual ~glConstantBuffer();
|
||||||
|
|
||||||
void bind() override;
|
void bind() override;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class glVertexBuffer: public VertexBuffer
|
||||||
public:
|
public:
|
||||||
glVertexBuffer(float *vertices, unsigned int stride, unsigned int count);
|
glVertexBuffer(float *vertices, unsigned int stride, unsigned int count);
|
||||||
|
|
||||||
~glVertexBuffer();
|
~glVertexBuffer() override;
|
||||||
|
|
||||||
void bind() override;
|
void bind() override;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class glIndexBuffer: public IndexBuffer
|
||||||
public:
|
public:
|
||||||
glIndexBuffer(unsigned int *indices, unsigned int count);
|
glIndexBuffer(unsigned int *indices, unsigned int count);
|
||||||
|
|
||||||
~glIndexBuffer();
|
~glIndexBuffer() override;
|
||||||
|
|
||||||
void bind() override;
|
void bind() override;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class glFramebuffer: public Framebuffer
|
||||||
public:
|
public:
|
||||||
glFramebuffer(const FramebufferSpecification &specification);
|
glFramebuffer(const FramebufferSpecification &specification);
|
||||||
|
|
||||||
~glFramebuffer();
|
virtual ~glFramebuffer();
|
||||||
|
|
||||||
void bind_as_target(const glm::vec4 &clearColor) override;
|
void bind_as_target(const glm::vec4 &clearColor) override;
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,16 @@ class glShader: public Shader
|
||||||
public:
|
public:
|
||||||
glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile);
|
glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile);
|
||||||
|
|
||||||
~glShader();
|
~glShader() override;
|
||||||
|
|
||||||
void bind() override;
|
void bind() override;
|
||||||
|
|
||||||
void un_bind() override;
|
void un_bind() override;
|
||||||
|
|
||||||
private:
|
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
|
} // namespace Light
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
const std::string &filePath
|
const std::string &filePath
|
||||||
);
|
);
|
||||||
|
|
||||||
~glTexture();
|
~glTexture() override;
|
||||||
|
|
||||||
void bind(unsigned int slot = 0u) override;
|
void bind(unsigned int slot = 0u) override;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class glUserInterface: public UserInterface
|
||||||
public:
|
public:
|
||||||
glUserInterface() = default;
|
glUserInterface() = default;
|
||||||
|
|
||||||
~glUserInterface();
|
~glUserInterface() override;
|
||||||
|
|
||||||
void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||||
override;
|
override;
|
||||||
|
@ -24,7 +24,7 @@ public:
|
||||||
void log_debug_data() override;
|
void log_debug_data() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFWwindow *m_window_handle;
|
GLFWwindow *m_window_handle{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -22,11 +22,11 @@ class glVertexLayout: public VertexLayout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
glVertexLayout(
|
glVertexLayout(
|
||||||
Ref<VertexBuffer> buffer,
|
const Ref<VertexBuffer>& buffer,
|
||||||
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
||||||
);
|
);
|
||||||
|
|
||||||
~glVertexLayout();
|
~glVertexLayout() override;
|
||||||
|
|
||||||
void bind() override;
|
void bind() override;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class lWindow: public Window
|
||||||
public:
|
public:
|
||||||
lWindow(std::function<void(Event &)> callback);
|
lWindow(std::function<void(Event &)> callback);
|
||||||
|
|
||||||
~lWindow();
|
~lWindow() override;
|
||||||
|
|
||||||
void poll_events() override;
|
void poll_events() override;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
||||||
void set_visibility(bool visible, bool toggle = false) override;
|
void set_visibility(bool visible, bool toggle = false) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFWwindow *m_handle;
|
GLFWwindow *m_handle{nullptr};
|
||||||
|
|
||||||
std::function<void(Event &)> m_event_callback;
|
std::function<void(Event &)> m_event_callback;
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ struct CameraComponent
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
operator SceneCamera()
|
operator SceneCamera() const
|
||||||
{
|
{
|
||||||
return camera;
|
return camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneCamera camera;
|
SceneCamera camera;
|
||||||
|
|
||||||
bool isPrimary;
|
bool isPrimary{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
|
|
||||||
virtual ~NativeScript() = default;
|
virtual ~NativeScript() = default;
|
||||||
|
|
||||||
auto get_uid() const -> unsigned int
|
[[nodiscard]] auto get_uid() const -> unsigned int
|
||||||
{
|
{
|
||||||
return m_unique_identifier;
|
return m_unique_identifier;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <engine/base/base.hpp>
|
#include <engine/base/base.hpp>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <utility>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
@ -17,19 +19,19 @@ struct SpriteRendererComponent
|
||||||
Ref<Texture> _texture,
|
Ref<Texture> _texture,
|
||||||
const glm::vec4 &_tint = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)
|
const glm::vec4 &_tint = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||||
)
|
)
|
||||||
: texture(_texture)
|
: texture(std::move(std::move(_texture)))
|
||||||
, tint(_tint)
|
, tint(_tint)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
operator Ref<Texture>()
|
operator Ref<Texture>() const
|
||||||
{
|
{
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Texture> texture;
|
Ref<Texture> texture;
|
||||||
|
|
||||||
glm::vec4 tint;
|
glm::vec4 tint{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <engine/base/base.hpp>
|
#include <engine/base/base.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
@ -10,11 +11,11 @@ struct TagComponent
|
||||||
|
|
||||||
TagComponent(const TagComponent &) = default;
|
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;
|
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))
|
return glm::translate(translation) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f))
|
||||||
* glm::scale(scale);
|
* glm::scale(scale);
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Light {
|
||||||
class Entity
|
class Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Entity(entt::entity handle = entt::null, Scene *registry = nullptr);
|
Entity(entt::entity handle = entt::null, Scene *scene = nullptr);
|
||||||
|
|
||||||
~Entity();
|
~Entity();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
return get_component<UUIDComponent>().uuid;
|
return get_component<UUIDComponent>().uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_valid() const -> bool
|
[[nodiscard]] auto is_valid() const -> bool
|
||||||
{
|
{
|
||||||
return m_handle != entt::null && m_scene != nullptr;
|
return m_handle != entt::null && m_scene != nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Timer
|
||||||
public:
|
public:
|
||||||
Timer();
|
Timer();
|
||||||
|
|
||||||
auto get_elapsed_time() const -> float
|
[[nodiscard]] auto get_elapsed_time() const -> float
|
||||||
{
|
{
|
||||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(
|
return (std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
std::chrono::steady_clock::now() - m_start
|
std::chrono::steady_clock::now() - m_start
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
auto get_delta_time() const -> float
|
[[nodiscard]] auto get_delta_time() const -> float
|
||||||
{
|
{
|
||||||
return m_delta_time;
|
return m_delta_time;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,13 @@ namespace Light {
|
||||||
class BasicFileHandle
|
class BasicFileHandle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~BasicFileHandle() = default;
|
||||||
BasicFileHandle(
|
BasicFileHandle(
|
||||||
uint8_t *data = nullptr,
|
uint8_t *data = nullptr,
|
||||||
uint32_t size = 0ull,
|
uint32_t size = 0ull,
|
||||||
const std::string &path = "",
|
std::string path = "",
|
||||||
const std::string &name = "",
|
std::string name = "",
|
||||||
const std::string &extension = ""
|
std::string extension = ""
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual void release();
|
virtual void release();
|
||||||
|
@ -22,7 +23,7 @@ public:
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_size() -> uint32_t
|
auto get_size() const -> uint32_t
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ public:
|
||||||
return m_name + '.' + m_extension;
|
return m_name + '.' + m_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_valid() const -> bool
|
[[nodiscard]] auto is_valid() const -> bool
|
||||||
{
|
{
|
||||||
return !!m_data;
|
return !!m_data;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +75,7 @@ private:
|
||||||
class ImageFileHandle: public BasicFileHandle
|
class ImageFileHandle: public BasicFileHandle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~ImageFileHandle() = default;
|
||||||
ImageFileHandle(
|
ImageFileHandle(
|
||||||
uint8_t *data,
|
uint8_t *data,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
|
@ -95,22 +97,22 @@ public:
|
||||||
|
|
||||||
void release() override;
|
void release() override;
|
||||||
|
|
||||||
auto get_width() const -> uint32_t
|
[[nodiscard]] auto get_width() const -> uint32_t
|
||||||
{
|
{
|
||||||
return m_width;
|
return m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_height() const -> uint32_t
|
[[nodiscard]] auto get_height() const -> uint32_t
|
||||||
{
|
{
|
||||||
return m_height;
|
return m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_components() const -> uint32_t
|
[[nodiscard]] auto get_components() const -> uint32_t
|
||||||
{
|
{
|
||||||
return m_components;
|
return m_components;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_desired_components() const -> uint32_t
|
[[nodiscard]] auto get_desired_components() const -> uint32_t
|
||||||
{
|
{
|
||||||
return m_desired_components;
|
return m_desired_components;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SceneSerializer
|
||||||
public:
|
public:
|
||||||
SceneSerializer(const Ref<Scene> &scene);
|
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;
|
auto deserialize(const std::string &file_path) -> bool;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
SceneCamera::SceneCamera()
|
SceneCamera::SceneCamera()
|
||||||
: m_orthographic_specification { 1000.0f, -1.0f, 10000.0f }
|
: m_orthographic_specification { .size=1000.0f, .near_plane=-1.0f, .far_plane=10000.0f }
|
||||||
, m_perspective_specification { glm::radians(45.0f), 0.01f, 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_aspect_ratio(16.0f / 9.0f)
|
||||||
, m_projection_type(ProjectionType::Orthographic)
|
|
||||||
{
|
{
|
||||||
calculate_projection();
|
calculate_projection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,20 +26,20 @@ Application::Application()
|
||||||
log_debug_data();
|
log_debug_data();
|
||||||
|
|
||||||
m_instrumentor = Instrumentor::create();
|
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_layer_stack = LayerStack::create();
|
||||||
m_input = Input::create();
|
m_input = Input::create();
|
||||||
|
|
||||||
m_resource_manager = ResourceManager::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()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
log_trc("Application::~Application()");
|
log_trc("Application::~Application()");
|
||||||
m_instrumentor->end_session();
|
Light::Instrumentor::end_session();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::game_loop()
|
void Application::game_loop()
|
||||||
|
@ -54,8 +54,8 @@ void Application::game_loop()
|
||||||
// reveal window
|
// reveal window
|
||||||
m_window->set_visibility(true);
|
m_window->set_visibility(true);
|
||||||
|
|
||||||
m_instrumentor->end_session();
|
Light::Instrumentor::end_session();
|
||||||
m_instrumentor->begin_session("Logs/ProfileResults_GameLoop.json");
|
Light::Instrumentor::begin_session("Logs/ProfileResults_GameLoop.json");
|
||||||
|
|
||||||
/* game loop */
|
/* game loop */
|
||||||
auto delta_timer = DeltaTimer {};
|
auto delta_timer = DeltaTimer {};
|
||||||
|
@ -65,8 +65,9 @@ void Application::game_loop()
|
||||||
// update layers
|
// update layers
|
||||||
lt_profile_scope("game_loop::update");
|
lt_profile_scope("game_loop::update");
|
||||||
|
|
||||||
for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++)
|
for (auto & it : *m_layer_stack) {
|
||||||
(*it)->on_update(delta_timer.get_delta_time());
|
it->on_update(delta_timer.get_delta_time());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -74,8 +75,9 @@ void Application::game_loop()
|
||||||
lt_profile_scope("game_loop::Render");
|
lt_profile_scope("game_loop::Render");
|
||||||
m_window->get_graphics_context()->get_renderer()->begin_frame();
|
m_window->get_graphics_context()->get_renderer()->begin_frame();
|
||||||
|
|
||||||
for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++)
|
for (auto & it : *m_layer_stack) {
|
||||||
(*it)->on_render();
|
it->on_render();
|
||||||
|
}
|
||||||
|
|
||||||
m_window->get_graphics_context()->get_renderer()->end_frame();
|
m_window->get_graphics_context()->get_renderer()->end_frame();
|
||||||
}
|
}
|
||||||
|
@ -85,8 +87,9 @@ void Application::game_loop()
|
||||||
lt_profile_scope("game_loop::UserInterface");
|
lt_profile_scope("game_loop::UserInterface");
|
||||||
m_window->get_graphics_context()->get_user_interface()->begin();
|
m_window->get_graphics_context()->get_user_interface()->begin();
|
||||||
|
|
||||||
for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++)
|
for (auto & it : *m_layer_stack) {
|
||||||
(*it)->on_user_interface_update();
|
it->on_user_interface_update();
|
||||||
|
}
|
||||||
|
|
||||||
m_window->get_graphics_context()->get_user_interface()->end();
|
m_window->get_graphics_context()->get_user_interface()->end();
|
||||||
}
|
}
|
||||||
|
@ -101,8 +104,8 @@ void Application::game_loop()
|
||||||
delta_timer.update();
|
delta_timer.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_instrumentor->end_session();
|
Light::Instrumentor::end_session();
|
||||||
m_instrumentor->begin_session("Logs/ProfileResults_Termination.json");
|
Light::Instrumentor::begin_session("Logs/ProfileResults_Termination.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::quit()
|
void Application::quit()
|
||||||
|
@ -117,10 +120,11 @@ void Application::on_event(const Event &event)
|
||||||
{
|
{
|
||||||
m_window->on_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(
|
m_window->get_graphics_context()->get_renderer()->on_window_resize(
|
||||||
(const WindowResizedEvent &)event
|
(const WindowResizedEvent &)event
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// input
|
// input
|
||||||
|
|
|
@ -9,7 +9,7 @@ auto Instrumentor::create() -> Scope<Instrumentor>
|
||||||
return make_scope<Instrumentor>(new Instrumentor);
|
return make_scope<Instrumentor>(new Instrumentor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Instrumentor::Instrumentor(): m_current_session_count(0u)
|
Instrumentor::Instrumentor()
|
||||||
{
|
{
|
||||||
// #todo: maintenance
|
// #todo: maintenance
|
||||||
lt_assert(
|
lt_assert(
|
||||||
|
@ -29,8 +29,9 @@ void Instrumentor::begin_session_impl(const std::string &outputPath)
|
||||||
|
|
||||||
void Instrumentor::end_session_impl()
|
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");
|
log_wrn("0 profiling for the ended session");
|
||||||
|
}
|
||||||
|
|
||||||
m_current_session_count = 0u;
|
m_current_session_count = 0u;
|
||||||
|
|
||||||
|
@ -41,14 +42,15 @@ void Instrumentor::end_session_impl()
|
||||||
|
|
||||||
void Instrumentor::submit_scope_profile_impl(const ScopeProfileResult &profileResult)
|
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 << "{";
|
m_output_file_stream << "{";
|
||||||
else
|
} else {
|
||||||
m_output_file_stream << ",{";
|
m_output_file_stream << ",{";
|
||||||
|
}
|
||||||
|
|
||||||
m_output_file_stream << "\"name\":\"" << profileResult.name << "\",";
|
m_output_file_stream << R"("name":")" << profileResult.name << "\",";
|
||||||
m_output_file_stream << "\"cat\": \"scope\",";
|
m_output_file_stream << R"("cat": "scope",)";
|
||||||
m_output_file_stream << "\"ph\": \"X\",";
|
m_output_file_stream << R"("ph": "X",)";
|
||||||
m_output_file_stream << "\"ts\":" << profileResult.start << ",";
|
m_output_file_stream << "\"ts\":" << profileResult.start << ",";
|
||||||
m_output_file_stream << "\"dur\":" << profileResult.duration << ",";
|
m_output_file_stream << "\"dur\":" << profileResult.duration << ",";
|
||||||
m_output_file_stream << "\"pid\":0,";
|
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)
|
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())
|
, m_start(std::chrono::steady_clock::now())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
auto Blender::create(Ref<SharedContext> sharedContext) -> Scope<Blender>
|
auto Blender::create(const Ref<SharedContext>& /*sharedContext*/) -> Scope<Blender>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Light {
|
||||||
auto ConstantBuffer::create(
|
auto ConstantBuffer::create(
|
||||||
ConstantBufferIndex index,
|
ConstantBufferIndex index,
|
||||||
unsigned int size,
|
unsigned int size,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& /*sharedContext*/
|
||||||
) -> Scope<ConstantBuffer>
|
) -> Scope<ConstantBuffer>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
|
@ -42,7 +42,7 @@ auto VertexBuffer::create(
|
||||||
float *vertices,
|
float *vertices,
|
||||||
unsigned int stride,
|
unsigned int stride,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& /*sharedContext*/
|
||||||
) -> Ref<VertexBuffer>
|
) -> Ref<VertexBuffer>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
|
@ -70,7 +70,7 @@ auto VertexBuffer::create(
|
||||||
auto IndexBuffer::create(
|
auto IndexBuffer::create(
|
||||||
unsigned int *indices,
|
unsigned int *indices,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& /*sharedContext*/
|
||||||
) -> Ref<IndexBuffer>
|
) -> Ref<IndexBuffer>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Light {
|
||||||
|
|
||||||
auto Framebuffer::create(
|
auto Framebuffer::create(
|
||||||
const FramebufferSpecification &specification,
|
const FramebufferSpecification &specification,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& /*sharedContext*/
|
||||||
) -> Ref<Framebuffer>
|
) -> Ref<Framebuffer>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
|
|
|
@ -18,8 +18,7 @@ namespace Light {
|
||||||
GraphicsContext *GraphicsContext::s_context = nullptr;
|
GraphicsContext *GraphicsContext::s_context = nullptr;
|
||||||
|
|
||||||
GraphicsContext::~GraphicsContext()
|
GraphicsContext::~GraphicsContext()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
auto GraphicsContext::create(GraphicsAPI api, GLFWwindow *windowHandle) -> Scope<GraphicsContext>
|
auto GraphicsContext::create(GraphicsAPI api, GLFWwindow *windowHandle) -> Scope<GraphicsContext>
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
auto RenderCommand::create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
auto RenderCommand::create(GLFWwindow *windowHandle, const Ref<SharedContext>& /*sharedContext*/)
|
||||||
-> Scope<RenderCommand>
|
-> Scope<RenderCommand>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
|
|
|
@ -9,21 +9,21 @@
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/matrix.hpp>
|
#include <glm/matrix.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
Renderer *Renderer::s_context = nullptr;
|
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_quad_renderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext)
|
||||||
, m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext)
|
, m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext)
|
||||||
, m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext)
|
, m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext)
|
||||||
, m_view_projection_buffer(nullptr)
|
, m_view_projection_buffer(nullptr)
|
||||||
, m_render_command(nullptr)
|
, m_render_command(nullptr)
|
||||||
, m_blender(nullptr)
|
, m_blender(nullptr)
|
||||||
, m_default_framebuffer_camera(nullptr)
|
|
||||||
, m_target_framebuffer(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!");
|
lt_assert(!s_context, "An instance of 'renderer' already exists, do not construct this class!");
|
||||||
s_context = this;
|
s_context = this;
|
||||||
|
@ -41,7 +41,7 @@ Renderer::Renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||||
|
|
||||||
auto Renderer::create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext) -> Scope<Renderer>
|
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)
|
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::translate(glm::mat4(1.0f), position)
|
||||||
* glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }),
|
* glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }),
|
||||||
tint,
|
tint,
|
||||||
texture
|
std::move(texture)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void Renderer::draw_quad_impl(
|
||||||
draw_quad(
|
draw_quad(
|
||||||
glm::translate(glm::mat4(1.0f), position)
|
glm::translate(glm::mat4(1.0f), position)
|
||||||
* glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }),
|
* glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }),
|
||||||
texture
|
std::move(texture)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//======================================== DRAW_QUAD ========================================//
|
//======================================== DRAW_QUAD ========================================//
|
||||||
|
@ -127,7 +127,7 @@ void Renderer::draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint)
|
||||||
//==================== DRAW_QUAD_TINT ====================//
|
//==================== DRAW_QUAD_TINT ====================//
|
||||||
|
|
||||||
//==================== DRAW_QUAD_TEXTURE ====================//
|
//==================== 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
|
// #todo: implement a proper binding
|
||||||
lt_assert(texture, "Texture passed to renderer::draw_quad_impl");
|
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(
|
void Renderer::draw_quad_impl(
|
||||||
const glm::mat4 &transform,
|
const glm::mat4 &transform,
|
||||||
const glm::vec4 &tint,
|
const glm::vec4 &tint,
|
||||||
Ref<Texture> texture
|
const Ref<Texture> &texture
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// #todo: implement a proper binding
|
// #todo: implement a proper binding
|
||||||
|
@ -229,7 +229,9 @@ void Renderer::begin_scene_impl(
|
||||||
m_target_framebuffer = targetFrameBuffer;
|
m_target_framebuffer = targetFrameBuffer;
|
||||||
|
|
||||||
if (targetFrameBuffer)
|
if (targetFrameBuffer)
|
||||||
|
{
|
||||||
targetFrameBuffer->bind_as_target(camera->get_background_color());
|
targetFrameBuffer->bind_as_target(camera->get_background_color());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_default_framebuffer_camera = camera;
|
m_default_framebuffer_camera = camera;
|
||||||
|
@ -237,7 +239,7 @@ void Renderer::begin_scene_impl(
|
||||||
}
|
}
|
||||||
|
|
||||||
// update view projection buffer
|
// 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);
|
map[0] = camera->get_projection() * glm::inverse(cameraTransform);
|
||||||
m_view_projection_buffer->un_map();
|
m_view_projection_buffer->un_map();
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,12 @@
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext)
|
QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, const Ref<SharedContext>& sharedContext)
|
||||||
: m_shader(nullptr)
|
: m_shader(nullptr)
|
||||||
, m_index_buffer(nullptr)
|
, m_index_buffer(nullptr)
|
||||||
, m_vertex_layout(nullptr)
|
, m_vertex_layout(nullptr)
|
||||||
, m_map_current(nullptr)
|
,
|
||||||
, m_map_end(nullptr)
|
m_max_vertices(maxVertices)
|
||||||
, m_quad_count(0u)
|
|
||||||
, m_max_vertices(maxVertices)
|
|
||||||
{
|
{
|
||||||
// #todo: don't use relative path
|
// #todo: don't use relative path
|
||||||
ResourceManager::load_shader(
|
ResourceManager::load_shader(
|
||||||
|
|
|
@ -9,15 +9,13 @@ namespace Light {
|
||||||
|
|
||||||
TextureRendererProgram::TextureRendererProgram(
|
TextureRendererProgram::TextureRendererProgram(
|
||||||
unsigned int maxVertices,
|
unsigned int maxVertices,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
)
|
)
|
||||||
: m_shader(nullptr)
|
: m_shader(nullptr)
|
||||||
, m_index_buffer(nullptr)
|
, m_index_buffer(nullptr)
|
||||||
, m_vertex_layout(nullptr)
|
, m_vertex_layout(nullptr)
|
||||||
, m_map_current(nullptr)
|
,
|
||||||
, m_map_end(nullptr)
|
m_max_vertices(maxVertices)
|
||||||
, m_quad_count(0u)
|
|
||||||
, m_max_vertices(maxVertices)
|
|
||||||
{
|
{
|
||||||
// #todo: don't use relative path
|
// #todo: don't use relative path
|
||||||
ResourceManager::load_shader(
|
ResourceManager::load_shader(
|
||||||
|
|
|
@ -9,15 +9,13 @@ namespace Light {
|
||||||
|
|
||||||
TintedTextureRendererProgram::TintedTextureRendererProgram(
|
TintedTextureRendererProgram::TintedTextureRendererProgram(
|
||||||
unsigned int maxVertices,
|
unsigned int maxVertices,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& sharedContext
|
||||||
)
|
)
|
||||||
: m_shader(nullptr)
|
: m_shader(nullptr)
|
||||||
, m_index_buffer(nullptr)
|
, m_index_buffer(nullptr)
|
||||||
, m_vertex_layout(nullptr)
|
, m_vertex_layout(nullptr)
|
||||||
, m_map_current(nullptr)
|
,
|
||||||
, m_map_end(nullptr)
|
m_max_vertices(maxVertices)
|
||||||
, m_quad_count(0u)
|
|
||||||
, m_max_vertices(maxVertices)
|
|
||||||
{
|
{
|
||||||
// #todo: don't use relative path
|
// #todo: don't use relative path
|
||||||
ResourceManager::load_shader(
|
ResourceManager::load_shader(
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
auto Shader::create(
|
auto Shader::create(
|
||||||
BasicFileHandle vertexFile,
|
const BasicFileHandle& vertexFile,
|
||||||
BasicFileHandle pixelFile,
|
const BasicFileHandle& pixelFile,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& /*sharedContext*/
|
||||||
) -> Ref<Shader>
|
) -> Ref<Shader>
|
||||||
{
|
{
|
||||||
// load shader source
|
// load shader source
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <engine/graphics/graphics_context.hpp>
|
#include <engine/graphics/graphics_context.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ auto Texture::create(
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
unsigned int components,
|
unsigned int components,
|
||||||
unsigned char *pixels,
|
unsigned char *pixels,
|
||||||
Ref<SharedContext> sharedContext,
|
const Ref<SharedContext>& /*sharedContext*/,
|
||||||
const std::string &filePath
|
const std::string &filePath
|
||||||
) -> Ref<Texture>
|
) -> 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 {
|
namespace Light {
|
||||||
|
|
||||||
auto VertexLayout::create(
|
auto VertexLayout::create(
|
||||||
Ref<VertexBuffer> vertexBuffer,
|
const Ref<VertexBuffer>& vertexBuffer,
|
||||||
Ref<Shader> shader,
|
const Ref<Shader>& /*shader*/,
|
||||||
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
||||||
Ref<SharedContext> sharedContext
|
const Ref<SharedContext>& /*sharedContext*/
|
||||||
) -> Ref<VertexLayout>
|
) -> Ref<VertexLayout>
|
||||||
{
|
{
|
||||||
switch (GraphicsContext::get_graphics_api())
|
switch (GraphicsContext::get_graphics_api())
|
||||||
|
|
|
@ -16,13 +16,10 @@ auto Input::create() -> Scope<Input>
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::Input()
|
Input::Input()
|
||||||
: m_keyboad_keys {}
|
:
|
||||||
, m_mouse_buttons {}
|
m_mouse_position {}
|
||||||
, m_mouse_position {}
|
|
||||||
, m_mouse_delta {}
|
, m_mouse_delta {}
|
||||||
, m_mouse_wheel_delta {}
|
|
||||||
, m_user_interface_events(true)
|
|
||||||
, m_game_events(true)
|
|
||||||
{
|
{
|
||||||
lt_assert(
|
lt_assert(
|
||||||
!s_context,
|
!s_context,
|
||||||
|
@ -43,9 +40,10 @@ void Input::receieve_game_events_impl(bool receive, bool toggle /*= false*/)
|
||||||
auto prev = m_game_events;
|
auto prev = m_game_events;
|
||||||
m_game_events = toggle ? !m_user_interface_events : receive;
|
m_game_events = toggle ? !m_user_interface_events : receive;
|
||||||
|
|
||||||
if (m_game_events != prev)
|
if (m_game_events != prev) {
|
||||||
restart_input_state();
|
restart_input_state();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Input::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();
|
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());
|
io.MousePos = ImVec2(event.get_x(), event.get_y());
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case EventType::ButtonPressed:
|
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;
|
m_mouse_buttons[event.get_button()] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_user_interface_events)
|
if (m_user_interface_events) {
|
||||||
io.MouseDown[event.get_button()] = true;
|
io.MouseDown[event.get_button()] = true;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case EventType::ButtonReleased:
|
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;
|
m_mouse_buttons[event.get_button()] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_user_interface_events)
|
if (m_user_interface_events) {
|
||||||
io.MouseDown[event.get_button()] = false;
|
io.MouseDown[event.get_button()] = false;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case EventType::WheelScrolled:
|
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();
|
m_mouse_wheel_delta = event.get_offset();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_user_interface_events)
|
if (m_user_interface_events) {
|
||||||
io.MouseWheel = event.get_offset();
|
io.MouseWheel = event.get_offset();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//** KEYBOARD_EVENTS **//
|
//** KEYBOARD_EVENTS **//
|
||||||
case EventType::KeyPressed:
|
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;
|
m_keyboad_keys[event.get_key()] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_user_interface_events)
|
if (m_user_interface_events)
|
||||||
{
|
{
|
||||||
|
@ -133,13 +139,15 @@ void Input::on_event(const Event &inputEvent)
|
||||||
}
|
}
|
||||||
case EventType::KeyReleased:
|
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;
|
m_keyboad_keys[event.get_key()] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_user_interface_events)
|
if (m_user_interface_events) {
|
||||||
io.KeysDown[event.get_key()] = false;
|
io.KeysDown[event.get_key()] = false;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +155,7 @@ void Input::on_event(const Event &inputEvent)
|
||||||
{
|
{
|
||||||
if (m_user_interface_events)
|
if (m_user_interface_events)
|
||||||
{
|
{
|
||||||
const auto &event = (const SetCharEvent &)inputEvent;
|
const auto &event = dynamic_cast<const SetCharEvent &>(inputEvent);
|
||||||
io.AddInputCharacter(event.get_character());
|
io.AddInputCharacter(event.get_character());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Light {
|
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());
|
return make_scope<LayerStack>(new LayerStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerStack::LayerStack(): m_layers {}, m_begin(), m_end()
|
LayerStack::LayerStack()
|
||||||
{
|
{
|
||||||
lt_assert(
|
lt_assert(
|
||||||
!s_context,
|
!s_context,
|
||||||
|
@ -25,9 +25,10 @@ LayerStack::LayerStack(): m_layers {}, m_begin(), m_end()
|
||||||
|
|
||||||
LayerStack::~LayerStack()
|
LayerStack::~LayerStack()
|
||||||
{
|
{
|
||||||
for (auto *layer : m_layers)
|
for (auto *layer : m_layers) {
|
||||||
delete layer;
|
delete layer;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LayerStack::attach_layer_impl(Layer *layer)
|
void LayerStack::attach_layer_impl(Layer *layer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <engine/math/random.hpp>
|
#include <engine/math/random.hpp>
|
||||||
|
|
||||||
namespace Light {
|
|
||||||
namespace Math {
|
namespace Light::Math {
|
||||||
|
|
||||||
auto rand(int min, int max, int decimals /* = 0 */) -> float
|
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 };
|
return { r1, r2, r3 };
|
||||||
}
|
}
|
||||||
} // namespace Math
|
} // namespace Light::Math
|
||||||
} // namespace Light
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <cstddef>
|
||||||
#include <engine/platform/graphics/opengl/buffers.hpp>
|
#include <engine/platform/graphics/opengl/buffers.hpp>
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
|
@ -41,7 +42,12 @@ glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned in
|
||||||
: m_buffer_id(NULL)
|
: m_buffer_id(NULL)
|
||||||
{
|
{
|
||||||
glCreateBuffers(1, &m_buffer_id);
|
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()
|
glVertexBuffer::~glVertexBuffer()
|
||||||
|
@ -108,8 +114,10 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffe
|
||||||
|
|
||||||
// delete indices
|
// delete indices
|
||||||
if (!hasIndices)
|
if (!hasIndices)
|
||||||
|
{
|
||||||
delete[] indices;
|
delete[] indices;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glIndexBuffer::~glIndexBuffer()
|
glIndexBuffer::~glIndexBuffer()
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,9 +70,9 @@ void glGraphicsContext::set_debug_message_callback()
|
||||||
unsigned int type,
|
unsigned int type,
|
||||||
unsigned int id,
|
unsigned int id,
|
||||||
unsigned int severity,
|
unsigned int severity,
|
||||||
int length,
|
int /*length*/,
|
||||||
const char *message,
|
const char *message,
|
||||||
const void *userParam) {
|
const void * /*userParam*/) {
|
||||||
switch (severity)
|
switch (severity)
|
||||||
{
|
{
|
||||||
case GL_DEBUG_SEVERITY_HIGH:
|
case GL_DEBUG_SEVERITY_HIGH:
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_shader_id(0u)
|
glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile)
|
||||||
{
|
{
|
||||||
// create
|
// create
|
||||||
m_shader_id = glCreateProgram();
|
m_shader_id = glCreateProgram();
|
||||||
|
|
||||||
std::string vertexSource(vertexFile.get_data(), vertexFile.get_data() + vertexFile.get_size());
|
std::string const 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 pixelSource(pixelFile.get_data(), pixelFile.get_data() + pixelFile.get_size());
|
||||||
|
|
||||||
unsigned int vertexShader = compile_shader(vertexSource, Shader::Stage::VERTEX);
|
unsigned int const vertexShader = compile_shader(vertexSource, Shader::Stage::VERTEX);
|
||||||
unsigned int pixelShader = compile_shader(pixelSource, Shader::Stage::PIXEL);
|
unsigned int const pixelShader = compile_shader(pixelSource, Shader::Stage::PIXEL);
|
||||||
|
|
||||||
// attach shaders
|
// attach shaders
|
||||||
glAttachShader(m_shader_id, vertexShader);
|
glAttachShader(m_shader_id, vertexShader);
|
||||||
|
@ -68,7 +68,7 @@ void glShader::un_bind()
|
||||||
// return result;
|
// 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
|
// &(address of) needs an lvalue
|
||||||
const auto *lvalue_source = source.c_str();
|
const auto *lvalue_source = source.c_str();
|
||||||
|
@ -80,7 +80,7 @@ auto glShader::compile_shader(std::string source, Shader::Stage stage) -> unsign
|
||||||
);
|
);
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
glShaderSource(shader, 1, &lvalue_source, NULL);
|
glShaderSource(shader, 1, &lvalue_source, nullptr);
|
||||||
glCompileShader(shader);
|
glCompileShader(shader);
|
||||||
|
|
||||||
// check
|
// check
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Light {
|
||||||
|
|
||||||
void glUserInterface::platform_implementation(
|
void glUserInterface::platform_implementation(
|
||||||
GLFWwindow *windowHandle,
|
GLFWwindow *windowHandle,
|
||||||
Ref<SharedContext> sharedContext
|
Ref<SharedContext> /*sharedContext*/
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_window_handle = windowHandle;
|
m_window_handle = windowHandle;
|
||||||
|
@ -23,8 +23,9 @@ glUserInterface::~glUserInterface()
|
||||||
// #todo: handle this in a better way
|
// #todo: handle this in a better way
|
||||||
auto &io = ImGui::GetIO();
|
auto &io = ImGui::GetIO();
|
||||||
|
|
||||||
if (io.IniFilename == "default_gui_layout.ini")
|
if (io.IniFilename == "default_gui_layout.ini") {
|
||||||
io.IniFilename = "user_gui_layout.ini";
|
io.IniFilename = "user_gui_layout.ini";
|
||||||
|
}
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
glVertexLayout::glVertexLayout(
|
glVertexLayout::glVertexLayout(
|
||||||
Ref<VertexBuffer> buffer,
|
const Ref<VertexBuffer>& buffer,
|
||||||
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
||||||
)
|
)
|
||||||
: m_array_id(NULL)
|
: m_array_id(NULL)
|
||||||
|
@ -73,32 +73,32 @@ auto glVertexLayout::get_element_desc(VertexElementType type, unsigned int offse
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
/* byte */
|
/* byte */
|
||||||
case Light::VertexElementType::Byte1: 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 { GL_BYTE, 1u, sizeof(GLbyte), offset };
|
case Light::VertexElementType::Byte2: return { .type=GL_BYTE, .count=1u, .typeSize=sizeof(GLbyte), .offset=offset };
|
||||||
case Light::VertexElementType::Byte4: return { GL_BYTE, 1u, sizeof(GLbyte), offset };
|
case Light::VertexElementType::Byte4: return { .type=GL_BYTE, .count=1u, .typeSize=sizeof(GLbyte), .offset=offset };
|
||||||
|
|
||||||
/* ubyte */
|
/* ubyte */
|
||||||
case Light::VertexElementType::UByte1: return { GL_UNSIGNED_BYTE, 1u, sizeof(GLubyte), offset };
|
case Light::VertexElementType::UByte1: return { .type=GL_UNSIGNED_BYTE, .count=1u, .typeSize=sizeof(GLubyte), .offset=offset };
|
||||||
case Light::VertexElementType::UByte2: return { GL_UNSIGNED_BYTE, 2u, sizeof(GLubyte), offset };
|
case Light::VertexElementType::UByte2: return { .type=GL_UNSIGNED_BYTE, .count=2u, .typeSize=sizeof(GLubyte), .offset=offset };
|
||||||
case Light::VertexElementType::UByte4: return { GL_UNSIGNED_BYTE, 4u, sizeof(GLubyte), offset };
|
case Light::VertexElementType::UByte4: return { .type=GL_UNSIGNED_BYTE, .count=4u, .typeSize=sizeof(GLubyte), .offset=offset };
|
||||||
|
|
||||||
/* int */
|
/* int */
|
||||||
case VertexElementType::Int1: return { GL_INT, 1u, sizeof(GLint), offset };
|
case VertexElementType::Int1: return { .type=GL_INT, .count=1u, .typeSize=sizeof(GLint), .offset=offset };
|
||||||
case VertexElementType::Int2: return { GL_INT, 2u, sizeof(GLint), offset };
|
case VertexElementType::Int2: return { .type=GL_INT, .count=2u, .typeSize=sizeof(GLint), .offset=offset };
|
||||||
case VertexElementType::Int3: return { GL_INT, 3u, sizeof(GLint), offset };
|
case VertexElementType::Int3: return { .type=GL_INT, .count=3u, .typeSize=sizeof(GLint), .offset=offset };
|
||||||
case VertexElementType::Int4: return { GL_INT, 4u, sizeof(GLint), offset };
|
case VertexElementType::Int4: return { .type=GL_INT, .count=4u, .typeSize=sizeof(GLint), .offset=offset };
|
||||||
|
|
||||||
/* uint */
|
/* uint */
|
||||||
case VertexElementType::UInt1: return { GL_UNSIGNED_INT, 1u, sizeof(GLuint), offset };
|
case VertexElementType::UInt1: return { .type=GL_UNSIGNED_INT, .count=1u, .typeSize=sizeof(GLuint), .offset=offset };
|
||||||
case VertexElementType::UInt2: return { GL_UNSIGNED_INT, 2u, sizeof(GLuint), offset };
|
case VertexElementType::UInt2: return { .type=GL_UNSIGNED_INT, .count=2u, .typeSize=sizeof(GLuint), .offset=offset };
|
||||||
case VertexElementType::UInt3: return { GL_UNSIGNED_INT, 3u, sizeof(GLuint), offset };
|
case VertexElementType::UInt3: return { .type=GL_UNSIGNED_INT, .count=3u, .typeSize=sizeof(GLuint), .offset=offset };
|
||||||
case VertexElementType::UInt4: return { GL_UNSIGNED_INT, 4u, sizeof(GLuint), offset };
|
case VertexElementType::UInt4: return { .type=GL_UNSIGNED_INT, .count=4u, .typeSize=sizeof(GLuint), .offset=offset };
|
||||||
|
|
||||||
/* float */
|
/* float */
|
||||||
case VertexElementType::Float1: return { GL_FLOAT, 1u, sizeof(GLfloat), offset };
|
case VertexElementType::Float1: return { .type=GL_FLOAT, .count=1u, .typeSize=sizeof(GLfloat), .offset=offset };
|
||||||
case VertexElementType::Float2: return { GL_FLOAT, 2u, sizeof(GLfloat), offset };
|
case VertexElementType::Float2: return { .type=GL_FLOAT, .count=2u, .typeSize=sizeof(GLfloat), .offset=offset };
|
||||||
case VertexElementType::Float3: return { GL_FLOAT, 3u, sizeof(GLfloat), offset };
|
case VertexElementType::Float3: return { .type=GL_FLOAT, .count=3u, .typeSize=sizeof(GLfloat), .offset=offset };
|
||||||
case VertexElementType::Float4: return { GL_FLOAT, 4u, sizeof(GLfloat), offset };
|
case VertexElementType::Float4: return { .type=GL_FLOAT, .count=4u, .typeSize=sizeof(GLfloat), .offset=offset };
|
||||||
|
|
||||||
default: lt_assert(false, "Invalid 'VertexElementType'"); return {};
|
default: lt_assert(false, "Invalid 'VertexElementType'"); return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,19 @@
|
||||||
#include <engine/events/window.hpp>
|
#include <engine/events/window.hpp>
|
||||||
#include <engine/graphics/graphics_context.hpp>
|
#include <engine/graphics/graphics_context.hpp>
|
||||||
#include <engine/platform/os/linux/l_window.hpp>
|
#include <engine/platform/os/linux/l_window.hpp>
|
||||||
|
#include <utility>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Light {
|
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);
|
return create_scope<lWindow>(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
lWindow::lWindow(std::function<void(Event &)> 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
|
// init glfw
|
||||||
lt_assert(glfwInit(), "lWindow::lWindow: failed to initialize '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;
|
case EventType::WindowClosed: b_Closed = true; break;
|
||||||
|
|
||||||
/* resized */
|
/* 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;
|
m_properties.visible = toggle ? !m_properties.visible : visible;
|
||||||
|
|
||||||
if (m_properties.visible)
|
if (m_properties.visible) {
|
||||||
glfwShowWindow(m_handle);
|
glfwShowWindow(m_handle);
|
||||||
else
|
} else {
|
||||||
glfwHideWindow(m_handle);
|
glfwHideWindow(m_handle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void lWindow::bind_glfw_events()
|
void lWindow::bind_glfw_events()
|
||||||
{
|
{
|
||||||
|
@ -130,8 +133,8 @@ void lWindow::bind_glfw_events()
|
||||||
callback(event);
|
callback(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int mods) {
|
glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int /*mods*/) {
|
||||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
std::function<void(Event &)> const callback = *(std::function<void(Event &)> *)
|
||||||
glfwGetWindowUserPointer(window);
|
glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
if (action == GLFW_PRESS)
|
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 callback = *(std::function<void(Event &)> *)glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
auto event = WheelScrolledEvent { static_cast<float>(yoffset) };
|
auto event = WheelScrolledEvent { static_cast<float>(yoffset) };
|
||||||
|
@ -155,7 +158,7 @@ void lWindow::bind_glfw_events()
|
||||||
|
|
||||||
glfwSetKeyCallback(
|
glfwSetKeyCallback(
|
||||||
m_handle,
|
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);
|
auto callback = *(std::function<void(Event &)> *)glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
|
|
|
@ -8,7 +8,6 @@ Entity::Entity(entt::entity handle, Scene *scene): m_handle(handle), m_scene(sce
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity::~Entity()
|
Entity::~Entity()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Light
|
} // namespace Light
|
||||||
|
|
|
@ -6,13 +6,12 @@
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
Scene::Scene(): m_registry()
|
Scene::Scene()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene::~Scene()
|
Scene::~Scene()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::on_create()
|
void Scene::on_create()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <engine/events/mouse.hpp>
|
#include <engine/events/mouse.hpp>
|
||||||
#include <engine/graphics/graphics_context.hpp>
|
#include <engine/graphics/graphics_context.hpp>
|
||||||
#include <engine/input/key_codes.hpp>
|
#include <engine/input/key_codes.hpp>
|
||||||
|
#include <utility>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
@ -38,7 +39,7 @@ auto UserInterface::create(GLFWwindow *windowHandle, Ref<SharedContext> sharedCo
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
scopeUserInterface->init(windowHandle, sharedContext);
|
scopeUserInterface->init(windowHandle, std::move(sharedContext));
|
||||||
return std::move(scopeUserInterface);
|
return std::move(scopeUserInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,15 +75,16 @@ void UserInterface::init(GLFWwindow *windowHandle, Ref<SharedContext> sharedCont
|
||||||
io.ConfigFlags |= ImGuiBackendFlags_RendererHasViewports;
|
io.ConfigFlags |= ImGuiBackendFlags_RendererHasViewports;
|
||||||
|
|
||||||
// #todo: handle this in a better way
|
// #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";
|
io.IniFilename = "user_gui_layout.ini";
|
||||||
else
|
} else {
|
||||||
io.IniFilename = "default_gui_layout.ini";
|
io.IniFilename = "default_gui_layout.ini";
|
||||||
|
}
|
||||||
|
|
||||||
// style
|
// style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
|
||||||
platform_implementation(windowHandle, sharedContext);
|
platform_implementation(windowHandle, std::move(sharedContext));
|
||||||
|
|
||||||
// keyboard map
|
// keyboard map
|
||||||
io.KeyMap[ImGuiKey_Tab] = Key::Tab;
|
io.KeyMap[ImGuiKey_Tab] = Key::Tab;
|
||||||
|
@ -127,11 +129,11 @@ void UserInterface::dockspace_begin()
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 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);
|
ImGui::PopStyleVar(3);
|
||||||
|
|
||||||
ImGuiStyle &style = ImGui::GetStyle();
|
ImGuiStyle &style = ImGui::GetStyle();
|
||||||
float minWinSizeX = style.WindowMinSize.x;
|
float const minWinSizeX = style.WindowMinSize.x;
|
||||||
style.WindowMinSize.x = 370.0f;
|
style.WindowMinSize.x = 370.0f;
|
||||||
ImGui::DockSpace(
|
ImGui::DockSpace(
|
||||||
ImGui::GetID("MyDockSpace"),
|
ImGui::GetID("MyDockSpace"),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include <engine/utils/file_manager.hpp>
|
#include <engine/utils/file_manager.hpp>
|
||||||
|
#include <utility>
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
@ -7,15 +8,15 @@ namespace Light {
|
||||||
BasicFileHandle::BasicFileHandle(
|
BasicFileHandle::BasicFileHandle(
|
||||||
uint8_t *data,
|
uint8_t *data,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
const std::string &path,
|
std::string path,
|
||||||
const std::string &name,
|
std::string name,
|
||||||
const std::string &extension
|
std::string extension
|
||||||
)
|
)
|
||||||
: m_data(data)
|
: m_data(data)
|
||||||
, m_size(size)
|
, m_size(size)
|
||||||
, m_path(path)
|
, m_path(std::move(path))
|
||||||
, m_name(name)
|
, m_name(std::move(name))
|
||||||
, m_extension(extension)
|
, m_extension(std::move(extension))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ auto ResourceManager::create() -> Scope<ResourceManager>
|
||||||
return make_scope(new ResourceManager());
|
return make_scope(new ResourceManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager::ResourceManager(): m_shaders {}, m_textures {}
|
ResourceManager::ResourceManager()
|
||||||
{
|
{
|
||||||
lt_assert(!s_context, "Repeated singleton construction");
|
lt_assert(!s_context, "Repeated singleton construction");
|
||||||
s_context = this;
|
s_context = this;
|
||||||
|
|
|
@ -19,8 +19,9 @@ struct convert<glm::vec3>
|
||||||
|
|
||||||
static auto decode(const Node &node, glm::vec3 &rhs) -> bool
|
static auto decode(const Node &node, glm::vec3 &rhs) -> bool
|
||||||
{
|
{
|
||||||
if (!node.IsSequence() || node.size() != 3)
|
if (!node.IsSequence() || node.size() != 3) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rhs.x = node[0].as<float>();
|
rhs.x = node[0].as<float>();
|
||||||
rhs.y = node[1].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
|
static auto decode(const Node &node, glm::vec4 &rhs) -> bool
|
||||||
{
|
{
|
||||||
if (!node.IsSequence() || node.size() != 4)
|
if (!node.IsSequence() || node.size() != 4) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rhs.x = node[0].as<float>();
|
rhs.x = node[0].as<float>();
|
||||||
rhs.y = node[1].as<float>();
|
rhs.y = node[1].as<float>();
|
||||||
|
@ -221,12 +223,12 @@ auto SceneSerializer::deserialize(const std::string &file_path) -> bool
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneSerializer::serialize_binary(const std::string &filePath)
|
void SceneSerializer::serialize_binary(const std::string & /*filePath*/)
|
||||||
{
|
{
|
||||||
log_err("NO_IMPLEMENT");
|
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");
|
log_err("NO_IMPLEMENT");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -14,11 +14,11 @@ class SceneHierarchyPanel: public Panel
|
||||||
public:
|
public:
|
||||||
SceneHierarchyPanel();
|
SceneHierarchyPanel();
|
||||||
|
|
||||||
SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel = nullptr);
|
SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> properties_panel = nullptr);
|
||||||
|
|
||||||
void on_user_interface_update();
|
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:
|
private:
|
||||||
void draw_node(Entity entity, const std::string &label);
|
void draw_node(Entity entity, const std::string &label);
|
||||||
|
|
Loading…
Add table
Reference in a new issue