diff --git a/modules/engine/include/engine/base/base.hpp b/modules/engine/include/engine/base/base.hpp index bbeab25..063e4a6 100644 --- a/modules/engine/include/engine/base/base.hpp +++ b/modules/engine/include/engine/base/base.hpp @@ -5,55 +5,55 @@ namespace Light { // Ref (Ref) -template -using Ref = std::shared_ptr; +template +using Ref = std::shared_ptr; -template -constexpr Ref CreateRef(Args &&...args) +template +constexpr Ref create_ref(Args &&...args) { - return std::make_shared(std::forward(args)...); + return std::make_shared(std::forward(args)...); } -template -constexpr Ref MakeRef(T *rawPointer) +template +constexpr Ref make_ref(t *rawPointer) { - return std::shared_ptr(rawPointer); + return std::shared_ptr(rawPointer); } // Scope (std::unique_ptr) -template -using Scope = std::unique_ptr; +template +using Scope = std::unique_ptr; -template -constexpr std::unique_ptr CreateScope(Args &&...args) +template +constexpr std::unique_ptr create_scope(Args &&...args) { - return std::make_unique(std::forward(args)...); + return std::make_unique(std::forward(args)...); } -template -constexpr std::unique_ptr MakeScope(T *rawPointer) +template +constexpr std::unique_ptr make_scope(t *rawPointer) { - return std::unique_ptr(rawPointer); + return std::unique_ptr(rawPointer); } } // namespace Light //========== PLATFORM ==========// -#define LT_WIN(x) // windows -#define LT_LIN(x) // linux -#define LT_MAC(x) // mac +#define lt_win(x) // windows +#define lt_lin(x) // linux +#define lt_mac(x) // mac #if defined(LIGHT_PLATFORM_WINDOWS) #define LT_BUILD_PLATFORM "Windows" - #define LT_WIN(x) x + #define lt_win(x) x #elif defined(LIGHT_PLATFORM_LINUX) #define LT_BUILD_PLATFORM "Linux" - #define LT_LIN(x) x + #define lt_lin(x) x #elif defined(LIGHT_PLATFORM_MAC) #error "Unsupported platform: MAC" - #define LT_MAC(x) x + #define lt_mac(x) x #else #error "Unsupported platform: Unknown" @@ -63,23 +63,23 @@ constexpr std::unique_ptr MakeScope(T *rawPointer) //====================================================================== OPERATIONS //======================================================================// /* assertions */ -#define ASSERT(x, ...) \ +#define lt_assert(x, ...) \ { \ if (!(x)) \ { \ - LOG(critical, __VA_ARGS__); \ - LT_DEBUG_TRAP(); \ + lt_log(critical, __VA_ARGS__); \ + lt_debug_trap(); \ throw ::Light::FailedAssertion(__FILE__, __LINE__); \ } \ } /* bit-wise */ -#define BIT(x) 1 << x +#define bit(x) 1 << x /* token */ -#define LT_PAIR_TOKEN_VALUE_TO_NAME(token) { token, #token } -#define LT_PAIR_TOKEN_NAME_TO_VALUE(token) { #token, token } -#define LT_TOKEN_NAME(token) #token +#define lt_pair_token_value_to_name(token) { token, #token } +#define lt_pair_token_name_to_value(token) { #token, token } +#define lt_token_name(token) #token //====================================================================== OPERATIONS //======================================================================// diff --git a/modules/engine/include/engine/base/entrypoint.hpp b/modules/engine/include/engine/base/entrypoint.hpp index 092f0ab..b2d62f4 100644 --- a/modules/engine/include/engine/base/entrypoint.hpp +++ b/modules/engine/include/engine/base/entrypoint.hpp @@ -21,29 +21,29 @@ int main(int argc, char *argv[]) try { application = Light::CreateApplication(); - ASSERT(application, "Light::Application is not intialized"); + lt_assert(application, "Light::Application is not intialized"); for (int i = 0; i < argc; i++) - LOG(info, "argv[{}]: {}", i, argv[i]); + lt_log(info, "argv[{}]: {}", i, argv[i]); - application->GameLoop(); + application->game_loop(); } // failed engine assertion catch (Light::FailedAssertion) { - LOG(critical, "Terminating due to unhandled 'FailedEngineAssertion'"); + lt_log(critical, "Terminating due to unhandled 'FailedEngineAssertion'"); exitCode = -1; } // gl exception catch (Light::glException) { - LOG(critical, "Terminating due to unhandled 'glException'"); + lt_log(critical, "Terminating due to unhandled 'glException'"); exitCode = -3; } // dx exception catch (Light::dxException) { - LOG(critical, "Terminating due to unhandled 'dxException'"); + lt_log(critical, "Terminating due to unhandled 'dxException'"); exitCode = -4; } @@ -67,20 +67,20 @@ int main(int argc, char *argv[]) try { application = Light::CreateApplication(); - ASSERT(application, "Light::Application is not intialized"); + lt_assert(application, "Light::Application is not intialized"); - application->GameLoop(); + application->game_loop(); } // failed engine assertion catch (Light::FailedAssertion) { - LOG(critical, "Exitting due to unhandled 'FailedEngineAssertion'"); + lt_log(critical, "Exitting due to unhandled 'FailedEngineAssertion'"); exitCode = -1; } // gl exception catch (Light::glException) { - LOG(critical, "main: exitting due to unhandled 'glException'"); + lt_log(critical, "main: exitting due to unhandled 'glException'"); exitCode = -3; } diff --git a/modules/engine/include/engine/base/portables/debug_trap.hpp b/modules/engine/include/engine/base/portables/debug_trap.hpp index c184ecb..22112a9 100644 --- a/modules/engine/include/engine/base/portables/debug_trap.hpp +++ b/modules/engine/include/engine/base/portables/debug_trap.hpp @@ -8,7 +8,7 @@ #ifdef LIGHT_DIST #ifdef _MSC_VER - #define LT_DEBUG_TRAP() \ + #define lt_debug_trap() \ LT_FILE_CRITICAL( \ "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ __FUNCSIG__, \ @@ -17,139 +17,139 @@ ) // or __FUNCSIG__ #else - #define LT_DEBUG_TRAP() \ + #define lt_debug_trap() \ LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__) #endif #endif - #if !defined(LT_DEBUG_TRAP) && defined(__has_builtin) && !defined(__ibmxl__) + #if !defined(lt_debug_trap) && defined(__has_builtin) && !defined(__ibmxl__) #if __has_builtin(__builtin_debugtrap) - #define LT_DEBUG_TRAP() __builtin_debugtrap() + #define lt_debug_trap() __builtin_debugtrap() #elif __has_builtin(__debugbreak) - #define LT_DEBUG_TRAP() __debugbreak() + #define lt_debug_trap() __debugbreak() #endif #endif - #if !defined(LT_DEBUG_TRAP) + #if !defined(lt_debug_trap) #if defined(_MSC_VER) || defined(__INTEL_COMPILER) - #define LT_DEBUG_TRAP() __debugbreak() + #define lt_debug_trap() __debugbreak() #elif defined(__ARMCC_VERSION) - #define LT_DEBUG_TRAP() __breakpoint(42) + #define lt_debug_trap() __breakpoint(42) #elif defined(__ibmxl__) || defined(__xlC__) #include - #define LT_DEBUG_TRAP() __trap(42) + #define lt_debug_trap() __trap(42) #elif defined(__DMC__) && defined(_M_IX86) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm int 3h; } #elif defined(__i386__) || defined(__x86_64__) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__("int3"); } #elif defined(__thumb__) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__(".inst 0xde01"); } #elif defined(__aarch64__) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__(".inst 0xd4200000"); } #elif defined(__arm__) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__(".inst 0xe7f001f0"); } #elif defined(__alpha__) && !defined(__osf__) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__("bpt"); } #elif defined(_54_) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__("ESTOP"); } #elif defined(_55_) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { - __asm__ __volatile__(";\n .if (.MNEMONIC)\n ESTOP_1\n .else\n ESTOP_1()\n .endif\n NOP"); + __asm__ __volatile__(";\n .if (.MNEMONIC)\n estop_1\n .else\n estop_1()\n .endif\n NOP"); } #elif defined(_64P_) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__("SWBP 0"); } #elif defined(_6x_) -static inline void LT_DEBUG_TRAP(void) +static inline void lt_debug_trap(void) { __asm__ __volatile__("NOP\n .word 0x10000000"); } #elif defined(__STDC_HOSTED__) && (__STDC_HOSTED__ == 0) && defined(__GNUC__) - #define LT_DEBUG_TRAP() __builtin_trap() + #define lt_debug_trap() __builtin_trap() #else #include #if defined(SIGTRAP) - #define LT_DEBUG_TRAP() raise(SIGTRAP) + #define lt_debug_trap() raise(SIGTRAP) #else - #define LT_DEBUG_TRAP() raise(SIGABRT) + #define lt_debug_trap() raise(SIGABRT) #endif #endif #endif - #if !defined(LT_DEBUG_TRAP) + #if !defined(lt_debug_trap) #if !defined(LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP) #error "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP in Config.h to disable this error" #elif defined(LIGHT_DIST) #ifdef _MSC_VER - #define LT_DEBUG_TRAP() \ - LOG(critical, \ + #define lt_debug_trap() \ + lt_log(critical, \ "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ __FUNCSIG__, \ __FILE__, \ __LINE__) // or __FUNCSIG__ #else - #define LT_DEBUG_TRAP() \ - LOG(critical, "DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__) + #define lt_debug_trap() \ + lt_log(critical, "DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__) #endif #else /* !defined(LIGHT_DIST) */ #ifdef _MSC_VER - #define LT_DEBUG_TRAP() \ - LOG(critical, \ + #define lt_debug_trap() \ + lt_log(critical, \ "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ __FUNCSIG__, \ __FILE__, \ __LINE__) // or __FUNCSIG__ #else - #define LT_DEBUG_TRAP() \ - LOG(critical, "DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__) + #define lt_debug_trap() \ + lt_log(critical, "DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__) #endif #endif diff --git a/modules/engine/include/engine/camera/camera.hpp b/modules/engine/include/engine/camera/camera.hpp index 1554d1d..21da5a1 100644 --- a/modules/engine/include/engine/camera/camera.hpp +++ b/modules/engine/include/engine/camera/camera.hpp @@ -26,7 +26,7 @@ public: return m_background_color; } - inline void SetBackgroundColor(const glm::vec4 &color) + inline void set_background_color(const glm::vec4 &color) { m_background_color = color; } diff --git a/modules/engine/include/engine/camera/ortho.hpp b/modules/engine/include/engine/camera/ortho.hpp index 75a5ec1..e61c7c5 100644 --- a/modules/engine/include/engine/camera/ortho.hpp +++ b/modules/engine/include/engine/camera/ortho.hpp @@ -28,10 +28,10 @@ public: ); // CAMERA // - void CalculateView(); - void CalculateProjection(); + void calculate_view(); + void calculate_projection(); - void OnResize(const glm::vec2 &size); + void on_resize(const glm::vec2 &size); inline const glm::mat4 &GetView() const { @@ -48,7 +48,7 @@ public: } // CAMERA_CONTROLLER // - void Move(const glm::vec2 &position); + void move(const glm::vec2 &position); }; } // namespace Light diff --git a/modules/engine/include/engine/camera/scene.hpp b/modules/engine/include/engine/camera/scene.hpp index 5376326..59132f1 100644 --- a/modules/engine/include/engine/camera/scene.hpp +++ b/modules/engine/include/engine/camera/scene.hpp @@ -36,51 +36,51 @@ private: public: SceneCamera(); - void SetViewportSize(unsigned int width, unsigned int height); + void set_viewport_size(unsigned int width, unsigned int height); - void SetProjectionType(ProjectionType projectionType); + void set_projection_type(ProjectionType projectionType); - void SetOrthographicSize(float size); - void SetOrthographicFarPlane(float farPlane); - void SetOrthographicNearPlane(float nearPlane); + void set_orthographic_size(float size); + void set_orthographic_far_plane(float farPlane); + void set_orthographic_near_plane(float nearPlane); - void SetPerspectiveVerticalFOV(float verticalFov); - void SetPerspectiveFarPlane(float farPlane); - void SetPerspectiveNearPlane(float nearPlane); + void set_perspective_vertical_fov(float verticalFov); + void set_perspective_far_plane(float farPlane); + void set_perspective_near_plane(float nearPlane); - inline float GetOrthographicSize() const + inline float get_orthographic_size() const { return m_orthographic_specification.size; } - inline float GetOrthographicFarPlane() const + inline float get_orthographic_far_plane() const { return m_orthographic_specification.farPlane; } - inline float GetOrthographicNearPlane() const + inline float get_orthographic_near_plane() const { return m_orthographic_specification.nearPlane; } - inline float GetPerspectiveVerticalFOV() const + inline float get_perspective_vertical_fov() const { return m_perspective_specification.verticalFOV; } - inline float GetPerspectiveFarPlane() const + inline float get_perspective_far_plane() const { return m_perspective_specification.farPlane; } - inline float GetPerspectiveNearPlane() const + inline float get_perspective_near_plane() const { return m_perspective_specification.nearPlane; } - inline ProjectionType GetProjectionType() const + inline ProjectionType get_projection_type() const { return m_projection_type; } private: - void CalculateProjection(); + void calculate_projection(); }; } // namespace Light diff --git a/modules/engine/include/engine/core/application.hpp b/modules/engine/include/engine/core/application.hpp index a2bf533..4dae09d 100644 --- a/modules/engine/include/engine/core/application.hpp +++ b/modules/engine/include/engine/core/application.hpp @@ -19,7 +19,7 @@ private: static Application *s_Context; private: - Scope m_logger; + Scope m_logger; Scope m_instrumentor; Scope m_layer_stack; Scope m_input; @@ -34,19 +34,19 @@ public: virtual ~Application(); - void GameLoop(); + void game_loop(); // To be defined in client project - static void Quit(); + static void quit(); protected: Application(); private: - void OnEvent(const Event &event); + void on_event(const Event &event); - void LogDebugData(); + void log_debug_data(); }; extern Application *CreateApplication(); diff --git a/modules/engine/include/engine/core/window.hpp b/modules/engine/include/engine/core/window.hpp index 9770c97..23d99bf 100644 --- a/modules/engine/include/engine/core/window.hpp +++ b/modules/engine/include/engine/core/window.hpp @@ -23,7 +23,7 @@ protected: bool b_Closed; public: - static Scope Create(std::function callback); + static Scope create(std::function callback); Window(): m_graphics_context(nullptr), m_properties {}, b_Closed(false) { @@ -35,27 +35,27 @@ public: virtual ~Window() = default; /* events */ - virtual void PollEvents() = 0; - virtual void OnEvent(const Event &event) = 0; + virtual void poll_events() = 0; + virtual void on_event(const Event &event) = 0; //======================================== SETTERS ========================================// - virtual void SetProperties( + virtual void set_properties( const WindowProperties &properties, bool affectVisibility = false ) = 0; - virtual void SetTitle(const std::string &title) = 0; + virtual void set_title(const std::string &title) = 0; - virtual void SetSize(const glm::uvec2 &size, bool additive = false) = 0; // pass 0 for width or + virtual void set_size(const glm::uvec2 &size, bool additive = false) = 0; // pass 0 for width or // height for single // dimension resizing - inline void Close() + inline void close() { b_Closed = true; } - virtual void SetVSync(bool vsync, bool toggle = false) = 0; - virtual void SetVisibility(bool visible, bool toggle = false) = 0; + virtual void set_v_sync(bool vsync, bool toggle = false) = 0; + virtual void set_visibility(bool visible, bool toggle = false) = 0; //======================================== SETTERS ========================================// //============================== GETTERS ==============================// @@ -74,20 +74,20 @@ public: return m_properties.title; } - inline const glm::uvec2 &GetSize() const + inline const glm::uvec2 &get_size() const { return m_properties.size; } - inline bool IsClosed() const + inline bool is_closed() const { return b_Closed; } - inline bool IsVSync() const + inline bool is_v_sync() const { return m_properties.vsync; } - inline bool IsVisible() const + inline bool is_visible() const { return m_properties.visible; } diff --git a/modules/engine/include/engine/debug/exceptions.hpp b/modules/engine/include/engine/debug/exceptions.hpp index db3f1c1..a202b02 100644 --- a/modules/engine/include/engine/debug/exceptions.hpp +++ b/modules/engine/include/engine/debug/exceptions.hpp @@ -1,10 +1,10 @@ #pragma once -#define DXC(x) DXC_NO_REDIFINITION(x, __LINE__) +#define dxc(x) dxc_no_redifinition(x, __LINE__) -#define DXC_NO_REDIFINITION(x, line) DXC_NO_REDIFINITION2(x, line) +#define dxc_no_redifinition(x, line) dxc_no_redifinition2(x, line) -#define DXC_NO_REDIFINITION2(x, line) \ +#define dxc_no_redifinition2(x, line) \ HRESULT hr##line; \ if (FAILED(hr##line = x)) \ throw dxException(hr##line, __FILE__, line) diff --git a/modules/engine/include/engine/debug/instrumentor.hpp b/modules/engine/include/engine/debug/instrumentor.hpp index 38b6eff..33f625d 100644 --- a/modules/engine/include/engine/debug/instrumentor.hpp +++ b/modules/engine/include/engine/debug/instrumentor.hpp @@ -26,29 +26,29 @@ private: unsigned int m_current_session_count; public: - static Scope Create(); + static Scope create(); - static inline void BeginSession(const std::string &outputPath) + static inline void begin_session(const std::string &outputPath) { - s_Context->BeginSessionImpl(outputPath); + s_Context->begin_session_impl(outputPath); } - static inline void EndSession() + static inline void end_session() { - s_Context->EndSessionImpl(); + s_Context->end_session_impl(); } - static inline void SubmitScopeProfile(const ScopeProfileResult &profileResult) + static inline void submit_scope_profile(const ScopeProfileResult &profileResult) { - s_Context->SubmitScopeProfileImpl(profileResult); + s_Context->submit_scope_profile_impl(profileResult); } private: Instrumentor(); - void BeginSessionImpl(const std::string &outputPath); - void EndSessionImpl(); + void begin_session_impl(const std::string &outputPath); + void end_session_impl(); - void SubmitScopeProfileImpl(const ScopeProfileResult &profileResult); + void submit_scope_profile_impl(const ScopeProfileResult &profileResult); }; class InstrumentorTimer @@ -65,13 +65,13 @@ public: } // namespace Light /* scope */ -#define LT_PROFILE_SCOPE(name) LT_PROFILE_SCOPE_NO_REDIFINITION(name, __LINE__) -#define LT_PROFILE_SCOPE_NO_REDIFINITION(name, line) LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) -#define LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) InstrumentorTimer timer##line(name) +#define lt_profile_scope(name) lt_profile_scope_no_redifinition(name, __LINE__) +#define lt_profile_scope_no_redifinition(name, line) lt_profile_scope_no_redifinition2(name, line) +#define lt_profile_scope_no_redifinition2(name, line) InstrumentorTimer timer##line(name) /* function */ -#define LT_PROFILE_FUNCTION LT_PROFILE_SCOPE(__FUNCSIG__) +#define LT_PROFILE_FUNCTION lt_profile_scope(__FUNCSIG__) /* session */ -#define LT_PROFILE_BEGIN_SESSION(outputPath) ::Light::Instrumentor::BeginSession(outputPath) -#define LT_PROFILE_END_SESSION() ::Light::Instrumentor::EndSession() +#define lt_profile_begin_session(outputPath) ::Light::Instrumentor::begin_session(outputPath) +#define lt_profile_end_session() ::Light::Instrumentor::end_session() diff --git a/modules/engine/include/engine/debug/logger.hpp b/modules/engine/include/engine/debug/logger.hpp index 06868eb..23d5c19 100644 --- a/modules/engine/include/engine/debug/logger.hpp +++ b/modules/engine/include/engine/debug/logger.hpp @@ -5,19 +5,19 @@ #include #include - #define LT_LOG_FILE_LOCATION "Logs/Logger.txt" + #define LT_LOG_FILE_LOCATION "Logs/logger.txt" #ifndef LIGHT_DIST - #define LOG(logLevel, ...) \ + #define lt_log(logLevel, ...) \ SPDLOG_LOGGER_CALL( \ - ::Light::Logger::GetEngineLogger(), \ + ::Light::logger::get_engine_logger(), \ spdlog::level::logLevel, \ __VA_ARGS__ \ ) #else - #define LOG(logLevel, ...) \ + #define lt_log(logLevel, ...) \ SPDLOG_LOGGER_CALL( \ - ::Light::Logger::GetFileLogger(), \ + ::Light::logger::get_file_logger(), \ spdlog::level::logLevel, \ __VA_ARGS__ \ ) @@ -26,31 +26,31 @@ namespace Light { // #todo: extend -class Logger /* singleton */ +class logger /* singleton */ { private: - static Logger *s_Context; + static logger *s_Context; private: Ref m_engine_logger, m_file_logger; std::string m_log_file_path; public: - static Scope Create(); + static Scope create(); - static inline Ref GetEngineLogger() + static inline Ref get_engine_logger() { return s_Context->m_engine_logger; } - static inline Ref GetFileLogger() + static inline Ref get_file_logger() { return s_Context->m_file_logger; } - void LogDebugData(); + void log_debug_data(); private: - Logger(); + logger(); }; } // namespace Light diff --git a/modules/engine/include/engine/events/char.hpp b/modules/engine/include/engine/events/char.hpp index 9e0101d..7017e02 100644 --- a/modules/engine/include/engine/events/char.hpp +++ b/modules/engine/include/engine/events/char.hpp @@ -16,19 +16,19 @@ public: { } - inline int GetCharacter() const + inline int get_character() const { return m_character; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "CharSet: " << m_character; return ss.str(); } - EVENT_TYPE(SetChar) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) + event_type(SetChar) + event_category(InputEventCategory | KeyboardEventCategory) }; } // namespace Light diff --git a/modules/engine/include/engine/events/event.hpp b/modules/engine/include/engine/events/event.hpp index 606eede..35e970b 100644 --- a/modules/engine/include/engine/events/event.hpp +++ b/modules/engine/include/engine/events/event.hpp @@ -30,19 +30,19 @@ enum EventCategory { None = 0, - WindowEventCategory = BIT(0), - InputEventCategory = BIT(1), - KeyboardEventCategory = BIT(2), - MouseEventCategory = BIT(3), + WindowEventCategory = bit(0), + InputEventCategory = bit(1), + KeyboardEventCategory = bit(2), + MouseEventCategory = bit(3), }; -#define EVENT_TYPE(type) \ - EventType GetEventType() const override \ +#define event_type(type) \ + EventType get_event_type() const override \ { \ return ::Light::EventType::type; \ } -#define EVENT_CATEGORY(eCategory) \ - inline bool HasCategory(EventCategory category) const override \ +#define event_category(eCategory) \ + inline bool has_category(EventCategory category) const override \ { \ return (eCategory) & category; \ } @@ -50,13 +50,13 @@ enum EventCategory class Event { public: - virtual EventType GetEventType() const = 0; - virtual std::string GetInfoLog() const = 0; - virtual bool HasCategory(EventCategory category) const = 0; + virtual EventType get_event_type() const = 0; + virtual std::string get_info_lt_log() const = 0; + virtual bool has_category(EventCategory category) const = 0; friend std::ostream &operator<<(std::ostream &os, const Event &e) { - return os << e.GetInfoLog(); + return os << e.get_info_lt_log(); } }; diff --git a/modules/engine/include/engine/events/keyboard.hpp b/modules/engine/include/engine/events/keyboard.hpp index ecde4d4..6e988a8 100644 --- a/modules/engine/include/engine/events/keyboard.hpp +++ b/modules/engine/include/engine/events/keyboard.hpp @@ -16,19 +16,19 @@ public: { } - inline int GetKey() const + inline int get_key() const { return m_key; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "KeyPressed: " << m_key; return ss.str(); } - EVENT_TYPE(KeyPressed) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) + event_type(KeyPressed) + event_category(InputEventCategory | KeyboardEventCategory) }; class KeyRepeatEvent: public Event @@ -41,19 +41,19 @@ public: { } - inline int GetKey() const + inline int get_key() const { return m_key; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "KeyRepeated: " << m_key; return ss.str(); } - EVENT_TYPE(KeyRepeated) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) + event_type(KeyRepeated) + event_category(InputEventCategory | KeyboardEventCategory) }; class KeyReleasedEvent: public Event @@ -66,19 +66,19 @@ public: { } - inline int GetKey() const + inline int get_key() const { return m_key; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "KeyReleased: " << m_key; return ss.str(); } - EVENT_TYPE(KeyReleased) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) + event_type(KeyReleased) + event_category(InputEventCategory | KeyboardEventCategory) }; } // namespace Light diff --git a/modules/engine/include/engine/events/mouse.hpp b/modules/engine/include/engine/events/mouse.hpp index a070cd4..fd28ea4 100644 --- a/modules/engine/include/engine/events/mouse.hpp +++ b/modules/engine/include/engine/events/mouse.hpp @@ -22,23 +22,23 @@ public: return m_position; } - inline float GetX() const + inline float get_x() const { return m_position.x; } - inline float GetY() const + inline float get_y() const { return m_position.y; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "MouseMoved: " << m_position.x << ", " << m_position.y; return ss.str(); } - EVENT_TYPE(MouseMoved) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) + event_type(MouseMoved) + event_category(InputEventCategory | MouseEventCategory) }; class WheelScrolledEvent: public Event @@ -51,19 +51,19 @@ public: { } - inline float GetOffset() const + inline float get_offset() const { return m_offset; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "WheelScrolled: " << m_offset; return ss.str(); } - EVENT_TYPE(WheelScrolled) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) + event_type(WheelScrolled) + event_category(InputEventCategory | MouseEventCategory) }; class ButtonPressedEvent: public Event @@ -76,19 +76,19 @@ public: { } - inline int GetButton() const + inline int get_button() const { return m_button; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "ButtonPressed: " << m_button; return ss.str(); } - EVENT_TYPE(ButtonPressed) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) + event_type(ButtonPressed) + event_category(InputEventCategory | MouseEventCategory) }; class ButtonReleasedEvent: public Event @@ -101,19 +101,19 @@ public: { } - inline int GetButton() const + inline int get_button() const { return m_button; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "ButtonReleased: " << m_button; return ss.str(); } - EVENT_TYPE(ButtonReleased) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) + event_type(ButtonReleased) + event_category(InputEventCategory | MouseEventCategory) }; } // namespace Light diff --git a/modules/engine/include/engine/events/window.hpp b/modules/engine/include/engine/events/window.hpp index ba61cb4..916044f 100644 --- a/modules/engine/include/engine/events/window.hpp +++ b/modules/engine/include/engine/events/window.hpp @@ -10,12 +10,12 @@ namespace Light { class WindowClosedEvent: public Event { public: - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { return "WindowClosedEvent"; } - EVENT_TYPE(WindowClosed) - EVENT_CATEGORY(WindowEventCategory) + event_type(WindowClosed) + event_category(WindowEventCategory) }; class WindowMovedEvent: public Event @@ -33,15 +33,15 @@ public: return m_position; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "WindwoMoved: " << m_position.x << ", " << m_position.y; return ss.str(); ; } - EVENT_TYPE(WindowMoved) - EVENT_CATEGORY(WindowEventCategory) + event_type(WindowMoved) + event_category(WindowEventCategory) }; class WindowResizedEvent: public Event @@ -54,41 +54,41 @@ public: { } - const glm::uvec2 &GetSize() const + const glm::uvec2 &get_size() const { return m_size; } - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { std::stringstream ss; ss << "WindowResized: " << m_size.x << ", " << m_size.y; return ss.str(); } - EVENT_TYPE(WindowResized) - EVENT_CATEGORY(WindowEventCategory) + event_type(WindowResized) + event_category(WindowEventCategory) }; class WindowLostFocusEvent: public Event { public: - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { return "WindowLostFocus"; } - EVENT_TYPE(WindowLostFocus) - EVENT_CATEGORY(WindowEventCategory) + event_type(WindowLostFocus) + event_category(WindowEventCategory) }; class WindowGainFocusEvent: public Event { public: - virtual std::string GetInfoLog() const override + virtual std::string get_info_lt_log() const override { return "WindowGainFocus"; } - EVENT_TYPE(WindowGainFocus) - EVENT_CATEGORY(WindowEventCategory) + event_type(WindowGainFocus) + event_category(WindowEventCategory) }; } // namespace Light diff --git a/modules/engine/include/engine/graphics/blender.hpp b/modules/engine/include/engine/graphics/blender.hpp index f9a9479..10e81a4 100644 --- a/modules/engine/include/engine/graphics/blender.hpp +++ b/modules/engine/include/engine/graphics/blender.hpp @@ -37,10 +37,10 @@ enum class BlendFactor : uint8_t class Blender { public: - static Scope Create(Ref sharedContext); + static Scope create(Ref sharedContext); - virtual void Enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; - virtual void Disable() = 0; + virtual void enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; + virtual void disable() = 0; protected: Blender() = default; diff --git a/modules/engine/include/engine/graphics/buffers.hpp b/modules/engine/include/engine/graphics/buffers.hpp index 16a77b9..d93dae2 100644 --- a/modules/engine/include/engine/graphics/buffers.hpp +++ b/modules/engine/include/engine/graphics/buffers.hpp @@ -15,12 +15,12 @@ enum class ConstantBufferIndex class ConstantBuffer { public: - static Scope Create(ConstantBufferIndex index, unsigned int size, Ref sharedContext); + static Scope create(ConstantBufferIndex index, unsigned int size, Ref sharedContext); - virtual void* Map() = 0; - virtual void UnMap() = 0; + virtual void* map() = 0; + virtual void un_map() = 0; - virtual void Bind() = 0; + virtual void bind() = 0; protected: ConstantBuffer() = default; @@ -30,15 +30,15 @@ protected: class VertexBuffer { public: - static Ref Create(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); + static Ref create(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); virtual ~VertexBuffer() = default; - virtual void* Map() = 0; - virtual void UnMap() = 0; + virtual void* map() = 0; + virtual void un_map() = 0; - virtual void Bind() = 0; - virtual void UnBind() = 0; + virtual void bind() = 0; + virtual void un_bind() = 0; protected: VertexBuffer() = default; @@ -48,12 +48,12 @@ protected: class IndexBuffer { public: - static Ref Create(unsigned int* indices, unsigned int count, Ref sharedContext); + static Ref create(unsigned int* indices, unsigned int count, Ref sharedContext); virtual ~IndexBuffer() = default; - virtual void Bind() = 0; - virtual void UnBind() = 0; + virtual void bind() = 0; + virtual void un_bind() = 0; protected: IndexBuffer() = default; diff --git a/modules/engine/include/engine/graphics/framebuffer.hpp b/modules/engine/include/engine/graphics/framebuffer.hpp index 16111e7..696852b 100644 --- a/modules/engine/include/engine/graphics/framebuffer.hpp +++ b/modules/engine/include/engine/graphics/framebuffer.hpp @@ -17,12 +17,12 @@ struct FramebufferSpecification class Framebuffer { public: - static Ref Create(const FramebufferSpecification& specification, Ref sharedContext); + static Ref create(const FramebufferSpecification& specification, Ref sharedContext); - virtual void BindAsTarget(const glm::vec4& clearColor) = 0; - virtual void BindAsResource() = 0; + virtual void bind_as_target(const glm::vec4& clearColor) = 0; + virtual void bind_as_resource() = 0; - virtual void Resize(const glm::uvec2& size) = 0; + virtual void resize(const glm::uvec2& size) = 0; virtual void* GetColorAttachment() = 0; diff --git a/modules/engine/include/engine/graphics/graphics_context.hpp b/modules/engine/include/engine/graphics/graphics_context.hpp index 0be3b20..1997e19 100644 --- a/modules/engine/include/engine/graphics/graphics_context.hpp +++ b/modules/engine/include/engine/graphics/graphics_context.hpp @@ -6,8 +6,8 @@ struct GLFWwindow; namespace Light { -class Renderer; -class ResourceManager; +class renderer; +class resource_manager; class SharedContext; class UserInterface; @@ -30,26 +30,26 @@ private: private: Scope m_user_interface; - Scope m_renderer; + Scope m_renderer; protected: GraphicsAPI m_graphics_api; Ref m_shared_context = nullptr; public: - static Scope Create(GraphicsAPI api, GLFWwindow* windowHandle); + static Scope create(GraphicsAPI api, GLFWwindow* windowHandle); GraphicsContext(const GraphicsContext&) = delete; GraphicsContext& operator=(const GraphicsContext&) = delete; virtual ~GraphicsContext(); - virtual void LogDebugData() = 0; + virtual void log_debug_data() = 0; - static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_graphics_api; } - static inline Ref GetSharedContext() { return s_Context->m_shared_context; } + static inline GraphicsAPI get_graphics_api() { return s_Context->m_graphics_api; } + static inline Ref get_shared_context() { return s_Context->m_shared_context; } - inline Renderer* GetRenderer() { return m_renderer.get(); } + inline renderer* GetRenderer() { return m_renderer.get(); } inline UserInterface* GetUserInterface() { return m_user_interface.get(); } protected: diff --git a/modules/engine/include/engine/graphics/render_command.hpp b/modules/engine/include/engine/graphics/render_command.hpp index 8e7211b..74c66fb 100644 --- a/modules/engine/include/engine/graphics/render_command.hpp +++ b/modules/engine/include/engine/graphics/render_command.hpp @@ -12,22 +12,22 @@ class SharedContext; class RenderCommand { public: - static Scope Create(GLFWwindow *windowHandle, Ref sharedContext); + static Scope create(GLFWwindow *windowHandle, Ref sharedContext); RenderCommand(const RenderCommand &) = delete; RenderCommand &operator=(const RenderCommand &) = delete; virtual ~RenderCommand() = default; - virtual void SwapBuffers() = 0; - virtual void ClearBackBuffer(const glm::vec4 &clearColor) = 0; + virtual void swap_buffers() = 0; + virtual void clear_back_buffer(const glm::vec4 &clearColor) = 0; - virtual void Draw(unsigned int count) = 0; - virtual void DrawIndexed(unsigned int count) = 0; + virtual void draw(unsigned int count) = 0; + virtual void draw_indexed(unsigned int count) = 0; - virtual void DefaultTargetFramebuffer() = 0; + virtual void default_target_framebuffer() = 0; - virtual void SetViewport( + virtual void set_viewport( unsigned int x, unsigned int y, unsigned int width, diff --git a/modules/engine/include/engine/graphics/renderer.hpp b/modules/engine/include/engine/graphics/renderer.hpp index e704c0d..569a4bb 100644 --- a/modules/engine/include/engine/graphics/renderer.hpp +++ b/modules/engine/include/engine/graphics/renderer.hpp @@ -25,10 +25,10 @@ class Camera; class WindowResizedEvent; -class Renderer +class renderer { private: - static Renderer *s_Context; + static renderer *s_Context; // renderer programs QuadRendererProgram m_quad_renderer; @@ -47,88 +47,88 @@ private: bool m_should_clear_backbuffer; public: - static Scope Create(GLFWwindow *windowHandle, Ref sharedContext); + static Scope create(GLFWwindow *windowHandle, Ref sharedContext); - static inline void DrawQuad( + static inline void draw_quad( const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint, Ref texture ) { - s_Context->DrawQuadImpl(position, size, tint, texture); + s_Context->draw_quad_impl(position, size, tint, texture); } - static inline void DrawQuad( + static inline void draw_quad( const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint ) { - s_Context->DrawQuadImpl(position, size, tint); + s_Context->draw_quad_impl(position, size, tint); } - static inline void DrawQuad( + static inline void draw_quad( const glm::vec3 &position, const glm::vec2 &size, Ref texture ) { - s_Context->DrawQuadImpl(position, size, texture); + s_Context->draw_quad_impl(position, size, texture); } - static void DrawQuad(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture) + static void draw_quad(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture) { - s_Context->DrawQuadImpl(transform, tint, texture); + s_Context->draw_quad_impl(transform, tint, texture); } - static void DrawQuad(const glm::mat4 &transform, const glm::vec4 &tint) + static void draw_quad(const glm::mat4 &transform, const glm::vec4 &tint) { - s_Context->DrawQuadImpl(transform, tint); + s_Context->draw_quad_impl(transform, tint); } - static void DrawQuad(const glm::mat4 &transform, Ref texture) + static void draw_quad(const glm::mat4 &transform, Ref texture) { - s_Context->DrawQuadImpl(transform, texture); + s_Context->draw_quad_impl(transform, texture); } - static inline void BeginScene( + static inline void begin_scene( Camera *camera, const glm::mat4 &cameraTransform, const Ref &targetFrameBuffer = nullptr ) { - s_Context->BeginSceneImpl(camera, cameraTransform, targetFrameBuffer); + s_Context->begin_scene_impl(camera, cameraTransform, targetFrameBuffer); } - static inline void EndScene() + static inline void end_scene() { - s_Context->EndSceneImpl(); + s_Context->end_scene_impl(); } - void OnWindowResize(const WindowResizedEvent &event); + void on_window_resize(const WindowResizedEvent &event); - void BeginFrame(); - void EndFrame(); + void begin_frame(); + void end_frame(); private: - Renderer(GLFWwindow *windowHandle, Ref sharedContext); + renderer(GLFWwindow *windowHandle, Ref sharedContext); - void DrawQuadImpl( + void draw_quad_impl( const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint, Ref texture ); - void DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint); - void DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, Ref texture); + void draw_quad_impl(const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint); + void draw_quad_impl(const glm::vec3 &position, const glm::vec2 &size, Ref texture); - void DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture); - void DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint); - void DrawQuadImpl(const glm::mat4 &transform, Ref texture); + void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture); + void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint); + void draw_quad_impl(const glm::mat4 &transform, Ref texture); - void BeginSceneImpl( + void begin_scene_impl( Camera *camera, const glm::mat4 &cameraTransform, const Ref &targetFrameBuffer = nullptr ); - void FlushScene(); - void EndSceneImpl(); + void flush_scene(); + void end_scene_impl(); }; } // namespace Light diff --git a/modules/engine/include/engine/graphics/renderer_programs/quad.hpp b/modules/engine/include/engine/graphics/renderer_programs/quad.hpp index 2ef301c..dd39332 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/quad.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/quad.hpp @@ -39,22 +39,22 @@ private: public: QuadRendererProgram(unsigned int maxVertices, Ref sharedContext); - bool Advance(); + bool advance(); - void Map() override; - void UnMap() override; + void map() override; + void un_map() override; - void Bind() override; + void bind() override; inline QuadVertexData *GetMapCurrent() { return m_map_current; } - inline unsigned int GetQuadCount() const + inline unsigned int get_quad_count() const { return m_quad_count; } - inline constexpr unsigned int GetVertexSize() const + inline constexpr unsigned int get_vertex_size() const { return sizeof(QuadVertexData); } diff --git a/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp b/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp index f32d663..719ac26 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/renderer_program.hpp @@ -8,10 +8,10 @@ class OrthographicCamera; class RendererProgram { - virtual void Map() = 0; - virtual void UnMap() = 0; + virtual void map() = 0; + virtual void un_map() = 0; - virtual void Bind() = 0; + virtual void bind() = 0; }; } // namespace Light diff --git a/modules/engine/include/engine/graphics/renderer_programs/texture.hpp b/modules/engine/include/engine/graphics/renderer_programs/texture.hpp index 4f00abc..3790dd5 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/texture.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/texture.hpp @@ -39,24 +39,24 @@ private: public: TextureRendererProgram(unsigned int maxVertices, Ref sharedContext); - bool Advance(); + bool advance(); - void Map() override; - void UnMap() override; + void map() override; + void un_map() override; - void Bind() override; + void bind() override; inline TextureVertexData *GetMapCurrent() { return m_map_current; } - inline unsigned int GetQuadCount() const + inline unsigned int get_quad_count() const { return m_quad_count; } - inline constexpr unsigned int GetVertexSize() const + inline constexpr unsigned int get_vertex_size() const { return sizeof(TextureVertexData); } diff --git a/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp b/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp index db3f495..1c861cb 100644 --- a/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp +++ b/modules/engine/include/engine/graphics/renderer_programs/tinted_texture.hpp @@ -40,24 +40,24 @@ private: public: TintedTextureRendererProgram(unsigned int maxVertices, Ref sharedContext); - bool Advance(); + bool advance(); - void Map() override; - void UnMap() override; + void map() override; + void un_map() override; - void Bind() override; + void bind() override; inline TintedTextureVertexData *GetMapCurrent() { return m_map_current; } - inline unsigned int GetQuadCount() const + inline unsigned int get_quad_count() const { return m_quad_count; } - inline constexpr unsigned int GetVertexSize() const + inline constexpr unsigned int get_vertex_size() const { return sizeof(TintedTextureVertexData); } diff --git a/modules/engine/include/engine/graphics/shader.hpp b/modules/engine/include/engine/graphics/shader.hpp index d1ddc03..89613ba 100644 --- a/modules/engine/include/engine/graphics/shader.hpp +++ b/modules/engine/include/engine/graphics/shader.hpp @@ -20,16 +20,16 @@ public: }; public: - static Ref Create( - BasicFileHandle vertexFile, - BasicFileHandle pixelFile, + static Ref create( + basic_file_handle vertexFile, + basic_file_handle pixelFile, Ref sharedContext ); virtual ~Shader() = default; - virtual void Bind() = 0; - virtual void UnBind() = 0; + virtual void bind() = 0; + virtual void un_bind() = 0; protected: Shader() = default; diff --git a/modules/engine/include/engine/graphics/texture.hpp b/modules/engine/include/engine/graphics/texture.hpp index 198ae8c..be3b7ea 100644 --- a/modules/engine/include/engine/graphics/texture.hpp +++ b/modules/engine/include/engine/graphics/texture.hpp @@ -10,16 +10,16 @@ class SharedContext; class Texture { public: - static Ref Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext, const std::string& filePath); + static Ref create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext, const std::string& filePath); Texture(const Texture&) = delete; Texture& operator=(const Texture&) = delete; virtual ~Texture() = default; - virtual void Bind(unsigned int slot = 0) = 0; + virtual void bind(unsigned int slot = 0) = 0; - virtual void* GetTexture() = 0; + virtual void* get_texture() = 0; inline const std::string& GetFilePath() const { return m_file_path; } diff --git a/modules/engine/include/engine/graphics/vertex_layout.hpp b/modules/engine/include/engine/graphics/vertex_layout.hpp index cd15773..dcf8c2a 100644 --- a/modules/engine/include/engine/graphics/vertex_layout.hpp +++ b/modules/engine/include/engine/graphics/vertex_layout.hpp @@ -34,7 +34,7 @@ enum class VertexElementType class VertexLayout { public: - static Ref Create( + static Ref create( Ref vertexBuffer, Ref shader, const std::vector> &elements, @@ -44,8 +44,8 @@ public: virtual ~VertexLayout() = default; ; - virtual void Bind() = 0; - virtual void UnBind() = 0; + virtual void bind() = 0; + virtual void un_bind() = 0; protected: VertexLayout() = default; diff --git a/modules/engine/include/engine/input/input.hpp b/modules/engine/include/engine/input/input.hpp index 97fe1fd..a1ed6fb 100644 --- a/modules/engine/include/engine/input/input.hpp +++ b/modules/engine/include/engine/input/input.hpp @@ -25,22 +25,22 @@ private: bool m_game_events; public: - static Scope Create(); + static Scope create(); - static inline void ReceiveUserInterfaceEvents(bool receive, bool toggle = false) + static inline void receive_user_interface_events(bool receive, bool toggle = false) { - s_Context->ReceiveUserInterfaceEventsImpl(receive, toggle); + s_Context->receive_user_interface_events_impl(receive, toggle); } - static inline void ReceiveGameEvents(bool receive, bool toggle = false) + static inline void receive_game_events(bool receive, bool toggle = false) { - s_Context->ReceieveGameEventsImpl(receive, toggle); + s_Context->receieve_game_events_impl(receive, toggle); } - static inline bool GetKeyboardKey(int code) + static inline bool get_keyboard_key(int code) { return s_Context->m_keyboad_keys[code]; } - static inline bool GetMouseButton(int code) + static inline bool get_mouse_button(int code) { return s_Context->m_mouse_buttons[code]; } @@ -50,13 +50,13 @@ public: return s_Context->m_mouse_position; } - void OnEvent(const Event &inputEvent); + void on_event(const Event &inputEvent); - inline bool IsReceivingInputEvents() const + inline bool is_receiving_input_events() const { return m_user_interface_events; } - inline bool IsReceivingGameEvents() const + inline bool is_receiving_game_events() const { return m_game_events; } @@ -64,10 +64,10 @@ public: private: Input(); - void ReceiveUserInterfaceEventsImpl(bool receive, bool toggle = false); - void ReceieveGameEventsImpl(bool receive, bool toggle = false); + void receive_user_interface_events_impl(bool receive, bool toggle = false); + void receieve_game_events_impl(bool receive, bool toggle = false); - void RestartInputState(); + void restart_input_state(); }; } // namespace Light diff --git a/modules/engine/include/engine/input/key_codes.hpp b/modules/engine/include/engine/input/key_codes.hpp index f2fe2ae..887ed2a 100644 --- a/modules/engine/include/engine/input/key_codes.hpp +++ b/modules/engine/include/engine/input/key_codes.hpp @@ -41,7 +41,7 @@ enum : uint16_t Q = 81, R = 82, S = 83, - T = 84, + t = 84, U = 85, V = 86, W = 87, @@ -75,7 +75,7 @@ enum : uint16_t /* home/end */ Home = 268, - End = 269, + end = 269, /* toggles */ CapsLock = 280, diff --git a/modules/engine/include/engine/layer/layer.hpp b/modules/engine/include/engine/layer/layer.hpp index 51607d2..42a1b47 100644 --- a/modules/engine/include/engine/layer/layer.hpp +++ b/modules/engine/include/engine/layer/layer.hpp @@ -42,82 +42,82 @@ public: } /* update */ - virtual void OnUpdate(float deltaTime) + virtual void on_update(float deltaTime) { } - virtual void OnUserInterfaceUpdate() + virtual void on_user_interface_update() { } - virtual void OnRender() + virtual void on_render() { } - bool OnEvent(const Event &event); + bool on_event(const Event &event); protected: /* mouse */ // cursor - virtual bool OnMouseMoved(const MouseMovedEvent &event) + virtual bool on_mouse_moved(const MouseMovedEvent &event) { return false; } // button - virtual bool OnButtonPressed(const ButtonPressedEvent &event) + virtual bool on_button_pressed(const ButtonPressedEvent &event) { return false; } - virtual bool OnButtonReleased(const ButtonReleasedEvent &event) + virtual bool on_button_released(const ButtonReleasedEvent &event) { return false; } // wheel - virtual bool OnWheelScrolled(const WheelScrolledEvent &event) + virtual bool on_wheel_scrolled(const WheelScrolledEvent &event) { return false; } /* keyboard */ // key - virtual bool OnKeyPressed(const KeyPressedEvent &event) + virtual bool on_key_pressed(const KeyPressedEvent &event) { return false; } - virtual bool OnKeyRepeat(const KeyRepeatEvent &event) + virtual bool on_key_repeat(const KeyRepeatEvent &event) { return false; } - virtual bool OnKeyReleased(const KeyReleasedEvent &event) + virtual bool on_key_released(const KeyReleasedEvent &event) { return false; } // char - virtual bool OnSetChar(const SetCharEvent &event) + virtual bool on_set_char(const SetCharEvent &event) { return false; } /* window */ // termination - virtual bool OnWindowClosed(const WindowClosedEvent &event) + virtual bool on_window_closed(const WindowClosedEvent &event) { return false; } // size/position - virtual bool OnWindowResized(const WindowResizedEvent &event) + virtual bool on_window_resized(const WindowResizedEvent &event) { return false; } - virtual bool OnWindowMoved(const WindowMovedEvent &event) + virtual bool on_window_moved(const WindowMovedEvent &event) { return false; } // focus - virtual bool OnWindowLostFocus(const WindowLostFocusEvent &event) + virtual bool on_window_lost_focus(const WindowLostFocusEvent &event) { return false; } - virtual bool OnWindowGainFocus(const WindowGainFocusEvent &event) + virtual bool on_window_gain_focus(const WindowGainFocusEvent &event) { return false; } diff --git a/modules/engine/include/engine/layer/layer_stack.hpp b/modules/engine/include/engine/layer/layer_stack.hpp index aa1f170..b99f44c 100644 --- a/modules/engine/include/engine/layer/layer_stack.hpp +++ b/modules/engine/include/engine/layer/layer_stack.hpp @@ -20,27 +20,27 @@ private: std::vector::iterator m_end; public: - static Scope Create(); + static Scope create(); ~LayerStack(); // #todo: is this needed? - template - static inline void EmplaceLayer(Args &&...args) + template + static inline void emplace_layer(Args &&...args) { - s_Context->AttachLayerImpl(new T((args)...)); + s_Context->attach_layer_impl(new t((args)...)); } - static inline void AttachLayer(Layer *layer) + static inline void attach_layer(Layer *layer) { - s_Context->AttachLayerImpl(layer); + s_Context->attach_layer_impl(layer); } - static inline void DetachLayer(Layer *layer) + static inline void detach_layer(Layer *layer) { - s_Context->DetachLayerImpl(layer); + s_Context->detach_layer_impl(layer); } - inline bool IsEmpty() + inline bool is_empty() { return m_layers.empty(); } @@ -65,8 +65,8 @@ public: private: LayerStack(); - void AttachLayerImpl(Layer *layer); - void DetachLayerImpl(Layer *layer); + void attach_layer_impl(Layer *layer); + void detach_layer_impl(Layer *layer); }; } // namespace Light diff --git a/modules/engine/include/engine/math/random.hpp b/modules/engine/include/engine/math/random.hpp index 52264b4..a17165b 100644 --- a/modules/engine/include/engine/math/random.hpp +++ b/modules/engine/include/engine/math/random.hpp @@ -9,8 +9,8 @@ namespace Light { namespace Math { - float Rand(int min, int max, int decimals = 0); - glm::vec2 RandVec2(int min, int max, int decimals = 0); - glm::vec3 RandVec3(int min, int max, int decimals = 0); + float rand(int min, int max, int decimals = 0); + glm::vec2 rand_vec2(int min, int max, int decimals = 0); + glm::vec3 rand_vec3(int min, int max, int decimals = 0); }} \ No newline at end of file diff --git a/modules/engine/include/engine/platform/graphics/directx/blender.hpp b/modules/engine/include/engine/platform/graphics/directx/blender.hpp index cc5ec0f..cdc5265 100644 --- a/modules/engine/include/engine/platform/graphics/directx/blender.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/blender.hpp @@ -23,8 +23,8 @@ private: public: dxBlender(Ref sharedContext); - void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; - void Disable() override; + void enable(BlendFactor srcFactor, BlendFactor dstFactor) override; + void disable() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/buffers.hpp b/modules/engine/include/engine/platform/graphics/directx/buffers.hpp index 5d64d6c..cd00d79 100644 --- a/modules/engine/include/engine/platform/graphics/directx/buffers.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/buffers.hpp @@ -27,10 +27,10 @@ public: Ref sharedContext ); - void Bind() override; + void bind() override; - void *Map() override; - void UnMap() override; + void *map() override; + void un_map() override; }; //========== VERTEX_BUFFER ==========// @@ -53,11 +53,11 @@ public: ); ~dxVertexBuffer(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; - void *Map() override; - void UnMap() override; + void *map() override; + void un_map() override; }; //========== INDEX_BUFFER ==========// @@ -72,8 +72,8 @@ public: dxIndexBuffer(unsigned int *indices, unsigned int count, Ref sharedContext); ~dxIndexBuffer(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/framebuffers.hpp b/modules/engine/include/engine/platform/graphics/directx/framebuffers.hpp index 0b22019..d9c1747 100644 --- a/modules/engine/include/engine/platform/graphics/directx/framebuffers.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/framebuffers.hpp @@ -33,10 +33,10 @@ public: return (void *)m_shader_resource_view.Get(); } - void BindAsTarget(const glm::vec4 &clearColor) override; - void BindAsResource() override; + void bind_as_target(const glm::vec4 &clearColor) override; + void bind_as_resource() override; - void Resize(const glm::uvec2 &size) override; + void resize(const glm::uvec2 &size) override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/graphics_context.hpp b/modules/engine/include/engine/platform/graphics/directx/graphics_context.hpp index 31f117c..f237d41 100644 --- a/modules/engine/include/engine/platform/graphics/directx/graphics_context.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/graphics_context.hpp @@ -19,12 +19,12 @@ private: public: dxGraphicsContext(GLFWwindow *windowHandle); - virtual void LogDebugData() override; + virtual void log_debug_data() override; private: - void SetupDeviceAndSwapChain(GLFWwindow *windowHandle); - void SetupRenderTargets(); - void SetupDebugInterface(); + void setup_device_and_swap_chain(GLFWwindow *windowHandle); + void setup_render_targets(); + void setup_debug_interface(); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/render_command.hpp b/modules/engine/include/engine/platform/graphics/directx/render_command.hpp index 1c7b9e9..87df731 100644 --- a/modules/engine/include/engine/platform/graphics/directx/render_command.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/render_command.hpp @@ -17,15 +17,15 @@ private: public: dxRenderCommand(Ref sharedContext); - virtual void SwapBuffers() override; - virtual void ClearBackBuffer(const glm::vec4 &clearColor) override; + virtual void swap_buffers() override; + virtual void clear_back_buffer(const glm::vec4 &clearColor) override; - virtual void Draw(unsigned int count) override; - virtual void DrawIndexed(unsigned int count) override; + virtual void draw(unsigned int count) override; + virtual void draw_indexed(unsigned int count) override; - virtual void DefaultTargetFramebuffer() override; + virtual void default_target_framebuffer() override; - virtual void SetViewport( + virtual void set_viewport( unsigned int x, unsigned int y, unsigned int width, @@ -33,7 +33,7 @@ public: ) override; private: - void SetResolution(unsigned int width, unsigned int height); + void set_resolution(unsigned int width, unsigned int height); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/shader.hpp b/modules/engine/include/engine/platform/graphics/directx/shader.hpp index 6c8ba99..aaba07c 100644 --- a/modules/engine/include/engine/platform/graphics/directx/shader.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/shader.hpp @@ -22,16 +22,16 @@ private: public: dxShader( - BasicFileHandle vertexFile, - BasicFileHandle pixelFile, + basic_file_handle vertexFile, + basic_file_handle pixelFile, Ref sharedContext ); ~dxShader(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; - inline Microsoft::WRL::ComPtr GetVertexBlob() + inline Microsoft::WRL::ComPtr get_vertex_blob() { return m_vertex_blob; } diff --git a/modules/engine/include/engine/platform/graphics/directx/shared_context.hpp b/modules/engine/include/engine/platform/graphics/directx/shared_context.hpp index 3f008c7..72cb851 100644 --- a/modules/engine/include/engine/platform/graphics/directx/shared_context.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/shared_context.hpp @@ -16,19 +16,19 @@ private: Microsoft::WRL::ComPtr m_render_target_view = nullptr; public: - inline Microsoft::WRL::ComPtr GetDevice() + inline Microsoft::WRL::ComPtr get_device() { return m_device; } - inline Microsoft::WRL::ComPtr GetDeviceContext() + inline Microsoft::WRL::ComPtr get_device_context() { return m_deviceContext; } - inline Microsoft::WRL::ComPtr GetSwapChain() + inline Microsoft::WRL::ComPtr get_swap_chain() { return m_swap_chain; } - inline Microsoft::WRL::ComPtr GetRenderTargetView() + inline Microsoft::WRL::ComPtr get_render_target_view() { return m_render_target_view; } diff --git a/modules/engine/include/engine/platform/graphics/directx/texture.hpp b/modules/engine/include/engine/platform/graphics/directx/texture.hpp index 30f00e4..b3f770c 100644 --- a/modules/engine/include/engine/platform/graphics/directx/texture.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/texture.hpp @@ -28,7 +28,7 @@ public: const std::string &filePath ); - void Bind(unsigned int slot = 0u) override; + void bind(unsigned int slot = 0u) override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/user_interface.hpp b/modules/engine/include/engine/platform/graphics/directx/user_interface.hpp index dbb3d62..dd4409c 100644 --- a/modules/engine/include/engine/platform/graphics/directx/user_interface.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/user_interface.hpp @@ -17,13 +17,13 @@ public: dxUserInterface() = default; ~dxUserInterface(); - void PlatformImplementation(GLFWwindow *windowHandle, Ref sharedContext) + void platform_implementation(GLFWwindow *windowHandle, Ref sharedContext) override; - void Begin() override; - void End() override; + void begin() override; + void end() override; - void LogDebugData() override; + void log_debug_data() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/directx/vertex_layout.hpp b/modules/engine/include/engine/platform/graphics/directx/vertex_layout.hpp index fc8ca2e..b8e126d 100644 --- a/modules/engine/include/engine/platform/graphics/directx/vertex_layout.hpp +++ b/modules/engine/include/engine/platform/graphics/directx/vertex_layout.hpp @@ -26,11 +26,11 @@ public: ); ~dxVertexLayout(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; private: - DXGI_FORMAT GetDxgiFormat(VertexElementType type); + DXGI_FORMAT get_dxgi_format(VertexElementType type); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/blender.hpp b/modules/engine/include/engine/platform/graphics/opengl/blender.hpp index d6ad8db..3cc8122 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/blender.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/blender.hpp @@ -13,8 +13,8 @@ private: public: glBlender(); - void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; - void Disable() override; + void enable(BlendFactor srcFactor, BlendFactor dstFactor) override; + void disable() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp b/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp index 7da50d1..a2a0a22 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/buffers.hpp @@ -16,10 +16,10 @@ public: glConstantBuffer(ConstantBufferIndex index, unsigned int size); ~glConstantBuffer(); - void Bind() override; + void bind() override; - void *Map() override; - void UnMap() override; + void *map() override; + void un_map() override; }; //========== VERTEX_BUFFER ==========// @@ -32,11 +32,11 @@ public: glVertexBuffer(float *vertices, unsigned int stride, unsigned int count); ~glVertexBuffer(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; - void *Map() override; - void UnMap() override; + void *map() override; + void un_map() override; }; //========== INDEX_BUFFER ==========// @@ -49,8 +49,8 @@ public: glIndexBuffer(unsigned int *indices, unsigned int count); ~glIndexBuffer(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp b/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp index a2db30d..51bff64 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/framebuffers.hpp @@ -17,10 +17,10 @@ public: glFramebuffer(const FramebufferSpecification &specification); ~glFramebuffer(); - void BindAsTarget(const glm::vec4 &clearColor) override; - void BindAsResource() override; + void bind_as_target(const glm::vec4 &clearColor) override; + void bind_as_resource() override; - void Resize(const glm::uvec2 &size) override; + void resize(const glm::uvec2 &size) override; inline void *GetColorAttachment() override { diff --git a/modules/engine/include/engine/platform/graphics/opengl/graphics_context.hpp b/modules/engine/include/engine/platform/graphics/opengl/graphics_context.hpp index e1208b0..412e92e 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/graphics_context.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/graphics_context.hpp @@ -15,10 +15,10 @@ private: public: glGraphicsContext(GLFWwindow *windowHandle); - void LogDebugData() override; + void log_debug_data() override; private: - void SetDebugMessageCallback(); + void set_debug_message_callback(); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/render_command.hpp b/modules/engine/include/engine/platform/graphics/opengl/render_command.hpp index 144fefb..e2c2bed 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/render_command.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/render_command.hpp @@ -15,15 +15,15 @@ private: public: glRenderCommand(GLFWwindow *windowHandle); - void SwapBuffers() override; - void ClearBackBuffer(const glm::vec4 &clearColor) override; + void swap_buffers() override; + void clear_back_buffer(const glm::vec4 &clearColor) override; - void Draw(unsigned int count) override; - void DrawIndexed(unsigned int count) override; + void draw(unsigned int count) override; + void draw_indexed(unsigned int count) override; - void DefaultTargetFramebuffer() override; + void default_target_framebuffer() override; - void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) + void set_viewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) override; }; diff --git a/modules/engine/include/engine/platform/graphics/opengl/shader.hpp b/modules/engine/include/engine/platform/graphics/opengl/shader.hpp index 848fc70..5757814 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/shader.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/shader.hpp @@ -12,16 +12,16 @@ private: unsigned int m_shader_id; public: - glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile); + glShader(basic_file_handle vertexFile, basic_file_handle pixelFile); ~glShader(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; private: - // shaderc::SpvCompilationResult CompileGLSL(BasicFileHandle file, Shader::Stage stage); + // shaderc::SpvCompilationResult compile_glsl(basic_file_handle file, Shader::Stage stage); - unsigned int CompileShader(std::string source, Shader::Stage stage); + unsigned int compile_shader(std::string source, Shader::Stage stage); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/texture.hpp b/modules/engine/include/engine/platform/graphics/opengl/texture.hpp index 4d6b574..58d0302 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/texture.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/texture.hpp @@ -14,9 +14,9 @@ public: glTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, const std::string& filePath); ~glTexture(); - void Bind(unsigned int slot = 0u) override; + void bind(unsigned int slot = 0u) override; - void* GetTexture() override; + void* get_texture() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp b/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp index 0083cbf..59640b8 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/user_interface.hpp @@ -16,13 +16,13 @@ public: glUserInterface() = default; ~glUserInterface(); - void PlatformImplementation(GLFWwindow *windowHandle, Ref sharedContext) + void platform_implementation(GLFWwindow *windowHandle, Ref sharedContext) override; - void Begin() override; - void End() override; + void begin() override; + void end() override; - void LogDebugData() override; + void log_debug_data() override; }; } // namespace Light diff --git a/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp b/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp index 3135463..deb3d6f 100644 --- a/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp +++ b/modules/engine/include/engine/platform/graphics/opengl/vertex_layout.hpp @@ -27,11 +27,11 @@ public: ); ~glVertexLayout(); - void Bind() override; - void UnBind() override; + void bind() override; + void un_bind() override; private: - glVertexElementDesc GetElementDesc(VertexElementType type, unsigned int offset); + glVertexElementDesc get_element_desc(VertexElementType type, unsigned int offset); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/os/linux/l_window.hpp b/modules/engine/include/engine/platform/os/linux/l_window.hpp index c39a28c..3bd9d05 100644 --- a/modules/engine/include/engine/platform/os/linux/l_window.hpp +++ b/modules/engine/include/engine/platform/os/linux/l_window.hpp @@ -22,25 +22,25 @@ public: ~lWindow(); /* events */ - void PollEvents() override; - void OnEvent(const Event &event) override; + void poll_events() override; + void on_event(const Event &event) override; //======================================== SETTERS ========================================// - void SetProperties(const WindowProperties &properties, bool overrideVisibility = false) + void set_properties(const WindowProperties &properties, bool overrideVisibility = false) override; - void SetTitle(const std::string &title) override; + void set_title(const std::string &title) override; - void SetSize(const glm::uvec2 &size, bool additive = false) override; + void set_size(const glm::uvec2 &size, bool additive = false) override; - void SetVSync(bool vsync, bool toggle = false) override; - void SetVisibility(bool visible, bool toggle = false) override; + void set_v_sync(bool vsync, bool toggle = false) override; + void set_visibility(bool visible, bool toggle = false) override; //======================================== SETTERS ========================================// private: - void OnWindowResize(const WindowResizedEvent &event); + void on_window_resize(const WindowResizedEvent &event); - void BindGlfwEvents(); + void bind_glfw_events(); }; } // namespace Light diff --git a/modules/engine/include/engine/platform/os/windows/w_window.cpp b/modules/engine/include/engine/platform/os/windows/w_window.cpp index cfe6204..1eae06f 100644 --- a/modules/engine/include/engine/platform/os/windows/w_window.cpp +++ b/modules/engine/include/engine/platform/os/windows/w_window.cpp @@ -16,9 +16,9 @@ extern "C" namespace Light { -Scope Window::Create(std::function callback) +Scope Window::create(std::function callback) { - return CreateScope(callback); + return create_scope(callback); } wWindow::wWindow(std::function callback) @@ -26,7 +26,7 @@ wWindow::wWindow(std::function callback) , m_event_callback(callback) { // init glfw - ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); + lt_assert(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); // create window glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); @@ -35,15 +35,15 @@ wWindow::wWindow(std::function callback) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); - ASSERT(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); + lt_assert(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); // bind event stuff glfwSetWindowUserPointer(m_handle, &m_event_callback); - BindGlfwEvents(); + bind_glfw_events(); // create graphics context - m_graphics_context = GraphicsContext::Create(GraphicsAPI::DirectX, m_handle); - ASSERT(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'"); + m_graphics_context = GraphicsContext::create(GraphicsAPI::DirectX, m_handle); + lt_assert(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'"); } wWindow::~wWindow() @@ -51,30 +51,30 @@ wWindow::~wWindow() glfwDestroyWindow(m_handle); } -void wWindow::PollEvents() +void wWindow::poll_events() { glfwPollEvents(); } -void wWindow::OnEvent(const Event &event) +void wWindow::on_event(const Event &event) { - switch (event.GetEventType()) + switch (event.get_event_type()) { /* closed */ case EventType::WindowClosed: b_Closed = true; break; /* resized */ - case EventType::WindowResized: OnWindowResize((const WindowResizedEvent &)event); break; + case EventType::WindowResized: on_window_resize((const WindowResizedEvent &)event); break; } } -void wWindow::OnWindowResize(const WindowResizedEvent &event) +void wWindow::on_window_resize(const WindowResizedEvent &event) { - m_properties.size = event.GetSize(); + m_properties.size = event.get_size(); } void wWindow:: - SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */) + set_properties(const WindowProperties &properties, bool overrideVisiblity /* = false */) { // save the visibility status and re-assign if 'overrideVisibility' is false bool visible = overrideVisiblity ? properties.visible : m_properties.visible; @@ -82,20 +82,20 @@ void wWindow:: m_properties.visible = visible; // set properties - SetTitle(properties.title); - SetSize(properties.size); - SetVSync(properties.vsync); - SetVisibility(visible); + set_title(properties.title); + set_size(properties.size); + set_v_sync(properties.vsync); + set_visibility(visible); } -void wWindow::SetTitle(const std::string &title) +void wWindow::set_title(const std::string &title) { m_properties.title = title; glfwSetWindowTitle(m_handle, m_properties.title.c_str()); } -void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) +void wWindow::set_size(const glm::uvec2 &size, bool additive /* = false */) { m_properties.size.x = size.x == 0u ? m_properties.size.x : additive ? m_properties.size.x + size.x : @@ -108,14 +108,14 @@ void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) glfwSetWindowSize(m_handle, size.x, size.y); } -void wWindow::SetVSync(bool vsync, bool toggle /* = false */) +void wWindow::set_v_sync(bool vsync, bool toggle /* = false */) { m_properties.vsync = toggle ? !m_properties.vsync : vsync; glfwSwapInterval(m_properties.vsync); } -void wWindow::SetVisibility(bool visible, bool toggle) +void wWindow::set_visibility(bool visible, bool toggle) { m_properties.visible = toggle ? !m_properties.visible : visible; @@ -125,7 +125,7 @@ void wWindow::SetVisibility(bool visible, bool toggle) glfwHideWindow(m_handle); } -void wWindow::BindGlfwEvents() +void wWindow::bind_glfw_events() { //============================== MOUSE_EVENTS ==============================// /* cursor position */ diff --git a/modules/engine/include/engine/platform/os/windows/w_window.hpp b/modules/engine/include/engine/platform/os/windows/w_window.hpp index a370c6b..0d1ff9a 100644 --- a/modules/engine/include/engine/platform/os/windows/w_window.hpp +++ b/modules/engine/include/engine/platform/os/windows/w_window.hpp @@ -22,25 +22,25 @@ public: ~wWindow(); /* events */ - void PollEvents() override; - void OnEvent(const Event &event) override; + void poll_events() override; + void on_event(const Event &event) override; //======================================== SETTERS ========================================// - void SetProperties(const WindowProperties &properties, bool overrideVisibility = false) + void set_properties(const WindowProperties &properties, bool overrideVisibility = false) override; - void SetTitle(const std::string &title) override; + void set_title(const std::string &title) override; - void SetSize(const glm::uvec2 &size, bool additive = false) override; + void set_size(const glm::uvec2 &size, bool additive = false) override; - void SetVSync(bool vsync, bool toggle = false) override; - void SetVisibility(bool visible, bool toggle = false) override; + void set_v_sync(bool vsync, bool toggle = false) override; + void set_visibility(bool visible, bool toggle = false) override; //======================================== SETTERS ========================================// private: - void OnWindowResize(const WindowResizedEvent &event); + void on_window_resize(const WindowResizedEvent &event); - void BindGlfwEvents(); + void bind_glfw_events(); }; } // namespace Light diff --git a/modules/engine/include/engine/scene/components/native_script.hpp b/modules/engine/include/engine/scene/components/native_script.hpp index 7d2e3fb..78e205a 100644 --- a/modules/engine/include/engine/scene/components/native_script.hpp +++ b/modules/engine/include/engine/scene/components/native_script.hpp @@ -12,14 +12,14 @@ struct NativeScriptComponent NativeScript *(*CreateInstance)(); void (*DestroyInstance)(NativeScriptComponent *); - template - void Bind() + template + void bind() { CreateInstance = []() { - return static_cast(new T()); + return static_cast(new t()); }; DestroyInstance = [](NativeScriptComponent *nsc) { - delete (T *)(nsc->instance); + delete (t *)(nsc->instance); nsc->instance = nullptr; }; } diff --git a/modules/engine/include/engine/scene/components/scriptable_entity.hpp b/modules/engine/include/engine/scene/components/scriptable_entity.hpp index 17b48aa..43e6fe7 100644 --- a/modules/engine/include/engine/scene/components/scriptable_entity.hpp +++ b/modules/engine/include/engine/scene/components/scriptable_entity.hpp @@ -17,25 +17,25 @@ public: NativeScript() = default; virtual ~NativeScript() = default; - inline unsigned int GetUID() const + inline unsigned int get_uid() const { return m_unique_identifier; } - template - T &GetComponent() + template + t &GetComponent() { - return m_entity.GetComponent(); + return m_entity.GetComponent(); } protected: - virtual void OnCreate() + virtual void on_create() { } - virtual void OnDestroy() + virtual void on_destroy() { } - virtual void OnUpdate(float ts) + virtual void on_update(float ts) { } }; diff --git a/modules/engine/include/engine/scene/components/transform.hpp b/modules/engine/include/engine/scene/components/transform.hpp index f2649c6..7778f86 100644 --- a/modules/engine/include/engine/scene/components/transform.hpp +++ b/modules/engine/include/engine/scene/components/transform.hpp @@ -29,7 +29,7 @@ struct TransformComponent { } - inline glm::mat4 GetTransform() const + inline glm::mat4 get_transform() const { return glm::translate(translation) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(scale); @@ -37,7 +37,7 @@ struct TransformComponent operator const glm::mat4() const { - return GetTransform(); + return get_transform(); } }; diff --git a/modules/engine/include/engine/scene/entity.hpp b/modules/engine/include/engine/scene/entity.hpp index 907e400..3231f68 100644 --- a/modules/engine/include/engine/scene/entity.hpp +++ b/modules/engine/include/engine/scene/entity.hpp @@ -15,38 +15,39 @@ private: public: Entity(entt::entity handle = entt::null, Scene *registry = nullptr); + ~Entity(); - template - inline T &AddComponent(Args &&...args) + template + inline t &AddComponent(Args &&...args) { - return m_scene->m_registry.emplace(m_handle, std::forward(args)...); + return m_scene->m_registry.emplace(m_handle, std::forward(args)...); } - template - inline T &GetComponent() + template + inline t &GetComponent() { - return m_scene->m_registry.get(m_handle); + return m_scene->m_registry.get(m_handle); } - template - inline bool HasComponent() + template + inline bool has_component() { - return m_scene->m_registry.any_of(m_handle); + return m_scene->m_registry.any_of(m_handle); } - template - inline void RemoveComponent() + template + inline void remove_component() { - m_scene->m_registry.remove(m_handle); + m_scene->m_registry.remove(m_handle); } - inline uint64_t GetUUID() + inline uint64_t get_uuid() { return GetComponent().uuid; } - inline bool IsValid() const + inline bool is_valid() const { return m_handle != entt::null && m_scene != nullptr; } diff --git a/modules/engine/include/engine/scene/scene.hpp b/modules/engine/include/engine/scene/scene.hpp index 4bab48e..f89b12d 100644 --- a/modules/engine/include/engine/scene/scene.hpp +++ b/modules/engine/include/engine/scene/scene.hpp @@ -26,20 +26,20 @@ public: Scene(); ~Scene(); - void OnCreate(); + void on_create(); - void OnUpdate(float deltaTime); - void OnRender(const Ref &targetFrameBuffer = nullptr); + void on_update(float deltaTime); + void on_render(const Ref &targetFrameBuffer = nullptr); - Entity CreateEntity( + Entity create_entity( const std::string &name, const TransformComponent &transform = TransformComponent() ); - Entity GetEntityByTag(const std::string &tag); + Entity get_entity_by_tag(const std::string &tag); private: - Entity CreateEntityWithUUID( + Entity create_entity_with_uuid( const std::string &name, UUID uuid, const TransformComponent &transform = TransformComponent() diff --git a/modules/engine/include/engine/time/timer.hpp b/modules/engine/include/engine/time/timer.hpp index 688f497..7d826d1 100644 --- a/modules/engine/include/engine/time/timer.hpp +++ b/modules/engine/include/engine/time/timer.hpp @@ -13,7 +13,7 @@ private: public: Timer(); - inline float GetElapsedTime() const + inline float get_elapsed_time() const { return (std::chrono::duration_cast( std::chrono::steady_clock::now() - m_start @@ -22,7 +22,7 @@ public: / 1000.; } - inline void Reset() + inline void reset() { m_start = std::chrono::steady_clock::now(); } @@ -39,9 +39,9 @@ private: public: DeltaTimer(); - void Update(); + void update(); - inline float GetDeltaTime() const + inline float get_delta_time() const { return m_delta_time; } diff --git a/modules/engine/include/engine/user_interface/user_interface.hpp b/modules/engine/include/engine/user_interface/user_interface.hpp index 64b6dd4..7c204bc 100644 --- a/modules/engine/include/engine/user_interface/user_interface.hpp +++ b/modules/engine/include/engine/user_interface/user_interface.hpp @@ -21,33 +21,33 @@ private: ImGuiWindowFlags m_dockspace_flags; public: - static Scope Create(GLFWwindow *windowHandle, Ref sharedContext); + static Scope create(GLFWwindow *windowHandle, Ref sharedContext); UserInterface(const UserInterface &) = delete; UserInterface &operator=(const UserInterface &) = delete; virtual ~UserInterface() = default; - void Init(GLFWwindow *windowHandle, Ref sharedContext); + void init(GLFWwindow *windowHandle, Ref sharedContext); - static void DockspaceBegin(); - static void DockspaceEnd(); + static void dockspace_begin(); + static void dockspace_end(); - virtual void PlatformImplementation( + virtual void platform_implementation( GLFWwindow *windowHandle, Ref sharedContext ) = 0; - virtual void Begin() = 0; - virtual void End() = 0; + virtual void begin() = 0; + virtual void end() = 0; - virtual void LogDebugData() = 0; + virtual void log_debug_data() = 0; protected: UserInterface(); private: - void SetDarkThemeColors(); + void set_dark_theme_colors(); }; } // namespace Light diff --git a/modules/engine/include/engine/utils/file_manager.hpp b/modules/engine/include/engine/utils/file_manager.hpp index e21e711..124c9c6 100644 --- a/modules/engine/include/engine/utils/file_manager.hpp +++ b/modules/engine/include/engine/utils/file_manager.hpp @@ -4,10 +4,10 @@ namespace Light { -class BasicFileHandle +class basic_file_handle { public: - BasicFileHandle( + basic_file_handle( uint8_t *data = nullptr, uint32_t size = 0ull, const std::string &path = "", @@ -15,14 +15,14 @@ public: const std::string &extension = "" ); - virtual void Release(); + virtual void release(); // getters inline uint8_t *GetData() { return m_data; } - inline uint32_t GetSize() + inline uint32_t get_size() { return m_size; } @@ -45,7 +45,7 @@ public: return m_name + '.' + m_extension; } - inline bool IsValid() const + inline bool is_valid() const { return !!m_data; } @@ -53,11 +53,11 @@ public: // operators inline operator bool() const { - return IsValid(); + return is_valid(); } protected: - // made protected for custom Free(): + // made protected for custom free(): uint8_t *m_data; uint32_t m_size; @@ -65,10 +65,10 @@ private: const std::string m_path, m_name, m_extension; }; -class ImageFileHandle: public BasicFileHandle +class image_file_handle: public basic_file_handle { public: - ImageFileHandle( + image_file_handle( uint8_t *data, uint32_t size, const std::string &path, @@ -79,7 +79,7 @@ public: uint32_t components, uint32_t desiredComponents ) - : BasicFileHandle(data, size, path, name, extension) + : basic_file_handle(data, size, path, name, extension) , m_width(width) , m_height(height) , m_components(components) @@ -87,22 +87,22 @@ public: { } - void Release() override; + void release() override; // getters - inline uint32_t GetWidth() const + inline uint32_t get_width() const { return m_width; } - inline uint32_t GetHeight() const + inline uint32_t get_height() const { return m_height; } - inline uint32_t GetComponents() const + inline uint32_t get_components() const { return m_components; } - inline uint32_t GetDesiredComponents() const + inline uint32_t get_desired_components() const { return m_desired_components; } @@ -114,8 +114,8 @@ private: class FileManager { public: - static BasicFileHandle ReadTextFile(const std::string &path); - static ImageFileHandle ReadImageFile(const std::string &path, int32_t desiredComponents); + static basic_file_handle read_text_file(const std::string &path); + static image_file_handle read_image_file(const std::string &path, int32_t desiredComponents); }; } // namespace Light diff --git a/modules/engine/include/engine/utils/resource_manager.hpp b/modules/engine/include/engine/utils/resource_manager.hpp index 3a5ae1b..9c91150 100644 --- a/modules/engine/include/engine/utils/resource_manager.hpp +++ b/modules/engine/include/engine/utils/resource_manager.hpp @@ -19,37 +19,37 @@ private: std::unordered_map> m_textures; public: - static Scope Create(); + static Scope create(); // #todo: add geometry shader support - static inline void LoadShader( + static inline void load_shader( const std::string &name, const std::string &vertexPath, const std::string &pixelPath ) { - s_Context->LoadShaderImpl(name, vertexPath, pixelPath); + s_Context->load_shader_impl(name, vertexPath, pixelPath); } - static inline void LoadTexture( + static inline void load_texture( const std::string &name, const std::string &path, unsigned int desiredComponents = 4u ) { - s_Context->LoadTextureImpl(name, path, desiredComponents); + s_Context->load_texture_impl(name, path, desiredComponents); } - static inline void ReleaseTexture(const std::string &name) + static inline void release_texture(const std::string &name) { - s_Context->ReleaseTextureImpl(name); + s_Context->release_texture_impl(name); } - static inline Ref GetShader(const std::string &name) + static inline Ref get_shader(const std::string &name) { return s_Context->m_shaders[name]; } - static inline Ref GetTexture(const std::string &name) + static inline Ref get_texture(const std::string &name) { return s_Context->m_textures[name]; } @@ -57,19 +57,19 @@ public: private: ResourceManager(); - void LoadShaderImpl( + void load_shader_impl( const std::string &name, const std::string &vertexPath, const std::string &pixelPath ); - void LoadTextureImpl( + void load_texture_impl( const std::string &name, const std::string &path, unsigned int desiredComponents = 4u ); - void ReleaseTextureImpl(const std::string &name); + void release_texture_impl(const std::string &name); }; } // namespace Light diff --git a/modules/engine/include/engine/utils/serializer.hpp b/modules/engine/include/engine/utils/serializer.hpp index 2f9eb8e..2a28ea7 100644 --- a/modules/engine/include/engine/utils/serializer.hpp +++ b/modules/engine/include/engine/utils/serializer.hpp @@ -12,14 +12,14 @@ class SceneSerializer public: SceneSerializer(const Ref &scene); - void Serialize(const std::string &filePath); - bool Deserialize(const std::string &filePath); + void serialize(const std::string &filePath); + bool deserialize(const std::string &filePath); - void SerializeBinary(const std::string &filePath); - bool DeserializeBinary(const std::string &filePath); + void serialize_binary(const std::string &filePath); + bool deserialize_binary(const std::string &filePath); private: - void SerializeEntity(YAML::Emitter &out, Entity entity); + void serialize_entity(YAML::Emitter &out, Entity entity); private: Ref m_scene; diff --git a/modules/engine/include/engine/utils/stringifier.hpp b/modules/engine/include/engine/utils/stringifier.hpp index 6b3a138..ed85487 100644 --- a/modules/engine/include/engine/utils/stringifier.hpp +++ b/modules/engine/include/engine/utils/stringifier.hpp @@ -17,7 +17,7 @@ public: static std::string spdlogLevel(unsigned int level); - static std::string GraphicsAPIToString(GraphicsAPI api); + static std::string graphics_api_to_string(GraphicsAPI api); }; } // namespace Light diff --git a/modules/engine/rename.py b/modules/engine/rename.py new file mode 100644 index 0000000..8679387 --- /dev/null +++ b/modules/engine/rename.py @@ -0,0 +1,113 @@ +import re +import pathlib +import sys +import argparse +from collections import defaultdict + +# Convert PascalCase to snake_case +import re + +def to_snake_case(name): + # Skip if ALL CAPS (macros) + if name.isupper(): + return name.lower() # or just return name if you want to keep macros fully uppercase + + # Step 1: Split acronyms followed by normal PascalCase words (APIClient → API_Client) + name = re.sub(r'([A-Z]+)([A-Z][a-z])', r'\1_\2', name) + + # Step 2: Split lowercase/digit to uppercase (fooBar → foo_Bar) + name = re.sub(r'(?<=[a-z0-9])(?=[A-Z])', '_', name) + + # Step 3: Split letter-digit transitions only if digit is followed by uppercase letter + name = re.sub(r'(?<=[a-zA-Z])(?=[0-9][A-Z])', '_', name) + + # Step 4: Split digit-letter transitions (RGBA32Float → RGBA_32_Float) + name = re.sub(r'(?<=[0-9])(?=[a-zA-Z])', '_', name) + + # Step 5: Fix accidental splits like '_2_D' → '_2d' + name = re.sub(r'_(\d+)_([a-z])', r'_\1\2', name, flags=re.IGNORECASE) + + return name.lower() + +# Get all .cpp/.h/.hpp/.c files in the project (excluding vendor/third-party folders) +def get_source_files(root_dir): + skip_dirs = {"vendor", "external", "third_party", "Dependencies", "build"} + for path in pathlib.Path(root_dir).rglob("*"): + if path.suffix.lower() in {".cpp", ".h", ".hpp", ".c"}: + if not any(part in skip_dirs for part in path.parts): + yield path + +# Extract PascalCase function names from definitions +def extract_pascal_functions(code): + # Collect all class/struct names + class_names = set(re.findall(r'\b(class|struct)\s+([A-Za-z_][A-Za-z0-9_]*)', code)) + class_names = {name for _, name in class_names} + + # Match PascalCase function names, not prefixed with ~ + candidates = re.findall(r'\b(?:[A-Za-z_][\w:<>]*)\s+([A-Z][A-Za-z0-9_]*)\s*\(', code) + + valid_funcs = set() + for name in candidates: + if name.startswith("~"): + continue # Skip destructors + if name in class_names: + continue # Skip constructors + valid_funcs.add(name) + + return valid_funcs + +# Rename function names in content +def rename_usages(content, rename_map): + for original, replacement in rename_map.items(): + # Word-boundary replace: only full function names (not part of other identifiers) + content = re.sub(rf'\b{original}\b', replacement, content) + return content + +def main(): + parser = argparse.ArgumentParser(description="Rename project-defined PascalCase functions to snake_case") + parser.add_argument("project_dir", help="Path to project root") + parser.add_argument("--apply", action="store_true", help="Actually modify files") + args = parser.parse_args() + + project_dir = args.project_dir + defined_functions = set() + + print("[+] Scanning for function definitions...") + # First pass: collect function definitions + for file_path in get_source_files(project_dir): + try: + text = file_path.read_text(encoding='utf-8') + matches = extract_pascal_functions(text) + for name in matches: + if name.isidentifier() and not name.startswith("ImGui"): # crude 3rd-party filter + defined_functions.add(name) + except Exception as e: + print(f"[!] Error reading {file_path}: {e}") + + if not defined_functions: + print("[-] No PascalCase function definitions found.") + return + + rename_map = {name: to_snake_case(name) for name in defined_functions if name != to_snake_case(name)} + + print(f"[+] Found {len(rename_map)} functions to rename:") + for orig, snake in rename_map.items(): + print(f" {orig} → {snake}") + + if not args.apply: + print("\n[DRY RUN] No files will be modified. Use --apply to perform renaming.\n") + + # Second pass: apply renaming + for file_path in get_source_files(project_dir): + try: + content = file_path.read_text(encoding='utf-8') + new_content = rename_usages(content, rename_map) + if new_content != content: + print(f"[~] Updating {file_path}") + if args.apply: + file_path.write_text(new_content, encoding='utf-8') + except Exception as e: + print(f"[!] Error processing {file_path}: {e}") + +if __name__ == "__main__": + main() diff --git a/modules/engine/src/camera/ortho.cpp b/modules/engine/src/camera/ortho.cpp index 1fcade5..c72bfcc 100644 --- a/modules/engine/src/camera/ortho.cpp +++ b/modules/engine/src/camera/ortho.cpp @@ -18,12 +18,12 @@ OrthographicCamera::OrthographicCamera( { } -void OrthographicCamera::CalculateView() +void OrthographicCamera::calculate_view() { m_view = glm::lookAt(glm::vec3(m_position, 100.0f), glm::vec3(m_position, 0.0f), m_up); } -void OrthographicCamera::CalculateProjection() +void OrthographicCamera::calculate_projection() { m_projection = glm::ortho( -m_zoom_level * m_aspect_ratio, @@ -35,13 +35,13 @@ void OrthographicCamera::CalculateProjection() ); } -void OrthographicCamera::OnResize(const glm::vec2 &size) +void OrthographicCamera::on_resize(const glm::vec2 &size) { m_aspect_ratio = size.x / size.y; - CalculateProjection(); + calculate_projection(); } -void OrthographicCamera::Move(const glm::vec2 &position) +void OrthographicCamera::move(const glm::vec2 &position) { m_position += position; } diff --git a/modules/engine/src/camera/scene.cpp b/modules/engine/src/camera/scene.cpp index bcb935e..7cc6a81 100644 --- a/modules/engine/src/camera/scene.cpp +++ b/modules/engine/src/camera/scene.cpp @@ -9,58 +9,58 @@ SceneCamera::SceneCamera() , m_aspect_ratio(16.0f / 9.0f) , m_projection_type(ProjectionType::Orthographic) { - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetViewportSize(unsigned int width, unsigned int height) +void SceneCamera::set_viewport_size(unsigned int width, unsigned int height) { m_aspect_ratio = width / (float)height; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetProjectionType(ProjectionType projectionType) +void SceneCamera::set_projection_type(ProjectionType projectionType) { m_projection_type = projectionType; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetOrthographicSize(float size) +void SceneCamera::set_orthographic_size(float size) { m_orthographic_specification.size = size; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetOrthographicFarPlane(float farPlane) +void SceneCamera::set_orthographic_far_plane(float farPlane) { m_orthographic_specification.farPlane = farPlane; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetOrthographicNearPlane(float nearPlane) +void SceneCamera::set_orthographic_near_plane(float nearPlane) { m_orthographic_specification.nearPlane = nearPlane; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetPerspectiveVerticalFOV(float verticalFOV) +void SceneCamera::set_perspective_vertical_fov(float verticalFOV) { m_perspective_specification.verticalFOV = verticalFOV; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetPerspectiveFarPlane(float farPlane) +void SceneCamera::set_perspective_far_plane(float farPlane) { m_perspective_specification.farPlane = farPlane; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::SetPerspectiveNearPlane(float nearPlane) +void SceneCamera::set_perspective_near_plane(float nearPlane) { m_perspective_specification.nearPlane = nearPlane; - CalculateProjection(); + calculate_projection(); } -void SceneCamera::CalculateProjection() +void SceneCamera::calculate_projection() { if (m_projection_type == ProjectionType::Orthographic) { diff --git a/modules/engine/src/core/application.cpp b/modules/engine/src/core/application.cpp index 00d4916..38484f2 100644 --- a/modules/engine/src/core/application.cpp +++ b/modules/engine/src/core/application.cpp @@ -19,135 +19,135 @@ Application::Application() , m_input(nullptr) , m_window(nullptr) { - ASSERT(!s_Context, "Repeated singleton construction"); + lt_assert(!s_Context, "Repeated singleton construction"); s_Context = this; - m_logger = Logger::Create(); - LogDebugData(); + m_logger = logger::create(); + log_debug_data(); - m_instrumentor = Instrumentor::Create(); - m_instrumentor->BeginSession("Logs/ProfileResults_Startup.json"); + m_instrumentor = Instrumentor::create(); + m_instrumentor->begin_session("Logs/ProfileResults_Startup.json"); - m_layer_stack = LayerStack::Create(); - m_input = Input::Create(); + m_layer_stack = LayerStack::create(); + m_input = Input::create(); - m_resource_manager = ResourceManager::Create(); + m_resource_manager = ResourceManager::create(); - m_window = Window::Create(std::bind(&Application::OnEvent, this, std::placeholders::_1)); + m_window = Window::create(std::bind(&Application::on_event, this, std::placeholders::_1)); } Application::~Application() { - LOG(trace, "Application::~Application()"); - m_instrumentor->EndSession(); // ProfileResults_Termination // + lt_log(trace, "Application::~Application()"); + m_instrumentor->end_session(); // ProfileResults_Termination // } -void Application::GameLoop() +void Application::game_loop() { // check - ASSERT(!m_layer_stack->IsEmpty(), "LayerStack is empty"); + lt_assert(!m_layer_stack->is_empty(), "layer_stack is empty"); // log debug data - m_logger->LogDebugData(); - m_window->GetGfxContext()->LogDebugData(); - m_window->GetGfxContext()->GetUserInterface()->LogDebugData(); + m_logger->log_debug_data(); + m_window->GetGfxContext()->log_debug_data(); + m_window->GetGfxContext()->GetUserInterface()->log_debug_data(); // reveal window - m_window->SetVisibility(true); + m_window->set_visibility(true); - m_instrumentor->EndSession(); // ProfileResults_GameLoop // - m_instrumentor->BeginSession("Logs/ProfileResults_GameLoop.json"); + m_instrumentor->end_session(); // ProfileResults_GameLoop // + m_instrumentor->begin_session("Logs/ProfileResults_GameLoop.json"); /* game loop */ DeltaTimer deltaTimer; - while (!m_window->IsClosed()) + while (!m_window->is_closed()) { { // update layers - LT_PROFILE_SCOPE("GameLoop::Update"); + lt_profile_scope("game_loop::update"); for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++) - (*it)->OnUpdate(deltaTimer.GetDeltaTime()); + (*it)->on_update(deltaTimer.get_delta_time()); } { // render layers - LT_PROFILE_SCOPE("GameLoop::Render"); - m_window->GetGfxContext()->GetRenderer()->BeginFrame(); + lt_profile_scope("game_loop::Render"); + m_window->GetGfxContext()->GetRenderer()->begin_frame(); for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++) - (*it)->OnRender(); + (*it)->on_render(); - m_window->GetGfxContext()->GetRenderer()->EndFrame(); + m_window->GetGfxContext()->GetRenderer()->end_frame(); } { // render user interface - LT_PROFILE_SCOPE("GameLoop::UserInterface"); - m_window->GetGfxContext()->GetUserInterface()->Begin(); + lt_profile_scope("game_loop::UserInterface"); + m_window->GetGfxContext()->GetUserInterface()->begin(); for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++) - (*it)->OnUserInterfaceUpdate(); + (*it)->on_user_interface_update(); - m_window->GetGfxContext()->GetUserInterface()->End(); + m_window->GetGfxContext()->GetUserInterface()->end(); } { // poll events - LT_PROFILE_SCOPE("GameLoop::Events"); - m_window->PollEvents(); + lt_profile_scope("game_loop::Events"); + m_window->poll_events(); } /// update delta time - deltaTimer.Update(); + deltaTimer.update(); } - m_instrumentor->EndSession(); // ProfileResults_GameLoop // - m_instrumentor->BeginSession("Logs/ProfileResults_Termination.json"); + m_instrumentor->end_session(); // ProfileResults_GameLoop // + m_instrumentor->begin_session("Logs/ProfileResults_Termination.json"); } -void Application::Quit() +void Application::quit() { - s_Context->m_window->Close(); + s_Context->m_window->close(); } -void Application::OnEvent(const Event &event) +void Application::on_event(const Event &event) { // window - if (event.HasCategory(WindowEventCategory)) + if (event.has_category(WindowEventCategory)) { - m_window->OnEvent(event); + m_window->on_event(event); - if (event.GetEventType() == EventType::WindowResized) - m_window->GetGfxContext()->GetRenderer()->OnWindowResize( + if (event.get_event_type() == EventType::WindowResized) + m_window->GetGfxContext()->GetRenderer()->on_window_resize( (const WindowResizedEvent &)event ); } // input - if (event.HasCategory(InputEventCategory)) + if (event.has_category(InputEventCategory)) { - m_input->OnEvent(event); + m_input->on_event(event); - if (!m_input->IsReceivingGameEvents()) // return if the event is an input event and 'Input' - // has disabled the game events + if (!m_input->is_receiving_game_events()) // return if the event is an input event and + // 'Input' has disabled the game events return; } /* layers */ for (auto it = m_layer_stack->rbegin(); it != m_layer_stack->rend(); it++) - if ((*it)->OnEvent(event)) + if ((*it)->on_event(event)) return; } -void Application::LogDebugData() +void Application::log_debug_data() { // #todo: log more information - LOG(info, "________________________________________"); - LOG(info, "Platform::"); - LOG(info, " OS: {}", LT_BUILD_PLATFORM); - LOG(info, " DIR: {}", std::filesystem::current_path().generic_string()); - LOG(info, "________________________________________"); + lt_log(info, "________________________________________"); + lt_log(info, "Platform::"); + lt_log(info, " OS: {}", LT_BUILD_PLATFORM); + lt_log(info, " DIR: {}", std::filesystem::current_path().generic_string()); + lt_log(info, "________________________________________"); } } // namespace Light diff --git a/modules/engine/src/debug/exceptions.cpp b/modules/engine/src/debug/exceptions.cpp index 385c035..fde98ec 100644 --- a/modules/engine/src/debug/exceptions.cpp +++ b/modules/engine/src/debug/exceptions.cpp @@ -10,25 +10,25 @@ namespace Light { FailedAssertion::FailedAssertion(const char *file, int line) { - LOG(critical, "Assertion failed in: {} (line {})", file, line); + lt_log(critical, "Assertion failed in: {} (line {})", file, line); } glException::glException(unsigned int source, unsigned int type, unsigned int id, const char *msg) { // #todo: improve - LOG(critical, "________________________________________"); - LOG(critical, "glException::glException::"); - // LOG(critical, " Severity: {}", + lt_log(critical, "________________________________________"); + lt_log(critical, "glException::glException::"); + // lt_log(critical, " Severity: {}", // Stringifier::glDebugMsgSeverity(GL_DEBUG_SEVERITY_HIGH)); - LOG(critical, " Source : {}", Stringifier::glDebugMsgSource(source)); - LOG(critical, " Type : {}", Stringifier::glDebugMsgType(type)); - LOG(critical, " ID : {}", id); - // LOG(critical, " Vendor : {}", glGetString(GL_VENDOR)); - // LOG(critical, " Renderer: {}", glGetString(GL_RENDERER)); - // LOG(critical, " Version : {}", glGetString(GL_VERSION)); - // LOG(critical, " critical, SVersion: {}", glGetString(GL_SHADING_LANGUAGE_VERSION)); - LOG(critical, " {}", msg); - LOG(critical, "________________________________________"); + lt_log(critical, " Source : {}", Stringifier::glDebugMsgSource(source)); + lt_log(critical, " Type : {}", Stringifier::glDebugMsgType(type)); + lt_log(critical, " ID : {}", id); + // lt_log(critical, " Vendor : {}", glGetString(GL_VENDOR)); + // lt_log(critical, " renderer: {}", glGetString(GL_RENDERER)); + // lt_log(critical, " Version : {}", glGetString(GL_VERSION)); + // lt_log(critical, " critical, SVersion: {}", glGetString(GL_SHADING_LANGUAGE_VERSION)); + lt_log(critical, " {}", msg); + lt_log(critical, "________________________________________"); } #ifdef LIGHT_PLATFORM_WINDOWS @@ -46,11 +46,11 @@ dxException::dxException(long hr, const char *file, int line) ); // #todo: improve - LOG(critical, "________________________________________"); - LOG(critical, "dxException::dxException::"); - LOG(critical, " File: {}, Line: {}", file, line); - LOG(critical, " {}", message); - LOG(critical, "________________________________________"); + lt_log(critical, "________________________________________"); + lt_log(critical, "dxException::dxException::"); + lt_log(critical, " File: {}, Line: {}", file, line); + lt_log(critical, " {}", message); + lt_log(critical, "________________________________________"); LocalFree(message); } diff --git a/modules/engine/src/debug/instrumentor.cpp b/modules/engine/src/debug/instrumentor.cpp index ae21570..626252c 100644 --- a/modules/engine/src/debug/instrumentor.cpp +++ b/modules/engine/src/debug/instrumentor.cpp @@ -4,22 +4,22 @@ namespace Light { Instrumentor *Instrumentor::s_Context = nullptr; -Scope Instrumentor::Create() +Scope Instrumentor::create() { - return MakeScope(new Instrumentor); + return make_scope(new Instrumentor); } Instrumentor::Instrumentor(): m_current_session_count(0u) { // #todo: maintenance - ASSERT( + lt_assert( !s_Context, "An instance of 'Instrumentor' already exists, do not construct this class!" ); s_Context = this; } -void Instrumentor::BeginSessionImpl(const std::string &outputPath) +void Instrumentor::begin_session_impl(const std::string &outputPath) { std::filesystem::create_directory(outputPath.substr(0, outputPath.find_last_of('/') + 1)); @@ -27,10 +27,10 @@ void Instrumentor::BeginSessionImpl(const std::string &outputPath) m_output_file_stream << "{\"traceEvents\":["; } -void Instrumentor::EndSessionImpl() +void Instrumentor::end_session_impl() { if (m_current_session_count == 0u) - LOG(warn, "0 profiling for the ended session"); + lt_log(warn, "0 profiling for the ended session"); m_current_session_count = 0u; @@ -39,7 +39,7 @@ void Instrumentor::EndSessionImpl() m_output_file_stream.close(); } -void Instrumentor::SubmitScopeProfileImpl(const ScopeProfileResult &profileResult) +void Instrumentor::submit_scope_profile_impl(const ScopeProfileResult &profileResult) { if (m_current_session_count++ == 0u) m_output_file_stream << "{"; @@ -74,7 +74,7 @@ InstrumentorTimer::~InstrumentorTimer() .count() - m_result.start; - Instrumentor::SubmitScopeProfile(m_result); + Instrumentor::submit_scope_profile(m_result); } } // namespace Light diff --git a/modules/engine/src/debug/logger.cpp b/modules/engine/src/debug/logger.cpp index c886099..545921f 100644 --- a/modules/engine/src/debug/logger.cpp +++ b/modules/engine/src/debug/logger.cpp @@ -4,19 +4,19 @@ namespace Light { -Logger *Logger::s_Context = nullptr; +logger *logger::s_Context = nullptr; -Scope Logger::Create() +Scope logger::create() { - return MakeScope(new Logger()); + return make_scope(new logger()); } -Logger::Logger() +logger::logger() : m_engine_logger(nullptr) , m_file_logger(nullptr) , m_log_file_path(LT_LOG_FILE_LOCATION) { - ASSERT(!s_Context, "An instance of 'Logger' already exists, do not construct this class!"); + lt_assert(!s_Context, "An instance of 'logger' already exists, do not construct this class!"); s_Context = this; // set spdlog pattern @@ -40,15 +40,15 @@ Logger::Logger() #endif } -void Logger::LogDebugData() +void logger::log_debug_data() { // #todo: improve - LOG(info, "________________________________________"); - LOG(info, "Logger::"); - LOG(info, " EngineLevel : {}", Stringifier::spdlogLevel(m_engine_logger->level())); - LOG(info, " FileLevel : {}", Stringifier::spdlogLevel(m_file_logger->level())); - LOG(info, " DefaultLevel: {}", Stringifier::spdlogLevel(spdlog::get_level())); - LOG(info, "________________________________________"); + lt_log(info, "________________________________________"); + lt_log(info, "logger::"); + lt_log(info, " EngineLevel : {}", Stringifier::spdlogLevel(m_engine_logger->level())); + lt_log(info, " FileLevel : {}", Stringifier::spdlogLevel(m_file_logger->level())); + lt_log(info, " DefaultLevel: {}", Stringifier::spdlogLevel(spdlog::get_level())); + lt_log(info, "________________________________________"); } } // namespace Light diff --git a/modules/engine/src/graphics/blender.cpp b/modules/engine/src/graphics/blender.cpp index 275d091..a8db815 100644 --- a/modules/engine/src/graphics/blender.cpp +++ b/modules/engine/src/graphics/blender.cpp @@ -10,21 +10,21 @@ namespace Light { -Scope Blender::Create(Ref sharedContext) +Scope Blender::create(Ref sharedContext) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateScope(); + case GraphicsAPI::OpenGL: return create_scope(); case GraphicsAPI::DirectX: - LT_WIN(return CreateScope(std::static_pointer_cast(sharedContext + lt_win(return create_scope(std::static_pointer_cast(sharedContext ));) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); } } diff --git a/modules/engine/src/graphics/buffers.cpp b/modules/engine/src/graphics/buffers.cpp index dd45eb4..8d42328 100644 --- a/modules/engine/src/graphics/buffers.cpp +++ b/modules/engine/src/graphics/buffers.cpp @@ -13,28 +13,28 @@ namespace Light { //================================================== CONSTANT_BUFFER //==================================================// -Scope ConstantBuffer::Create( +Scope ConstantBuffer::create( ConstantBufferIndex index, unsigned int size, Ref sharedContext ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateScope(index, size); + case GraphicsAPI::OpenGL: return create_scope(index, size); case GraphicsAPI::DirectX: - LT_WIN(return CreateScope( + lt_win(return create_scope( index, size, std::static_pointer_cast(sharedContext) );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } @@ -44,19 +44,19 @@ Scope ConstantBuffer::Create( //================================================== VERTEX_BUFFER //==================================================// -Ref VertexBuffer::Create( +Ref VertexBuffer::create( float *vertices, unsigned int stride, unsigned int count, Ref sharedContext ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateRef(vertices, stride, count); + case GraphicsAPI::OpenGL: return create_ref(vertices, stride, count); case GraphicsAPI::DirectX: - LT_WIN(return CreateRef( + lt_win(return create_ref( vertices, stride, count, @@ -64,10 +64,10 @@ Ref VertexBuffer::Create( );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } @@ -76,28 +76,28 @@ Ref VertexBuffer::Create( //==================================================// //======================================== INDEX_BUFFER ========================================// -Ref IndexBuffer::Create( +Ref IndexBuffer::create( unsigned int *indices, unsigned int count, Ref sharedContext ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateRef(indices, count); + case GraphicsAPI::OpenGL: return create_ref(indices, count); case GraphicsAPI::DirectX: - LT_WIN(return CreateRef( + lt_win(return create_ref( indices, count, std::dynamic_pointer_cast(sharedContext) );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } diff --git a/modules/engine/src/graphics/framebuffer.cpp b/modules/engine/src/graphics/framebuffer.cpp index 28e1f26..83f72d3 100644 --- a/modules/engine/src/graphics/framebuffer.cpp +++ b/modules/engine/src/graphics/framebuffer.cpp @@ -10,26 +10,26 @@ namespace Light { -Ref Framebuffer::Create( +Ref Framebuffer::create( const FramebufferSpecification &specification, Ref sharedContext ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateRef(specification); + case GraphicsAPI::OpenGL: return create_ref(specification); case GraphicsAPI::DirectX: - LT_WIN(return CreateRef( + lt_win(return create_ref( specification, std::static_pointer_cast(sharedContext) );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } diff --git a/modules/engine/src/graphics/graphics_context.cpp b/modules/engine/src/graphics/graphics_context.cpp index 33f13e1..51348b9 100644 --- a/modules/engine/src/graphics/graphics_context.cpp +++ b/modules/engine/src/graphics/graphics_context.cpp @@ -21,7 +21,7 @@ GraphicsContext::~GraphicsContext() { } -Scope GraphicsContext::Create(GraphicsAPI api, GLFWwindow *windowHandle) +Scope GraphicsContext::create(GraphicsAPI api, GLFWwindow *windowHandle) { // terminate 'GraphicsContext' dependent classes if (s_Context) @@ -50,30 +50,30 @@ Scope GraphicsContext::Create(GraphicsAPI api, GLFWwindow *wind { // opengl case GraphicsAPI::OpenGL: - scopeGfx = CreateScope(windowHandle); + scopeGfx = create_scope(windowHandle); s_Context = scopeGfx.get(); break; // directx case GraphicsAPI::DirectX: - LT_WIN(scopeGfx = CreateScope(windowHandle); s_Context = scopeGfx.get(); + lt_win(scopeGfx = create_scope(windowHandle); s_Context = scopeGfx.get(); break;) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - Stringifier::GraphicsAPIToString(api) + Stringifier::graphics_api_to_string(api) ); return nullptr; } // create 'GraphicsContext' dependent classes - s_Context->m_user_interface = UserInterface::Create(windowHandle, s_Context->m_shared_context); - s_Context->m_renderer = Renderer::Create(windowHandle, s_Context->m_shared_context); + s_Context->m_user_interface = UserInterface::create(windowHandle, s_Context->m_shared_context); + s_Context->m_renderer = renderer::create(windowHandle, s_Context->m_shared_context); // check - ASSERT(s_Context->m_user_interface, "Failed to create UserInterface"); - ASSERT(s_Context->m_renderer, "Failed to create Renderer"); + lt_assert(s_Context->m_user_interface, "Failed to create UserInterface"); + lt_assert(s_Context->m_renderer, "Failed to create renderer"); return std::move(scopeGfx); } diff --git a/modules/engine/src/graphics/render_command.cpp b/modules/engine/src/graphics/render_command.cpp index cb30eac..a48bdcb 100644 --- a/modules/engine/src/graphics/render_command.cpp +++ b/modules/engine/src/graphics/render_command.cpp @@ -10,25 +10,25 @@ namespace Light { -Scope RenderCommand::Create( +Scope RenderCommand::create( GLFWwindow *windowHandle, Ref sharedContext ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateScope(windowHandle); + case GraphicsAPI::OpenGL: return create_scope(windowHandle); case GraphicsAPI::DirectX: - LT_WIN(return CreateScope( + lt_win(return create_scope( (std::static_pointer_cast)(sharedContext) );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } diff --git a/modules/engine/src/graphics/renderer.cpp b/modules/engine/src/graphics/renderer.cpp index 9219879..42be5b5 100644 --- a/modules/engine/src/graphics/renderer.cpp +++ b/modules/engine/src/graphics/renderer.cpp @@ -12,9 +12,9 @@ namespace Light { -Renderer *Renderer::s_Context = nullptr; +renderer *renderer::s_Context = nullptr; -Renderer::Renderer(GLFWwindow *windowHandle, Ref sharedContext) +renderer::renderer(GLFWwindow *windowHandle, Ref sharedContext) : m_quad_renderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext) , m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext) , m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext) @@ -25,40 +25,40 @@ Renderer::Renderer(GLFWwindow *windowHandle, Ref sharedContext) , m_target_framebuffer(nullptr) , m_should_clear_backbuffer(false) { - 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; - m_view_projection_buffer = ConstantBuffer::Create( + m_view_projection_buffer = ConstantBuffer::create( ConstantBufferIndex::ViewProjection, sizeof(glm::mat4), sharedContext ); - m_render_command = RenderCommand::Create(windowHandle, sharedContext); - m_blender = Blender::Create(sharedContext); - m_blender->Enable(BlendFactor::SRC_ALPHA, BlendFactor::INVERSE_SRC_ALPHA); + m_render_command = RenderCommand::create(windowHandle, sharedContext); + m_blender = Blender::create(sharedContext); + m_blender->enable(BlendFactor::SRC_ALPHA, BlendFactor::INVERSE_SRC_ALPHA); } -Scope Renderer::Create(GLFWwindow *windowHandle, Ref sharedContext) +Scope renderer::create(GLFWwindow *windowHandle, Ref sharedContext) { - return MakeScope(new Renderer(windowHandle, sharedContext)); + return make_scope(new renderer(windowHandle, sharedContext)); } -void Renderer::OnWindowResize(const WindowResizedEvent &event) +void renderer::on_window_resize(const WindowResizedEvent &event) { - m_render_command->SetViewport(0u, 0u, event.GetSize().x, event.GetSize().y); + m_render_command->set_viewport(0u, 0u, event.get_size().x, event.get_size().y); } //======================================== DRAW_QUAD ========================================// /* tinted textures */ -void Renderer::DrawQuadImpl( +void renderer::draw_quad_impl( const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint, Ref texture ) { - DrawQuad( + draw_quad( glm::translate(glm::mat4(1.0f), position) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }), tint, @@ -67,9 +67,9 @@ void Renderer::DrawQuadImpl( } /* tint */ -void Renderer::DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint) +void renderer::draw_quad_impl(const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &tint) { - DrawQuad( + draw_quad( glm::translate(glm::mat4(1.0f), position) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }), tint @@ -77,9 +77,9 @@ void Renderer::DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, co } /* texture */ -void Renderer::DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, Ref texture) +void renderer::draw_quad_impl(const glm::vec3 &position, const glm::vec2 &size, Ref texture) { - DrawQuad( + draw_quad( glm::translate(glm::mat4(1.0f), position) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }), texture @@ -88,7 +88,7 @@ void Renderer::DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, Re //======================================== DRAW_QUAD ========================================// //==================== DRAW_QUAD_TINT ====================// -void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint) +void renderer::draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint) { // locals QuadRendererProgram::QuadVertexData *bufferMap = m_quad_renderer.GetMapCurrent(); @@ -110,20 +110,20 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint) bufferMap[3].tint = tint; // advance - if (!m_quad_renderer.Advance()) + if (!m_quad_renderer.advance()) { - LOG(warn, "Exceeded LT_MAX_QUAD_RENDERER_VERTICES: {}", LT_MAX_QUAD_RENDERER_VERTICES); - FlushScene(); + lt_log(warn, "Exceeded LT_MAX_QUAD_RENDERER_VERTICES: {}", LT_MAX_QUAD_RENDERER_VERTICES); + flush_scene(); } } //==================== DRAW_QUAD_TINT ====================// //==================== DRAW_QUAD_TEXTURE ====================// -void Renderer::DrawQuadImpl(const glm::mat4 &transform, Ref texture) +void renderer::draw_quad_impl(const glm::mat4 &transform, Ref texture) { // #todo: implement a proper binding - ASSERT(texture, "Texture passed to Renderer::DrawQuadImpl"); - texture->Bind(); + lt_assert(texture, "Texture passed to renderer::draw_quad_impl"); + texture->bind(); // locals TextureRendererProgram::TextureVertexData *bufferMap = m_texture_renderer.GetMapCurrent(); @@ -145,19 +145,19 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, Ref texture) bufferMap[3].texcoord = { 0.0f, 1.0f }; // advance - if (!m_texture_renderer.Advance()) + if (!m_texture_renderer.advance()) { - LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES + lt_log(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES ); - FlushScene(); + flush_scene(); } } -void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture) +void renderer::draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint, Ref texture) { // #todo: implement a proper binding - ASSERT(texture, "Texture passed to Renderer::DrawQuadImpl"); - texture->Bind(); + lt_assert(texture, "Texture passed to renderer::draw_quad_impl"); + texture->bind(); // locals TintedTextureRendererProgram::TintedTextureVertexData *bufferMap = m_tinted_texture_renderer @@ -184,24 +184,24 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint, R bufferMap[3].texcoord = { 0.0f, 1.0f }; // advance - if (!m_tinted_texture_renderer.Advance()) + if (!m_tinted_texture_renderer.advance()) { - LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES + lt_log(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES ); - FlushScene(); + flush_scene(); } } //==================== DRAW_QUAD_TEXTURE ====================// -void Renderer::BeginFrame() +void renderer::begin_frame() { } -void Renderer::EndFrame() +void renderer::end_frame() { - m_render_command->SwapBuffers(); - m_render_command->ClearBackBuffer( + m_render_command->swap_buffers(); + m_render_command->clear_back_buffer( m_default_framebuffer_camera ? m_default_framebuffer_camera->GetBackgroundColor() : glm::vec4(0.0f) ); @@ -209,7 +209,7 @@ void Renderer::EndFrame() m_default_framebuffer_camera = nullptr; } -void Renderer::BeginSceneImpl( +void renderer::begin_scene_impl( Camera *camera, const glm::mat4 &cameraTransform, const Ref &targetFrameBuffer /* = nullptr */ @@ -219,86 +219,86 @@ void Renderer::BeginSceneImpl( m_target_framebuffer = targetFrameBuffer; if (targetFrameBuffer) - targetFrameBuffer->BindAsTarget(camera->GetBackgroundColor()); + targetFrameBuffer->bind_as_target(camera->GetBackgroundColor()); else { m_default_framebuffer_camera = camera; - m_render_command->DefaultTargetFramebuffer(); + m_render_command->default_target_framebuffer(); } // update view projection buffer - glm::mat4 *map = (glm::mat4 *)m_view_projection_buffer->Map(); + glm::mat4 *map = (glm::mat4 *)m_view_projection_buffer->map(); map[0] = camera->GetProjection() * glm::inverse(cameraTransform); - m_view_projection_buffer->UnMap(); + m_view_projection_buffer->un_map(); // map renderers - m_quad_renderer.Map(); - m_texture_renderer.Map(); - m_tinted_texture_renderer.Map(); + m_quad_renderer.map(); + m_texture_renderer.map(); + m_tinted_texture_renderer.map(); } -void Renderer::FlushScene() +void renderer::flush_scene() { /* tinted texture renderer */ - m_tinted_texture_renderer.UnMap(); - if (m_tinted_texture_renderer.GetQuadCount()) + m_tinted_texture_renderer.un_map(); + if (m_tinted_texture_renderer.get_quad_count()) { - m_tinted_texture_renderer.Bind(); - m_render_command->DrawIndexed(m_tinted_texture_renderer.GetQuadCount() * 6u); + m_tinted_texture_renderer.bind(); + m_render_command->draw_indexed(m_tinted_texture_renderer.get_quad_count() * 6u); } /* quad renderer */ - m_quad_renderer.UnMap(); - if (m_quad_renderer.GetQuadCount()) + m_quad_renderer.un_map(); + if (m_quad_renderer.get_quad_count()) { - m_quad_renderer.Bind(); - m_render_command->DrawIndexed(m_quad_renderer.GetQuadCount() * 6u); + m_quad_renderer.bind(); + m_render_command->draw_indexed(m_quad_renderer.get_quad_count() * 6u); } /* texture renderer */ - m_texture_renderer.UnMap(); - if (m_texture_renderer.GetQuadCount()) + m_texture_renderer.un_map(); + if (m_texture_renderer.get_quad_count()) { - m_texture_renderer.Bind(); - m_render_command->DrawIndexed(m_texture_renderer.GetQuadCount() * 6u); + m_texture_renderer.bind(); + m_render_command->draw_indexed(m_texture_renderer.get_quad_count() * 6u); } - m_quad_renderer.Map(); - m_texture_renderer.Map(); - m_tinted_texture_renderer.Map(); + m_quad_renderer.map(); + m_texture_renderer.map(); + m_tinted_texture_renderer.map(); } -void Renderer::EndSceneImpl() +void renderer::end_scene_impl() { /* tinted texture renderer */ - m_tinted_texture_renderer.UnMap(); - if (m_tinted_texture_renderer.GetQuadCount()) + m_tinted_texture_renderer.un_map(); + if (m_tinted_texture_renderer.get_quad_count()) { - m_tinted_texture_renderer.Bind(); - m_render_command->DrawIndexed(m_tinted_texture_renderer.GetQuadCount() * 6u); + m_tinted_texture_renderer.bind(); + m_render_command->draw_indexed(m_tinted_texture_renderer.get_quad_count() * 6u); } /* quad renderer */ - m_quad_renderer.UnMap(); - if (m_quad_renderer.GetQuadCount()) + m_quad_renderer.un_map(); + if (m_quad_renderer.get_quad_count()) { - m_quad_renderer.Bind(); - m_render_command->DrawIndexed(m_quad_renderer.GetQuadCount() * 6u); + m_quad_renderer.bind(); + m_render_command->draw_indexed(m_quad_renderer.get_quad_count() * 6u); } /* texture renderer */ - m_texture_renderer.UnMap(); - if (m_texture_renderer.GetQuadCount()) + m_texture_renderer.un_map(); + if (m_texture_renderer.get_quad_count()) { - m_texture_renderer.Bind(); - m_render_command->DrawIndexed(m_texture_renderer.GetQuadCount() * 6u); + m_texture_renderer.bind(); + m_render_command->draw_indexed(m_texture_renderer.get_quad_count() * 6u); } // reset frame buffer if (m_target_framebuffer) { m_target_framebuffer = nullptr; - m_render_command->DefaultTargetFramebuffer(); + m_render_command->default_target_framebuffer(); } } diff --git a/modules/engine/src/graphics/renderer_programs/quad.cpp b/modules/engine/src/graphics/renderer_programs/quad.cpp index 47115c1..532f94b 100644 --- a/modules/engine/src/graphics/renderer_programs/quad.cpp +++ b/modules/engine/src/graphics/renderer_programs/quad.cpp @@ -17,20 +17,20 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref( - VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext) + VertexBuffer::create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext) ); m_index_buffer = Ref( - IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext) + IndexBuffer::create(nullptr, (maxVertices / 4) * 6, sharedContext) ); - m_vertex_layout = Ref(VertexLayout::Create( + m_vertex_layout = Ref(VertexLayout::create( m_vertex_buffer, m_shader, { { "POSITION", VertexElementType::Float4 }, { "COLOR", VertexElementType::Float4 } }, @@ -38,13 +38,13 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref= m_map_end) { - LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices); + lt_log(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices); return false; } @@ -52,25 +52,25 @@ bool QuadRendererProgram::Advance() return true; } -void QuadRendererProgram::Map() +void QuadRendererProgram::map() { m_quad_count = 0u; - m_map_current = (QuadRendererProgram::QuadVertexData *)m_vertex_buffer->Map(); + m_map_current = (QuadRendererProgram::QuadVertexData *)m_vertex_buffer->map(); m_map_end = m_map_current + m_max_vertices; } -void QuadRendererProgram::UnMap() +void QuadRendererProgram::un_map() { - m_vertex_buffer->UnMap(); + m_vertex_buffer->un_map(); } -void QuadRendererProgram::Bind() +void QuadRendererProgram::bind() { - m_shader->Bind(); - m_vertex_layout->Bind(); - m_vertex_buffer->Bind(); - m_index_buffer->Bind(); + m_shader->bind(); + m_vertex_layout->bind(); + m_vertex_buffer->bind(); + m_index_buffer->bind(); } } // namespace Light diff --git a/modules/engine/src/graphics/renderer_programs/texture.cpp b/modules/engine/src/graphics/renderer_programs/texture.cpp index 11398d2..bd0cda4 100644 --- a/modules/engine/src/graphics/renderer_programs/texture.cpp +++ b/modules/engine/src/graphics/renderer_programs/texture.cpp @@ -20,20 +20,20 @@ TextureRendererProgram::TextureRendererProgram( , m_max_vertices(maxVertices) { // #todo: don't use relative path - ResourceManager::LoadShader( + ResourceManager::load_shader( "LT_ENGINE_RESOURCES_TEXTURE_SHADER", "Assets/Shaders/Texture/Texture_VS.glsl", "Assets/Shaders/Texture/Texture_PS.glsl" ); - m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER"); + m_shader = ResourceManager::get_shader("LT_ENGINE_RESOURCES_TEXTURE_SHADER"); m_vertex_buffer = Ref( - VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext) + VertexBuffer::create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext) ); m_index_buffer = Ref( - IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext) + IndexBuffer::create(nullptr, (maxVertices / 4) * 6, sharedContext) ); - m_vertex_layout = Ref(VertexLayout::Create( + m_vertex_layout = Ref(VertexLayout::create( m_vertex_buffer, m_shader, { { "POSITION", VertexElementType::Float4 }, { "TEXCOORD", VertexElementType::Float2 } }, @@ -41,11 +41,11 @@ TextureRendererProgram::TextureRendererProgram( )); } -bool TextureRendererProgram::Advance() +bool TextureRendererProgram::advance() { if (m_map_current + 4 >= m_map_end) { - LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices); + lt_log(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices); return false; } @@ -54,25 +54,25 @@ bool TextureRendererProgram::Advance() return true; } -void TextureRendererProgram::Map() +void TextureRendererProgram::map() { m_quad_count = 0u; - m_map_current = (TextureRendererProgram::TextureVertexData *)m_vertex_buffer->Map(); + m_map_current = (TextureRendererProgram::TextureVertexData *)m_vertex_buffer->map(); m_map_end = m_map_current + m_max_vertices; } -void TextureRendererProgram::UnMap() +void TextureRendererProgram::un_map() { - m_vertex_buffer->UnMap(); + m_vertex_buffer->un_map(); } -void TextureRendererProgram::Bind() +void TextureRendererProgram::bind() { - m_shader->Bind(); - m_vertex_layout->Bind(); - m_vertex_buffer->Bind(); - m_index_buffer->Bind(); + m_shader->bind(); + m_vertex_layout->bind(); + m_vertex_buffer->bind(); + m_index_buffer->bind(); } } // namespace Light diff --git a/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp b/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp index 74d18a8..2b0f018 100644 --- a/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp +++ b/modules/engine/src/graphics/renderer_programs/tinted_texture.cpp @@ -20,20 +20,20 @@ TintedTextureRendererProgram::TintedTextureRendererProgram( , m_max_vertices(maxVertices) { // #todo: don't use relative path - ResourceManager::LoadShader( + ResourceManager::load_shader( "LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER", "Assets/Shaders/TintedTexture/TintedTexture_VS.glsl", "Assets/Shaders/TintedTexture/TintedTexture_PS.glsl" ); - m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER"); + m_shader = ResourceManager::get_shader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER"); m_vertex_buffer = Ref( - VertexBuffer::Create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext) + VertexBuffer::create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext) ); m_index_buffer = Ref( - IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext) + IndexBuffer::create(nullptr, (maxVertices / 4) * 6, sharedContext) ); - m_vertex_layout = Ref(VertexLayout::Create( + m_vertex_layout = Ref(VertexLayout::create( m_vertex_buffer, m_shader, { { "POSITION", VertexElementType::Float4 }, @@ -43,13 +43,13 @@ TintedTextureRendererProgram::TintedTextureRendererProgram( )); } -bool TintedTextureRendererProgram::Advance() +bool TintedTextureRendererProgram::advance() { m_map_current += 4; if (m_map_current >= m_map_end) { - LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices); + lt_log(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices); return false; } @@ -57,25 +57,25 @@ bool TintedTextureRendererProgram::Advance() return true; } -void TintedTextureRendererProgram::Map() +void TintedTextureRendererProgram::map() { m_quad_count = 0u; - m_map_current = (TintedTextureRendererProgram::TintedTextureVertexData *)m_vertex_buffer->Map(); + m_map_current = (TintedTextureRendererProgram::TintedTextureVertexData *)m_vertex_buffer->map(); m_map_end = m_map_current + m_max_vertices; } -void TintedTextureRendererProgram::UnMap() +void TintedTextureRendererProgram::un_map() { - m_vertex_buffer->UnMap(); + m_vertex_buffer->un_map(); } -void TintedTextureRendererProgram::Bind() +void TintedTextureRendererProgram::bind() { - m_shader->Bind(); - m_vertex_layout->Bind(); - m_vertex_buffer->Bind(); - m_index_buffer->Bind(); + m_shader->bind(); + m_vertex_layout->bind(); + m_vertex_buffer->bind(); + m_index_buffer->bind(); } } // namespace Light diff --git a/modules/engine/src/graphics/shader.cpp b/modules/engine/src/graphics/shader.cpp index 14b12df..0bd0942 100644 --- a/modules/engine/src/graphics/shader.cpp +++ b/modules/engine/src/graphics/shader.cpp @@ -10,29 +10,29 @@ namespace Light { -Ref Shader::Create( - BasicFileHandle vertexFile, - BasicFileHandle pixelFile, +Ref Shader::create( + basic_file_handle vertexFile, + basic_file_handle pixelFile, Ref sharedContext ) { // load shader source - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateRef(vertexFile, pixelFile); + case GraphicsAPI::OpenGL: return create_ref(vertexFile, pixelFile); case GraphicsAPI::DirectX: - LT_WIN(return CreateRef( + lt_win(return create_ref( vertexFile, pixelFile, std::static_pointer_cast(sharedContext) );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } diff --git a/modules/engine/src/graphics/texture.cpp b/modules/engine/src/graphics/texture.cpp index 0ad8f68..6e93e7b 100644 --- a/modules/engine/src/graphics/texture.cpp +++ b/modules/engine/src/graphics/texture.cpp @@ -10,7 +10,7 @@ namespace Light { -Ref Texture::Create( +Ref Texture::create( unsigned int width, unsigned int height, unsigned int components, @@ -19,13 +19,13 @@ Ref Texture::Create( const std::string &filePath ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { case GraphicsAPI::OpenGL: - return CreateRef(width, height, components, pixels, filePath); + return create_ref(width, height, components, pixels, filePath); case GraphicsAPI::DirectX: - LT_WIN(return CreateRef( + lt_win(return create_ref( width, height, components, @@ -35,10 +35,10 @@ Ref Texture::Create( );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } diff --git a/modules/engine/src/graphics/vertex_layout.cpp b/modules/engine/src/graphics/vertex_layout.cpp index d9bde15..7e7a7de 100644 --- a/modules/engine/src/graphics/vertex_layout.cpp +++ b/modules/engine/src/graphics/vertex_layout.cpp @@ -10,29 +10,29 @@ namespace Light { -Ref VertexLayout::Create( +Ref VertexLayout::create( Ref vertexBuffer, Ref shader, const std::vector> &elements, Ref sharedContext ) { - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: return CreateRef(vertexBuffer, elements); + case GraphicsAPI::OpenGL: return create_ref(vertexBuffer, elements); case GraphicsAPI::DirectX: - LT_WIN(return CreateRef( + lt_win(return create_ref( shader, elements, std::static_pointer_cast(sharedContext) );) default: - ASSERT( + lt_assert( false, "Invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } diff --git a/modules/engine/src/input/input.cpp b/modules/engine/src/input/input.cpp index 482c83a..38ff46a 100644 --- a/modules/engine/src/input/input.cpp +++ b/modules/engine/src/input/input.cpp @@ -10,9 +10,9 @@ namespace Light { Input *Input::s_Context = nullptr; -Scope Input::Create() +Scope Input::create() { - return MakeScope(new Input); + return make_scope(new Input); } Input::Input() @@ -24,30 +24,30 @@ Input::Input() , m_user_interface_events(true) , m_game_events(true) { - ASSERT( + lt_assert( !s_Context, "Input::Input: an instance of 'Input' already exists, do not construct this class!" ); s_Context = this; - RestartInputState(); + restart_input_state(); } -void Input::ReceiveUserInterfaceEventsImpl(bool receive, bool toggle /* = false */) +void Input::receive_user_interface_events_impl(bool receive, bool toggle /* = false */) { m_user_interface_events = toggle ? !m_user_interface_events : receive; } -void Input::ReceieveGameEventsImpl(bool receive, bool toggle /*= false*/) +void Input::receieve_game_events_impl(bool receive, bool toggle /*= false*/) { bool prev = m_game_events; m_game_events = toggle ? !m_user_interface_events : receive; if (m_game_events != prev) - RestartInputState(); + restart_input_state(); } -void Input::RestartInputState() +void Input::restart_input_state() { m_keyboad_keys.fill(false); m_mouse_buttons.fill(false); @@ -57,10 +57,10 @@ void Input::RestartInputState() m_mouse_wheel_delta = 0.0f; } -void Input::OnEvent(const Event &inputEvent) +void Input::on_event(const Event &inputEvent) { ImGuiIO &io = ImGui::GetIO(); - switch (inputEvent.GetEventType()) + switch (inputEvent.get_event_type()) { //** MOUSE_EVENTS **// case EventType::MouseMoved: @@ -74,7 +74,7 @@ void Input::OnEvent(const Event &inputEvent) } if (m_user_interface_events) - io.MousePos = ImVec2(event.GetX(), event.GetY()); + io.MousePos = ImVec2(event.get_x(), event.get_y()); return; } @@ -83,10 +83,10 @@ void Input::OnEvent(const Event &inputEvent) const ButtonPressedEvent &event = (const ButtonPressedEvent &)inputEvent; if (m_game_events) - m_mouse_buttons[event.GetButton()] = true; + m_mouse_buttons[event.get_button()] = true; if (m_user_interface_events) - io.MouseDown[event.GetButton()] = true; + io.MouseDown[event.get_button()] = true; return; } @@ -95,10 +95,10 @@ void Input::OnEvent(const Event &inputEvent) const ButtonReleasedEvent &event = (const ButtonReleasedEvent &)inputEvent; if (m_game_events) - m_mouse_buttons[event.GetButton()] = false; + m_mouse_buttons[event.get_button()] = false; if (m_user_interface_events) - io.MouseDown[event.GetButton()] = false; + io.MouseDown[event.get_button()] = false; return; } @@ -107,10 +107,10 @@ void Input::OnEvent(const Event &inputEvent) const WheelScrolledEvent &event = (const WheelScrolledEvent &)inputEvent; if (m_game_events) - m_mouse_wheel_delta = event.GetOffset(); + m_mouse_wheel_delta = event.get_offset(); if (m_user_interface_events) - io.MouseWheel = event.GetOffset(); + io.MouseWheel = event.get_offset(); return; } @@ -120,12 +120,12 @@ void Input::OnEvent(const Event &inputEvent) const KeyPressedEvent &event = (const KeyPressedEvent &)inputEvent; if (m_game_events) - m_keyboad_keys[event.GetKey()] = true; + m_keyboad_keys[event.get_key()] = true; if (m_user_interface_events) { - io.KeysDown[event.GetKey()] = true; - // if (event.GetKey() == Key::BackSpace) + io.KeysDown[event.get_key()] = true; + // if (event.get_key() == Key::BackSpace) // io.AddInputCharacter(Key::BackSpace); } @@ -136,10 +136,10 @@ void Input::OnEvent(const Event &inputEvent) const KeyReleasedEvent &event = (const KeyReleasedEvent &)inputEvent; if (m_game_events) - m_keyboad_keys[event.GetKey()] = false; + m_keyboad_keys[event.get_key()] = false; if (m_user_interface_events) - io.KeysDown[event.GetKey()] = false; + io.KeysDown[event.get_key()] = false; return; } @@ -148,7 +148,7 @@ void Input::OnEvent(const Event &inputEvent) if (m_user_interface_events) { const SetCharEvent &event = (const SetCharEvent &)inputEvent; - io.AddInputCharacter(event.GetCharacter()); + io.AddInputCharacter(event.get_character()); } return; diff --git a/modules/engine/src/layer/layer.cpp b/modules/engine/src/layer/layer.cpp index 8969d84..db9a43f 100644 --- a/modules/engine/src/layer/layer.cpp +++ b/modules/engine/src/layer/layer.cpp @@ -11,36 +11,36 @@ Layer::Layer(const std::string &name): m_layer_name(name) { } -bool Layer::OnEvent(const Event &event) +bool Layer::on_event(const Event &event) { - switch (event.GetEventType()) + switch (event.get_event_type()) { /* mouse */ // cursor - case EventType::MouseMoved: return OnMouseMoved((MouseMovedEvent &)event); + case EventType::MouseMoved: return on_mouse_moved((MouseMovedEvent &)event); // button - case EventType::ButtonPressed: return OnButtonPressed((ButtonPressedEvent &)event); - case EventType::ButtonReleased: return OnButtonReleased((ButtonReleasedEvent &)event); + case EventType::ButtonPressed: return on_button_pressed((ButtonPressedEvent &)event); + case EventType::ButtonReleased: return on_button_released((ButtonReleasedEvent &)event); // wheel - case EventType::WheelScrolled: return OnWheelScrolled((WheelScrolledEvent &)event); + case EventType::WheelScrolled: return on_wheel_scrolled((WheelScrolledEvent &)event); /* keyboard */ // key - case EventType::KeyPressed: return OnKeyPressed((KeyPressedEvent &)event); - case EventType::KeyRepeated: return OnKeyRepeat((KeyRepeatEvent &)event); - case EventType::KeyReleased: return OnKeyReleased((KeyReleasedEvent &)event); + case EventType::KeyPressed: return on_key_pressed((KeyPressedEvent &)event); + case EventType::KeyRepeated: return on_key_repeat((KeyRepeatEvent &)event); + case EventType::KeyReleased: return on_key_released((KeyReleasedEvent &)event); // char - case EventType::SetChar: return OnSetChar((SetCharEvent &)event); + case EventType::SetChar: return on_set_char((SetCharEvent &)event); /* window */ // termination - case EventType::WindowClosed: return OnWindowClosed((WindowClosedEvent &)event); + case EventType::WindowClosed: return on_window_closed((WindowClosedEvent &)event); // size/position - case EventType::WindowResized: return OnWindowResized((WindowResizedEvent &)event); - case EventType::WindowMoved: return OnWindowMoved((WindowMovedEvent &)event); + case EventType::WindowResized: return on_window_resized((WindowResizedEvent &)event); + case EventType::WindowMoved: return on_window_moved((WindowMovedEvent &)event); // focus - case EventType::WindowLostFocus: return OnWindowLostFocus((WindowLostFocusEvent &)event); - case EventType::WindowGainFocus: return OnWindowGainFocus((WindowGainFocusEvent &)event); + case EventType::WindowLostFocus: return on_window_lost_focus((WindowLostFocusEvent &)event); + case EventType::WindowGainFocus: return on_window_gain_focus((WindowGainFocusEvent &)event); } } diff --git a/modules/engine/src/layer/layer_stack.cpp b/modules/engine/src/layer/layer_stack.cpp index cbac910..31e114c 100644 --- a/modules/engine/src/layer/layer_stack.cpp +++ b/modules/engine/src/layer/layer_stack.cpp @@ -9,15 +9,18 @@ namespace Light { LayerStack *LayerStack::s_Context = nullptr; -Scope LayerStack::Create() +Scope LayerStack::create() { - return MakeScope(new LayerStack()); + return make_scope(new LayerStack()); } LayerStack::LayerStack(): m_layers {}, m_begin(), m_end() { - ASSERT(!s_Context, "An instance of 'LayerStack' already exists, do not construct this class!") - s_Context = this; + lt_assert( + !s_Context, + "An instance of 'LayerStack' already exists, do not construct this class!" + ) s_Context + = this; } LayerStack::~LayerStack() @@ -26,24 +29,24 @@ LayerStack::~LayerStack() delete layer; } -void LayerStack::AttachLayerImpl(Layer *layer) +void LayerStack::attach_layer_impl(Layer *layer) { // #todo: handle attaching layer inside a for loop m_layers.push_back(layer); m_begin = m_layers.begin(); m_end = m_layers.end(); - LOG(trace, "Attached [{}]", layer->GetName()); + lt_log(trace, "Attached [{}]", layer->GetName()); } -void LayerStack::DetachLayerImpl(Layer *layer) +void LayerStack::detach_layer_impl(Layer *layer) { // #todo: handle detaching layer inside a for loop m_layers.erase(std::find(m_layers.begin(), m_layers.end(), layer)); m_begin = m_layers.begin(); m_end = m_layers.end(); - LOG(trace, "Detached [{}]", layer->GetName()); + lt_log(trace, "Detached [{}]", layer->GetName()); } } // namespace Light diff --git a/modules/engine/src/math/random.cpp b/modules/engine/src/math/random.cpp index 9d64c7a..7abff6f 100644 --- a/modules/engine/src/math/random.cpp +++ b/modules/engine/src/math/random.cpp @@ -4,36 +4,36 @@ namespace Light { namespace Math { -float Rand(int min, int max, int decimals /* = 0 */) +float rand(int min, int max, int decimals /* = 0 */) { const int dec = std::pow(10, decimals); min *= dec; max *= dec; - return (min + (rand() % (max)-min)) / (float)dec; + return (min + (::rand() % (max)-min)) / (float)dec; } -glm::vec2 RandVec2(int min, int max, int decimals /* = 0 */) +glm::vec2 rand_vec2(int min, int max, int decimals /* = 0 */) { const int dec = std::pow(10, decimals); min *= dec; max *= dec; - float r1 = (min + (rand() % (max)-min)) / (float)dec; - float r2 = (min + (rand() % (max)-min)) / (float)dec; + float r1 = (min + (::rand() % (max)-min)) / (float)dec; + float r2 = (min + (::rand() % (max)-min)) / (float)dec; return glm::vec2(r1, r2); } -glm::vec3 RandVec3(int min, int max, int decimals /* = 0 */) +glm::vec3 rand_vec3(int min, int max, int decimals /* = 0 */) { const int dec = std::pow(10, decimals); min *= dec; max *= dec; - float r1 = (min + (rand() % (max - min))) / (float)dec; - float r2 = (min + (rand() % (max - min))) / (float)dec; - float r3 = (min + (rand() % (max - min))) / (float)dec; + float r1 = (min + (::rand() % (max - min))) / (float)dec; + float r2 = (min + (::rand() % (max - min))) / (float)dec; + float r3 = (min + (::rand() % (max - min))) / (float)dec; return glm::vec3(r1, r2, r3); } diff --git a/modules/engine/src/platform/graphics/directx/blender.cpp b/modules/engine/src/platform/graphics/directx/blender.cpp index 63aa69c..c01a6b7 100644 --- a/modules/engine/src/platform/graphics/directx/blender.cpp +++ b/modules/engine/src/platform/graphics/directx/blender.cpp @@ -47,10 +47,10 @@ dxBlender::dxBlender(Ref sharedContext) // create blend state HRESULT hr; - DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_blend_state)); + dxc(m_context->get_device()->CreateBlendState(&m_desc, &m_blend_state)); } -void dxBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) +void dxBlender::enable(BlendFactor srcFactor, BlendFactor dstFactor) { // update desc m_desc.RenderTarget[0].BlendEnable = true; @@ -59,23 +59,23 @@ void dxBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) // re-create blind state HRESULT hr; - DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_blend_state)); + dxc(m_context->get_device()->CreateBlendState(&m_desc, &m_blend_state)); // bind blend state - m_context->GetDeviceContext()->OMSetBlendState(m_blend_state.Get(), nullptr, 0x0000000f); + m_context->get_device_context()->OMSetBlendState(m_blend_state.Get(), nullptr, 0x0000000f); } -void dxBlender::Disable() +void dxBlender::disable() { // update desc m_desc.RenderTarget[0].BlendEnable = false; // re-create blind state HRESULT hr; - DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_blend_state)); + dxc(m_context->get_device()->CreateBlendState(&m_desc, &m_blend_state)); // bind blend state - m_context->GetDeviceContext()->OMSetBlendState(m_blend_state.Get(), nullptr, 0xffffffff); + m_context->get_device_context()->OMSetBlendState(m_blend_state.Get(), nullptr, 0xffffffff); } } // namespace Light diff --git a/modules/engine/src/platform/graphics/directx/buffers.cpp b/modules/engine/src/platform/graphics/directx/buffers.cpp index 8c22ce3..22a57b2 100644 --- a/modules/engine/src/platform/graphics/directx/buffers.cpp +++ b/modules/engine/src/platform/graphics/directx/buffers.cpp @@ -23,25 +23,25 @@ dxConstantBuffer::dxConstantBuffer( bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; HRESULT hr; - DXC(m_context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_buffer)); - m_context->GetDeviceContext()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf()); + dxc(m_context->get_device()->CreateBuffer(&bDesc, nullptr, &m_buffer)); + m_context->get_device_context()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf()); } -void dxConstantBuffer::Bind() +void dxConstantBuffer::bind() { - m_context->GetDeviceContext()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf()); + m_context->get_device_context()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf()); } -void *dxConstantBuffer::Map() +void *dxConstantBuffer::map() { - m_context->GetDeviceContext()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf()); - m_context->GetDeviceContext()->Map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map); + m_context->get_device_context()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf()); + m_context->get_device_context()->map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map); return m_map.pData; } -void dxConstantBuffer::UnMap() +void dxConstantBuffer::un_map() { - m_context->GetDeviceContext()->Unmap(m_buffer.Get(), NULL); + m_context->get_device_context()->Unmap(m_buffer.Get(), NULL); } //======================================== CONSTANT_BUFFER //========================================// @@ -71,38 +71,38 @@ dxVertexBuffer::dxVertexBuffer( // create buffer HRESULT hr; - DXC(m_context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_buffer)); + dxc(m_context->get_device()->CreateBuffer(&bDesc, nullptr, &m_buffer)); } dxVertexBuffer::~dxVertexBuffer() { - UnBind(); + un_bind(); } -void *dxVertexBuffer::Map() +void *dxVertexBuffer::map() { - m_context->GetDeviceContext()->Map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map); + m_context->get_device_context()->map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map); return m_map.pData; } -void dxVertexBuffer::UnMap() +void dxVertexBuffer::un_map() { - m_context->GetDeviceContext()->Unmap(m_buffer.Get(), NULL); + m_context->get_device_context()->Unmap(m_buffer.Get(), NULL); } -void dxVertexBuffer::Bind() +void dxVertexBuffer::bind() { static const unsigned int offset = 0u; - m_context->GetDeviceContext() + m_context->get_device_context() ->IASetVertexBuffers(0u, 1u, m_buffer.GetAddressOf(), &m_stride, &offset); } -void dxVertexBuffer::UnBind() +void dxVertexBuffer::un_bind() { static const unsigned int offset = 0u; static ID3D11Buffer *buffer = nullptr; - m_context->GetDeviceContext()->IASetVertexBuffers(0u, 1u, &buffer, &m_stride, &offset); + m_context->get_device_context()->IASetVertexBuffers(0u, 1u, &buffer, &m_stride, &offset); } //================================================== VERTEX_BUFFER //==================================================// @@ -123,8 +123,8 @@ dxIndexBuffer::dxIndexBuffer( // check if (count % 6 != 0) { - LOG(warn, "'indices' can only be null if count is multiple of 6"); - LOG(warn, "Adding {} to 'count' -> {}", (6 - (count % 6)), count + (6 - (count % 6))); + lt_log(warn, "'indices' can only be null if count is multiple of 6"); + lt_log(warn, "Adding {} to 'count' -> {}", (6 - (count % 6)), count + (6 - (count % 6))); count = count + (6 - (count % 6)); } @@ -159,7 +159,7 @@ dxIndexBuffer::dxIndexBuffer( // create buffer HRESULT hr; - DXC(m_context->GetDevice()->CreateBuffer(&bDesc, &sDesc, &m_buffer)); + dxc(m_context->get_device()->CreateBuffer(&bDesc, &sDesc, &m_buffer)); // delete indices if (!hasIndices) @@ -168,20 +168,20 @@ dxIndexBuffer::dxIndexBuffer( dxIndexBuffer::~dxIndexBuffer() { - UnBind(); + un_bind(); } -void dxIndexBuffer::Bind() +void dxIndexBuffer::bind() { - m_context->GetDeviceContext()->IASetIndexBuffer(m_buffer.Get(), DXGI_FORMAT_R32_UINT, 0u); + m_context->get_device_context()->IASetIndexBuffer(m_buffer.Get(), DXGI_FORMAT_R32_UINT, 0u); } -void dxIndexBuffer::UnBind() +void dxIndexBuffer::un_bind() { static const unsigned int offset = 0u; static ID3D11Buffer *buffer = nullptr; - m_context->GetDeviceContext()->IASetIndexBuffer(buffer, DXGI_FORMAT_R32_UINT, offset); + m_context->get_device_context()->IASetIndexBuffer(buffer, DXGI_FORMAT_R32_UINT, offset); } //======================================== INDEX_BUFFER ========================================// diff --git a/modules/engine/src/platform/graphics/directx/framebuffers.cpp b/modules/engine/src/platform/graphics/directx/framebuffers.cpp index 2709424..25b5a90 100644 --- a/modules/engine/src/platform/graphics/directx/framebuffers.cpp +++ b/modules/engine/src/platform/graphics/directx/framebuffers.cpp @@ -29,25 +29,25 @@ dxFramebuffer::dxFramebuffer( t2dDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; t2dDesc.CPUAccessFlags = NULL; t2dDesc.MiscFlags = NULL; - DXC(m_context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_color_attachment)); + dxc(m_context->get_device()->CreateTexture2D(&t2dDesc, nullptr, &m_color_attachment)); D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.Format = t2dDesc.Format; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MipLevels = 1; srvDesc.Texture2D.MostDetailedMip = 0; - DXC(m_context->GetDevice() + dxc(m_context->get_device() ->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view)); D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {}; rtvDesc.Format = t2dDesc.Format; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.Texture2D.MipSlice = 0u; - DXC(m_context->GetDevice() + dxc(m_context->get_device() ->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view)); } -void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor) +void dxFramebuffer::bind_as_target(const glm::vec4 &clearColor) { FLOAT color[] = { clearColor.r, @@ -56,9 +56,9 @@ void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor) clearColor.a, }; - m_context->GetDeviceContext() + m_context->get_device_context() ->OMSetRenderTargets(1u, m_render_target_view.GetAddressOf(), nullptr); - m_context->GetDeviceContext()->ClearRenderTargetView(m_render_target_view.Get(), color); + m_context->get_device_context()->ClearRenderTargetView(m_render_target_view.Get(), color); D3D11_VIEWPORT viewport; @@ -72,15 +72,15 @@ void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor) viewport.MaxDepth = 1.0f; // set viewport - m_context->GetDeviceContext()->RSSetViewports(1u, &viewport); + m_context->get_device_context()->RSSetViewports(1u, &viewport); } -void dxFramebuffer::BindAsResource() +void dxFramebuffer::bind_as_resource() { - LOG(err, "NO_IMPLEMENT"); + lt_log(err, "NO_IMPLEMENT"); } -void dxFramebuffer::Resize(const glm::uvec2 &size) +void dxFramebuffer::resize(const glm::uvec2 &size) { m_specification.width = std::clamp(size.x, 1u, 16384u); m_specification.height = std::clamp(size.y, 1u, 16384u); @@ -97,10 +97,10 @@ void dxFramebuffer::Resize(const glm::uvec2 &size) textureDesc.Height = m_specification.height; HRESULT hr; - DXC(m_context->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &m_color_attachment)); - DXC(m_context->GetDevice() + dxc(m_context->get_device()->CreateTexture2D(&textureDesc, nullptr, &m_color_attachment)); + dxc(m_context->get_device() ->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view)); - DXC(m_context->GetDevice() + dxc(m_context->get_device() ->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view)); } diff --git a/modules/engine/src/platform/graphics/directx/graphics_context.cpp b/modules/engine/src/platform/graphics/directx/graphics_context.cpp index 6ffab12..b10205e 100644 --- a/modules/engine/src/platform/graphics/directx/graphics_context.cpp +++ b/modules/engine/src/platform/graphics/directx/graphics_context.cpp @@ -24,12 +24,12 @@ dxGraphicsContext::dxGraphicsContext(GLFWwindow *windowHandle) m_shared_context = std::make_shared(); // setup stuff - SetupDeviceAndSwapChain(windowHandle); - SetupRenderTargets(); - SetupDebugInterface(); + setup_device_and_swap_chain(windowHandle); + setup_render_targets(); + setup_debug_interface(); } -void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle) +void dxGraphicsContext::setup_device_and_swap_chain(GLFWwindow *windowHandle) { Ref context = std::static_pointer_cast(m_shared_context); @@ -68,7 +68,7 @@ void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle) #endif // create device and swap chain - DXC(D3D11CreateDeviceAndSwapChain( + dxc(D3D11CreateDeviceAndSwapChain( nullptr, D3D_DRIVER_TYPE_HARDWARE, NULL, @@ -84,37 +84,37 @@ void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle) )); } -void dxGraphicsContext::SetupRenderTargets() +void dxGraphicsContext::setup_render_targets() { Ref context = std::static_pointer_cast(m_shared_context); // set primitive topology - context->GetDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + context->get_device_context()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // create render target view Microsoft::WRL::ComPtr backBuffer; - DXC(context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); - DXC(context->GetDevice() + dxc(context->get_swap_chain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); + dxc(context->get_device() ->CreateRenderTargetView(backBuffer.Get(), nullptr, &context->GetRenderTargetViewRef()) ); // set render target view - context->GetDeviceContext() - ->OMSetRenderTargets(1u, context->GetRenderTargetView().GetAddressOf(), nullptr); + context->get_device_context() + ->OMSetRenderTargets(1u, context->get_render_target_view().GetAddressOf(), nullptr); } -void dxGraphicsContext::SetupDebugInterface() +void dxGraphicsContext::setup_debug_interface() { #ifdef LIGHT_DEBUG Ref context = std::static_pointer_cast(m_shared_context); HRESULT hr; Microsoft::WRL::ComPtr debugInterface = nullptr; - DXC(context->GetDevice()->QueryInterface(__uuidof(ID3D11Debug), &debugInterface)); + dxc(context->get_device()->QueryInterface(__uuidof(ID3D11Debug), &debugInterface)); Microsoft::WRL::ComPtr infoQueue = nullptr; - DXC(debugInterface->QueryInterface(__uuidof(ID3D11InfoQueue), &infoQueue)); + dxc(debugInterface->QueryInterface(__uuidof(ID3D11InfoQueue), &infoQueue)); infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true); infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true); @@ -128,11 +128,11 @@ void dxGraphicsContext::SetupDebugInterface() filter.DenyList.NumIDs = _countof(hide); filter.DenyList.pIDList = hide; infoQueue->AddStorageFilterEntries(&filter); - infoQueue->Release(); + infoQueue->release(); #endif } -void dxGraphicsContext::LogDebugData() +void dxGraphicsContext::log_debug_data() { Ref context = std::static_pointer_cast(m_shared_context); @@ -141,7 +141,7 @@ void dxGraphicsContext::LogDebugData() IDXGIAdapter *DXGIAdapter; DXGI_ADAPTER_DESC DXGIAdapterDesc; - context->GetDevice()->QueryInterface(__uuidof(IDXGIDevice), (void **)&DXGIDevice); + context->get_device()->QueryInterface(__uuidof(IDXGIDevice), (void **)&DXGIDevice); DXGIDevice->GetAdapter(&DXGIAdapter); DXGIAdapter->GetDesc(&DXGIAdapterDesc); @@ -152,14 +152,14 @@ void dxGraphicsContext::LogDebugData() std::string adapterDesc(ch); // release memory - DXGIDevice->Release(); - DXGIAdapter->Release(); + DXGIDevice->release(); + DXGIAdapter->release(); // #todo: log more information - LOG(info, "________________________________________"); - LOG(info, "dxGraphicsContext:"); - LOG(info, " Renderer: {}", adapterDesc); - LOG(info, "________________________________________"); + lt_log(info, "________________________________________"); + lt_log(info, "dxGraphicsContext:"); + lt_log(info, " renderer: {}", adapterDesc); + lt_log(info, "________________________________________"); } } // namespace Light diff --git a/modules/engine/src/platform/graphics/directx/render_command.cpp b/modules/engine/src/platform/graphics/directx/render_command.cpp index c86996a..3c36f2b 100644 --- a/modules/engine/src/platform/graphics/directx/render_command.cpp +++ b/modules/engine/src/platform/graphics/directx/render_command.cpp @@ -7,49 +7,49 @@ dxRenderCommand::dxRenderCommand(Ref sharedContext): m_context( { } -void dxRenderCommand::SwapBuffers() +void dxRenderCommand::swap_buffers() { #ifdef LIGHT_DEBUG HRESULT hr; - if (FAILED(hr = m_context->GetSwapChain()->Present(1u, 0u))) + if (FAILED(hr = m_context->get_swap_chain()->Present(1u, 0u))) { if (hr == DXGI_ERROR_DEVICE_REMOVED) { - LOG(critical, "dxRenderCommand::SwapBuffers: DeviceRemoved:"); - LOG(critical, " {}", m_context->GetDevice()->GetDeviceRemovedReason()); + lt_log(critical, "dxRenderCommand::swap_buffers: DeviceRemoved:"); + lt_log(critical, " {}", m_context->get_device()->GetDeviceRemovedReason()); throw dxException(hr, __FILE__, __LINE__); } } #else - m_context->GetSwapChain()->Present(0u, 0u); + m_context->get_swap_chain()->Present(0u, 0u); #endif } -void dxRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor) +void dxRenderCommand::clear_back_buffer(const glm::vec4 &clearColor) { - m_context->GetDeviceContext()->ClearRenderTargetView( - m_context->GetRenderTargetView().Get(), + m_context->get_device_context()->ClearRenderTargetView( + m_context->get_render_target_view().Get(), &clearColor[0] ); } -void dxRenderCommand::Draw(unsigned int count) +void dxRenderCommand::draw(unsigned int count) { - m_context->GetDeviceContext()->Draw(count, 0u); + m_context->get_device_context()->draw(count, 0u); } -void dxRenderCommand::DrawIndexed(unsigned int count) +void dxRenderCommand::draw_indexed(unsigned int count) { - m_context->GetDeviceContext()->DrawIndexed(count, 0u, 0u); + m_context->get_device_context()->draw_indexed(count, 0u, 0u); } -void dxRenderCommand::DefaultTargetFramebuffer() +void dxRenderCommand::default_target_framebuffer() { - m_context->GetDeviceContext() - ->OMSetRenderTargets(1, m_context->GetRenderTargetView().GetAddressOf(), nullptr); + m_context->get_device_context() + ->OMSetRenderTargets(1, m_context->get_render_target_view().GetAddressOf(), nullptr); } -void dxRenderCommand::SetViewport( +void dxRenderCommand::set_viewport( unsigned int x, unsigned int y, unsigned int width, @@ -57,7 +57,7 @@ void dxRenderCommand::SetViewport( ) { // #todo: maybe call this somewhere else?? - SetResolution(width, height); + set_resolution(width, height); // create viewport D3D11_VIEWPORT viewport; @@ -72,34 +72,34 @@ void dxRenderCommand::SetViewport( viewport.MaxDepth = 1.0f; // set viewport - m_context->GetDeviceContext()->RSSetViewports(1u, &viewport); + m_context->get_device_context()->RSSetViewports(1u, &viewport); } -void dxRenderCommand::SetResolution(unsigned int width, unsigned int height) +void dxRenderCommand::set_resolution(unsigned int width, unsigned int height) { HRESULT hr; // remove render target ID3D11RenderTargetView *nullViews[] = { nullptr }; - m_context->GetDeviceContext()->OMSetRenderTargets(1u, nullViews, nullptr); - m_context->GetRenderTargetViewRef().Reset(); + m_context->get_device_context()->OMSetRenderTargets(1u, nullViews, nullptr); + m_context->GetRenderTargetViewRef().reset(); // resize buffer - DXC(m_context->GetSwapChain() + dxc(m_context->get_swap_chain() ->ResizeBuffers(0u, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, NULL)); // create render target Microsoft::WRL::ComPtr backBuffer = nullptr; - DXC(m_context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); - DXC(m_context->GetDevice()->CreateRenderTargetView( + dxc(m_context->get_swap_chain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); + dxc(m_context->get_device()->CreateRenderTargetView( backBuffer.Get(), nullptr, &m_context->GetRenderTargetViewRef() )); // set render target - m_context->GetDeviceContext() - ->OMSetRenderTargets(1u, m_context->GetRenderTargetView().GetAddressOf(), nullptr); + m_context->get_device_context() + ->OMSetRenderTargets(1u, m_context->get_render_target_view().GetAddressOf(), nullptr); } } // namespace Light diff --git a/modules/engine/src/platform/graphics/directx/shader.cpp b/modules/engine/src/platform/graphics/directx/shader.cpp index 6185ece..1da40f3 100644 --- a/modules/engine/src/platform/graphics/directx/shader.cpp +++ b/modules/engine/src/platform/graphics/directx/shader.cpp @@ -5,8 +5,8 @@ namespace Light { dxShader::dxShader( - BasicFileHandle vertexFile, - BasicFileHandle pixelFile, + basic_file_handle vertexFile, + basic_file_handle pixelFile, Ref sharedContext ) : m_context(sharedContext) @@ -16,11 +16,11 @@ dxShader::dxShader( { Microsoft::WRL::ComPtr ps = nullptr, vsErr = nullptr, psErr = nullptr; - // compile shaders (we don't use DXC here because if D3DCompile fails it throws a dxException + // compile shaders (we don't use dxc here because if d3_d_compile fails it throws a dxException // without logging the vsErr/psErr - D3DCompile( + d3_d_compile( vertexFile.GetData(), - vertexFile.GetSize(), + vertexFile.get_size(), NULL, nullptr, nullptr, @@ -31,9 +31,9 @@ dxShader::dxShader( &m_vertex_blob, &vsErr ); - D3DCompile( + d3_d_compile( pixelFile.GetData(), - pixelFile.GetSize(), + pixelFile.get_size(), NULL, nullptr, nullptr, @@ -46,36 +46,36 @@ dxShader::dxShader( ); // check - ASSERT(!vsErr.Get(), "Vertex shader compile error: {}", (char *)vsErr->GetBufferPointer()); - ASSERT(!psErr.Get(), "Pixels shader compile error: {}", (char *)psErr->GetBufferPointer()); + lt_assert(!vsErr.Get(), "Vertex shader compile error: {}", (char *)vsErr->GetBufferPointer()); + lt_assert(!psErr.Get(), "Pixels shader compile error: {}", (char *)psErr->GetBufferPointer()); // create shaders HRESULT hr; - DXC(m_context->GetDevice()->CreateVertexShader( + dxc(m_context->get_device()->CreateVertexShader( m_vertex_blob->GetBufferPointer(), m_vertex_blob->GetBufferSize(), NULL, &m_vertex_shader )); - DXC(m_context->GetDevice() + dxc(m_context->get_device() ->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_pixel_shader)); } dxShader::~dxShader() { - UnBind(); + un_bind(); } -void dxShader::Bind() +void dxShader::bind() { - m_context->GetDeviceContext()->VSSetShader(m_vertex_shader.Get(), nullptr, 0u); - m_context->GetDeviceContext()->PSSetShader(m_pixel_shader.Get(), nullptr, 0u); + m_context->get_device_context()->VSSetShader(m_vertex_shader.Get(), nullptr, 0u); + m_context->get_device_context()->PSSetShader(m_pixel_shader.Get(), nullptr, 0u); } -void dxShader::UnBind() +void dxShader::un_bind() { - m_context->GetDeviceContext()->VSSetShader(nullptr, nullptr, 0u); - m_context->GetDeviceContext()->PSSetShader(nullptr, nullptr, 0u); + m_context->get_device_context()->VSSetShader(nullptr, nullptr, 0u); + m_context->get_device_context()->PSSetShader(nullptr, nullptr, 0u); } } // namespace Light diff --git a/modules/engine/src/platform/graphics/directx/texture.cpp b/modules/engine/src/platform/graphics/directx/texture.cpp index 138127f..5ce2e97 100644 --- a/modules/engine/src/platform/graphics/directx/texture.cpp +++ b/modules/engine/src/platform/graphics/directx/texture.cpp @@ -38,8 +38,8 @@ dxTexture::dxTexture( // create texture HRESULT hr; - DXC(m_context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_texture_2d)); - m_context->GetDeviceContext() + dxc(m_context->get_device()->CreateTexture2D(&t2dDesc, nullptr, &m_texture_2d)); + m_context->get_device_context() ->UpdateSubresource(m_texture_2d.Get(), 0u, nullptr, pixels, width * 4u, 0u); m_texture_2d->GetDesc(&t2dDesc); @@ -52,9 +52,9 @@ dxTexture::dxTexture( srvDesc.Texture2D.MipLevels = -1; // create shader resource view - m_context->GetDevice() + m_context->get_device() ->CreateShaderResourceView(m_texture_2d.Get(), &srvDesc, &m_shader_resource_view); - m_context->GetDeviceContext()->GenerateMips(m_shader_resource_view.Get()); + m_context->get_device_context()->GenerateMips(m_shader_resource_view.Get()); // sampler desc D3D11_SAMPLER_DESC sDesc = {}; @@ -67,13 +67,13 @@ dxTexture::dxTexture( sDesc.MaxLOD = D3D11_FLOAT32_MAX; // create sampler - m_context->GetDevice()->CreateSamplerState(&sDesc, &m_sampler_state); + m_context->get_device()->CreateSamplerState(&sDesc, &m_sampler_state); } -void dxTexture::Bind(unsigned int slot /* = 0u */) +void dxTexture::bind(unsigned int slot /* = 0u */) { - m_context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_sampler_state.GetAddressOf()); - m_context->GetDeviceContext() + m_context->get_device_context()->PSSetSamplers(slot, 1u, m_sampler_state.GetAddressOf()); + m_context->get_device_context() ->PSSetShaderResources(slot, 1u, m_shader_resource_view.GetAddressOf()); } diff --git a/modules/engine/src/platform/graphics/directx/user_interface.cpp b/modules/engine/src/platform/graphics/directx/user_interface.cpp index 3c1cf8d..a02a6c7 100644 --- a/modules/engine/src/platform/graphics/directx/user_interface.cpp +++ b/modules/engine/src/platform/graphics/directx/user_interface.cpp @@ -11,7 +11,7 @@ namespace Light { -void dxUserInterface::PlatformImplementation( +void dxUserInterface::platform_implementation( GLFWwindow *windowHandle, Ref sharedContext ) @@ -20,7 +20,7 @@ void dxUserInterface::PlatformImplementation( Ref context = std::dynamic_pointer_cast(sharedContext); ImGui_ImplWin32_Init(glfwGetWin32Window(windowHandle)); - ImGui_ImplDX11_Init(context->GetDevice().Get(), context->GetDeviceContext().Get()); + ImGui_ImplDX11_Init(context->get_device().Get(), context->get_device_context().Get()); } dxUserInterface::~dxUserInterface() @@ -36,14 +36,14 @@ dxUserInterface::~dxUserInterface() ImGui::DestroyContext(); } -void dxUserInterface::Begin() +void dxUserInterface::begin() { ImGui_ImplDX11_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); } -void dxUserInterface::End() +void dxUserInterface::end() { ImGui::Render(); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); @@ -52,15 +52,15 @@ void dxUserInterface::End() ImGui::RenderPlatformWindowsDefault(); } -void dxUserInterface::LogDebugData() +void dxUserInterface::log_debug_data() { // #todo: improve - LOG(info, "________________________________________"); - LOG(info, "UserInterface::"); - LOG(info, " API : ImGui"); - LOG(info, " Version: {}", ImGui::GetVersion()); - LOG(info, " GraphicsAPI : DirectX"); - LOG(info, "________________________________________"); + lt_log(info, "________________________________________"); + lt_log(info, "UserInterface::"); + lt_log(info, " API : ImGui"); + lt_log(info, " Version: {}", ImGui::GetVersion()); + lt_log(info, " GraphicsAPI : DirectX"); + lt_log(info, "________________________________________"); } } // namespace Light diff --git a/modules/engine/src/platform/graphics/directx/vertex_layout.cpp b/modules/engine/src/platform/graphics/directx/vertex_layout.cpp index b64db5d..1dff7c9 100644 --- a/modules/engine/src/platform/graphics/directx/vertex_layout.cpp +++ b/modules/engine/src/platform/graphics/directx/vertex_layout.cpp @@ -21,7 +21,7 @@ dxVertexLayout::dxVertexLayout( { inputElementsDesc.emplace_back(D3D11_INPUT_ELEMENT_DESC { element.first.c_str(), NULL, - GetDxgiFormat(element.second), + get_dxgi_format(element.second), 0u, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, @@ -29,35 +29,35 @@ dxVertexLayout::dxVertexLayout( } Ref dxpShader = std::dynamic_pointer_cast(shader); - ASSERT(dxpShader, "Failed to cast 'Shader' to 'dxShader'"); + lt_assert(dxpShader, "Failed to cast 'Shader' to 'dxShader'"); // create input layout (vertex layout) HRESULT hr; - DXC(m_context->GetDevice()->CreateInputLayout( + dxc(m_context->get_device()->CreateInputLayout( &inputElementsDesc[0], inputElementsDesc.size(), - dxpShader->GetVertexBlob().Get()->GetBufferPointer(), - dxpShader->GetVertexBlob().Get()->GetBufferSize(), + dxpShader->get_vertex_blob().Get()->GetBufferPointer(), + dxpShader->get_vertex_blob().Get()->GetBufferSize(), &m_input_layout )); } dxVertexLayout::~dxVertexLayout() { - UnBind(); + un_bind(); } -void dxVertexLayout::Bind() +void dxVertexLayout::bind() { - m_context->GetDeviceContext()->IASetInputLayout(m_input_layout.Get()); + m_context->get_device_context()->IASetInputLayout(m_input_layout.Get()); } -void dxVertexLayout::UnBind() +void dxVertexLayout::un_bind() { - m_context->GetDeviceContext()->IASetInputLayout(nullptr); + m_context->get_device_context()->IASetInputLayout(nullptr); } -DXGI_FORMAT dxVertexLayout::GetDxgiFormat(VertexElementType type) +DXGI_FORMAT dxVertexLayout::get_dxgi_format(VertexElementType type) { switch (type) { @@ -89,7 +89,7 @@ DXGI_FORMAT dxVertexLayout::GetDxgiFormat(VertexElementType type) case Light::VertexElementType::Float3: return DXGI_FORMAT_R32G32B32_FLOAT; case Light::VertexElementType::Float4: return DXGI_FORMAT_R32G32B32A32_FLOAT; - default: ASSERT(false, "Invalid 'VertexElementType'"); return DXGI_FORMAT_UNKNOWN; + default: lt_assert(false, "Invalid 'VertexElementType'"); return DXGI_FORMAT_UNKNOWN; } } diff --git a/modules/engine/src/platform/graphics/opengl/blender.cpp b/modules/engine/src/platform/graphics/opengl/blender.cpp index 6ca4ebc..19e66c8 100644 --- a/modules/engine/src/platform/graphics/opengl/blender.cpp +++ b/modules/engine/src/platform/graphics/opengl/blender.cpp @@ -32,13 +32,13 @@ glBlender::glBlender() { } -void glBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) +void glBlender::enable(BlendFactor srcFactor, BlendFactor dstFactor) { glEnable(GL_BLEND); glBlendFunc(m_factor_map.at(srcFactor), m_factor_map.at(dstFactor)); } -void glBlender::Disable() +void glBlender::disable() { glDisable(GL_BLEND); } diff --git a/modules/engine/src/platform/graphics/opengl/buffers.cpp b/modules/engine/src/platform/graphics/opengl/buffers.cpp index 6f42851..a9cfec8 100644 --- a/modules/engine/src/platform/graphics/opengl/buffers.cpp +++ b/modules/engine/src/platform/graphics/opengl/buffers.cpp @@ -11,7 +11,7 @@ glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size) glCreateBuffers(1, &m_buffer_id); glNamedBufferData(m_buffer_id, size, nullptr, GL_DYNAMIC_DRAW); - Bind(); + bind(); } glConstantBuffer::~glConstantBuffer() @@ -19,18 +19,18 @@ glConstantBuffer::~glConstantBuffer() glDeleteBuffers(1, &m_buffer_id); } -void glConstantBuffer::Bind() +void glConstantBuffer::bind() { glBindBufferBase(GL_UNIFORM_BUFFER, m_index, m_buffer_id); } -void *glConstantBuffer::Map() +void *glConstantBuffer::map() { void *map = glMapNamedBuffer(m_buffer_id, GL_WRITE_ONLY); return map; } -void glConstantBuffer::UnMap() +void glConstantBuffer::un_map() { glUnmapNamedBuffer(m_buffer_id); } @@ -49,22 +49,22 @@ glVertexBuffer::~glVertexBuffer() glDeleteBuffers(1, &m_buffer_id); } -void glVertexBuffer::Bind() +void glVertexBuffer::bind() { glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id); } -void glVertexBuffer::UnBind() +void glVertexBuffer::un_bind() { glBindBuffer(GL_ARRAY_BUFFER, NULL); } -void *glVertexBuffer::Map() +void *glVertexBuffer::map() { return glMapNamedBuffer(m_buffer_id, GL_WRITE_ONLY); } -void glVertexBuffer::UnMap() +void glVertexBuffer::un_map() { glUnmapNamedBuffer(m_buffer_id); } @@ -80,8 +80,8 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffe // check if (count % 6 != 0) { - LOG(warn, "'indices' can only be null if count is multiple of 6"); - LOG(warn, "Adding {} to 'count' -> {}", (6 - (count % 6)), count + (6 - (count % 6))); + lt_log(warn, "'indices' can only be null if count is multiple of 6"); + lt_log(warn, "Adding {} to 'count' -> {}", (6 - (count % 6)), count + (6 - (count % 6))); count = count + (6 - (count % 6)); } @@ -116,12 +116,12 @@ glIndexBuffer::~glIndexBuffer() glDeleteBuffers(1, &m_buffer_id); } -void glIndexBuffer::Bind() +void glIndexBuffer::bind() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer_id); } -void glIndexBuffer::UnBind() +void glIndexBuffer::un_bind() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, NULL); } diff --git a/modules/engine/src/platform/graphics/opengl/framebuffers.cpp b/modules/engine/src/platform/graphics/opengl/framebuffers.cpp index 034abab..3b62719 100644 --- a/modules/engine/src/platform/graphics/opengl/framebuffers.cpp +++ b/modules/engine/src/platform/graphics/opengl/framebuffers.cpp @@ -10,7 +10,7 @@ glFramebuffer::glFramebuffer(const FramebufferSpecification &specification) , m_color_attachment_id(NULL) , m_depth_stencil_attachment_id(NULL) { - Resize({ specification.width, specification.height }); + resize({ specification.width, specification.height }); } glFramebuffer::~glFramebuffer() @@ -20,7 +20,7 @@ glFramebuffer::~glFramebuffer() // glDeleteTextures(1, &m_depth_stencil_attachment_id); } -void glFramebuffer::BindAsTarget(const glm::vec4 &clearColor) +void glFramebuffer::bind_as_target(const glm::vec4 &clearColor) { // #todo: use viewport instead of default x=0, y=0 glBindFramebuffer(GL_FRAMEBUFFER, m_buffer_id); @@ -30,12 +30,12 @@ void glFramebuffer::BindAsTarget(const glm::vec4 &clearColor) glClear(GL_COLOR_BUFFER_BIT); } -void glFramebuffer::BindAsResource() +void glFramebuffer::bind_as_resource() { - LOG(err, "NO_IMPLEMENT!"); + lt_log(err, "NO_IMPLEMENT!"); } -void glFramebuffer::Resize(const glm::uvec2 &size) +void glFramebuffer::resize(const glm::uvec2 &size) { if (m_buffer_id) { @@ -85,7 +85,7 @@ void glFramebuffer::Resize(const glm::uvec2 &size) // m_specification.width, m_specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER, // GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depth_stencil_attachment_id, 0); - ASSERT( + lt_assert( (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE), "Framebuffer is incomplete" ); diff --git a/modules/engine/src/platform/graphics/opengl/graphics_context.cpp b/modules/engine/src/platform/graphics/opengl/graphics_context.cpp index f942ab7..6094996 100644 --- a/modules/engine/src/platform/graphics/opengl/graphics_context.cpp +++ b/modules/engine/src/platform/graphics/opengl/graphics_context.cpp @@ -23,23 +23,23 @@ glGraphicsContext::glGraphicsContext(GLFWwindow *windowHandle): m_window_handle( glfwMakeContextCurrent(windowHandle); // load opengl (glad) - ASSERT(gladLoadGL(glfwGetProcAddress), "Failed to initialize opengl (glad)"); + lt_assert(gladLoadGL(glfwGetProcAddress), "Failed to initialize opengl (glad)"); - SetDebugMessageCallback(); + set_debug_message_callback(); } -void glGraphicsContext::LogDebugData() +void glGraphicsContext::log_debug_data() { // #todo: log more information - LOG(info, "________________________________________"); - LOG(info, "GraphicsContext::"); - LOG(info, " API : OpenGL"); - // LOG(info, " Version : {}", glGetString(GL_VERSION)); - // LOG(info, " Renderer: {}", glGetString(GL_RENDERER)); - LOG(info, "________________________________________"); + lt_log(info, "________________________________________"); + lt_log(info, "GraphicsContext::"); + lt_log(info, " API : OpenGL"); + // lt_log(info, " Version : {}", glGetString(GL_VERSION)); + // lt_log(info, " renderer: {}", glGetString(GL_RENDERER)); + lt_log(info, "________________________________________"); } -void glGraphicsContext::SetDebugMessageCallback() +void glGraphicsContext::set_debug_message_callback() { // determine log level // #todo: set filters from config.h @@ -89,23 +89,23 @@ void glGraphicsContext::SetDebugMessageCallback() case GL_DEBUG_SEVERITY_MEDIUM: case GL_DEBUG_SEVERITY_LOW: - LOG(warn, + lt_log(warn, "glMessageCallback: Severity: {} :: Source: {} :: Type: {} :: ID: {}", Stringifier::glDebugMsgSeverity(severity), Stringifier::glDebugMsgSource(source), Stringifier::glDebugMsgType(type), id); - LOG(warn, " {}", message); + lt_log(warn, " {}", message); return; case GL_DEBUG_SEVERITY_NOTIFICATION: - LOG(trace, + lt_log(trace, "Severity: {} :: Source: {} :: Type: {} :: ID: {}", Stringifier::glDebugMsgSeverity(severity), Stringifier::glDebugMsgSource(source), Stringifier::glDebugMsgType(type), id); - LOG(trace, " {}", message); + lt_log(trace, " {}", message); return; } }, diff --git a/modules/engine/src/platform/graphics/opengl/render_command.cpp b/modules/engine/src/platform/graphics/opengl/render_command.cpp index 29eb854..c9e4f03 100644 --- a/modules/engine/src/platform/graphics/opengl/render_command.cpp +++ b/modules/engine/src/platform/graphics/opengl/render_command.cpp @@ -10,33 +10,33 @@ glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_window_handle(wind { } -void glRenderCommand::SwapBuffers() +void glRenderCommand::swap_buffers() { glfwSwapBuffers(m_window_handle); } -void glRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor) +void glRenderCommand::clear_back_buffer(const glm::vec4 &clearColor) { glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); glClear(GL_COLOR_BUFFER_BIT); } -void glRenderCommand::Draw(unsigned int count) +void glRenderCommand::draw(unsigned int count) { glDrawArrays(GL_TRIANGLES, 0, count); } -void glRenderCommand::DrawIndexed(unsigned int count) +void glRenderCommand::draw_indexed(unsigned int count) { glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); } -void glRenderCommand::DefaultTargetFramebuffer() +void glRenderCommand::default_target_framebuffer() { glBindFramebuffer(GL_FRAMEBUFFER, NULL); } -void glRenderCommand::SetViewport( +void glRenderCommand::set_viewport( unsigned int x, unsigned int y, unsigned int width, diff --git a/modules/engine/src/platform/graphics/opengl/shader.cpp b/modules/engine/src/platform/graphics/opengl/shader.cpp index a00ed03..2ccc7a0 100644 --- a/modules/engine/src/platform/graphics/opengl/shader.cpp +++ b/modules/engine/src/platform/graphics/opengl/shader.cpp @@ -6,16 +6,16 @@ namespace Light { -glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_shader_id(0u) +glShader::glShader(basic_file_handle vertexFile, basic_file_handle pixelFile): m_shader_id(0u) { // create m_shader_id = glCreateProgram(); - std::string vertexSource(vertexFile.GetData(), vertexFile.GetData() + vertexFile.GetSize()); - std::string pixelSource(pixelFile.GetData(), pixelFile.GetData() + pixelFile.GetSize()); + std::string vertexSource(vertexFile.GetData(), vertexFile.GetData() + vertexFile.get_size()); + std::string pixelSource(pixelFile.GetData(), pixelFile.GetData() + pixelFile.get_size()); - unsigned int vertexShader = CompileShader(vertexSource, Shader::Stage::VERTEX); - unsigned int pixelShader = CompileShader(pixelSource, Shader::Stage::PIXEL); + unsigned int vertexShader = compile_shader(vertexSource, Shader::Stage::VERTEX); + unsigned int pixelShader = compile_shader(pixelSource, Shader::Stage::PIXEL); // attach shaders glAttachShader(m_shader_id, vertexShader); @@ -34,17 +34,17 @@ glShader::~glShader() glDeleteProgram(m_shader_id); } -void glShader::Bind() +void glShader::bind() { glUseProgram(m_shader_id); } -void glShader::UnBind() +void glShader::un_bind() { glUseProgram(NULL); } -// shaderc::SpvCompilationResult glShader::CompileGLSL(BasicFileHandle file, Shader::Stage stage) +// shaderc::SpvCompilationResult glShader::compile_glsl(basic_file_handle file, Shader::Stage stage) // { // // compile options // shaderc::CompileOptions options; @@ -61,14 +61,14 @@ void glShader::UnBind() // // log error // if (result.GetCompilationStatus() != shaderc_compilation_status_success) // { -// LOG(err, "Failed to compile {} shader at {}...", stage == Shader::Stage::VERTEX ? "vertex" : -// "pixel", file.GetPath()); LOG(err, " {}", result.GetErrorMessage()); +// lt_log(err, "Failed to compile {} shader at {}...", stage == Shader::Stage::VERTEX ? "vertex" : +// "pixel", file.GetPath()); lt_log(err, " {}", result.GetErrorMessage()); // } // // return result; // } -unsigned int glShader::CompileShader(std::string source, Shader::Stage stage) +unsigned int glShader::compile_shader(std::string source, Shader::Stage stage) { // &(address of) needs an lvalue const char *lvalue_source = source.c_str(); @@ -94,7 +94,7 @@ unsigned int glShader::CompileShader(std::string source, Shader::Stage stage) char *errorLog = (char *)alloca(logLength); glGetShaderInfoLog(shader, logLength, &logLength, &errorLog[0]); - LOG(err, + lt_log(err, "glShader::glShader: failed to compile {} shader:\n {}", stage == Shader::Stage::VERTEX ? "Vertex" : "Pixel", errorLog); @@ -112,7 +112,7 @@ unsigned int glShader::CompileShader(std::string source, Shader::Stage stage) char *infoLog = (char *)alloca(logLength); glGetShaderInfoLog(shader, logLength, &logLength, &infoLog[0]); - LOG(warn, infoLog); + lt_log(warn, infoLog); } } #endif diff --git a/modules/engine/src/platform/graphics/opengl/texture.cpp b/modules/engine/src/platform/graphics/opengl/texture.cpp index f5aaa95..108b4a7 100644 --- a/modules/engine/src/platform/graphics/opengl/texture.cpp +++ b/modules/engine/src/platform/graphics/opengl/texture.cpp @@ -36,12 +36,12 @@ glTexture::glTexture( NULL; // check - ASSERT(format, "Invalid number of components: {}", components); + lt_assert(format, "Invalid number of components: {}", components); // #todo: isn't there something like glTextureImage2D ??? // create texture and mipsmaps - Bind(); + bind(); glTexImage2D( GL_TEXTURE_2D, 0, @@ -61,13 +61,13 @@ glTexture::~glTexture() glDeleteTextures(1, &m_texture_id); } -void glTexture::Bind(unsigned int slot /* = 0u */) +void glTexture::bind(unsigned int slot /* = 0u */) { glActiveTexture(GL_TEXTURE0 + slot); glBindTexture(GL_TEXTURE_2D, m_texture_id); } -void *glTexture::GetTexture() +void *glTexture::get_texture() { return (void *)(intptr_t)m_texture_id; } diff --git a/modules/engine/src/platform/graphics/opengl/user_interface.cpp b/modules/engine/src/platform/graphics/opengl/user_interface.cpp index 4b317a0..538c573 100644 --- a/modules/engine/src/platform/graphics/opengl/user_interface.cpp +++ b/modules/engine/src/platform/graphics/opengl/user_interface.cpp @@ -7,7 +7,7 @@ namespace Light { -void glUserInterface::PlatformImplementation( +void glUserInterface::platform_implementation( GLFWwindow *windowHandle, Ref sharedContext ) @@ -31,14 +31,14 @@ glUserInterface::~glUserInterface() ImGui::DestroyContext(); } -void glUserInterface::Begin() +void glUserInterface::begin() { ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); } -void glUserInterface::End() +void glUserInterface::end() { ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); @@ -48,15 +48,15 @@ void glUserInterface::End() glfwMakeContextCurrent(m_window_handle); } -void glUserInterface::LogDebugData() +void glUserInterface::log_debug_data() { // #todo: improve - LOG(info, "________________________________________"); - LOG(info, "UserInterface::"); - LOG(info, " API : ImGui"); - LOG(info, " Version: {}", ImGui::GetVersion()); - LOG(info, " GraphicsAPI : OpenGL"); - LOG(info, "________________________________________"); + lt_log(info, "________________________________________"); + lt_log(info, "UserInterface::"); + lt_log(info, " API : ImGui"); + lt_log(info, " Version: {}", ImGui::GetVersion()); + lt_log(info, " GraphicsAPI : OpenGL"); + lt_log(info, "________________________________________"); } } // namespace Light diff --git a/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp b/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp index 18bf3f3..c09eb5b 100644 --- a/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp +++ b/modules/engine/src/platform/graphics/opengl/vertex_layout.cpp @@ -11,11 +11,11 @@ glVertexLayout::glVertexLayout( : m_array_id(NULL) { // check - ASSERT( + lt_assert( std::dynamic_pointer_cast(buffer), "Failed to cast 'VertexBuffer' to 'glVertexBuffer'" ); - ASSERT(!elements.empty(), "'elements' is empty"); + lt_assert(!elements.empty(), "'elements' is empty"); // local std::vector elementsDesc; @@ -25,7 +25,7 @@ glVertexLayout::glVertexLayout( // extract elements desc for (const auto &element : elements) { - elementsDesc.push_back(GetElementDesc(element.second, stride)); + elementsDesc.push_back(get_element_desc(element.second, stride)); stride += elementsDesc.back().typeSize * elementsDesc.back().count; } @@ -33,8 +33,8 @@ glVertexLayout::glVertexLayout( glCreateVertexArrays(1, &m_array_id); // bind buffer and array - buffer->Bind(); - Bind(); + buffer->bind(); + bind(); // enable vertex attributes unsigned int index = 0u; @@ -57,17 +57,17 @@ glVertexLayout::~glVertexLayout() glDeleteVertexArrays(1, &m_array_id); } -void glVertexLayout::Bind() +void glVertexLayout::bind() { glBindVertexArray(m_array_id); } -void glVertexLayout::UnBind() +void glVertexLayout::un_bind() { glBindVertexArray(NULL); } -glVertexElementDesc glVertexLayout::GetElementDesc(VertexElementType type, unsigned int offset) +glVertexElementDesc glVertexLayout::get_element_desc(VertexElementType type, unsigned int offset) { switch (type) { @@ -99,7 +99,7 @@ glVertexElementDesc glVertexLayout::GetElementDesc(VertexElementType type, unsig case VertexElementType::Float3: return { GL_FLOAT, 3u, sizeof(GLfloat), offset }; case VertexElementType::Float4: return { GL_FLOAT, 4u, sizeof(GLfloat), offset }; - default: ASSERT(false, "Invalid 'VertexElementType'"); return {}; + default: lt_assert(false, "Invalid 'VertexElementType'"); return {}; } } diff --git a/modules/engine/src/platform/os/linux/l_window.cpp b/modules/engine/src/platform/os/linux/l_window.cpp index fb601e1..9cfaa76 100644 --- a/modules/engine/src/platform/os/linux/l_window.cpp +++ b/modules/engine/src/platform/os/linux/l_window.cpp @@ -9,9 +9,9 @@ namespace Light { -Scope Window::Create(std::function callback) +Scope Window::create(std::function callback) { - return CreateScope(callback); + return create_scope(callback); } lWindow::lWindow(std::function callback) @@ -19,7 +19,7 @@ lWindow::lWindow(std::function callback) , m_event_callback(callback) { // init glfw - ASSERT(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'"); + lt_assert(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'"); // create window glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); @@ -28,15 +28,15 @@ lWindow::lWindow(std::function callback) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); - ASSERT(m_handle, "lWindow::lWindow: failed to create 'GLFWwindow'"); + lt_assert(m_handle, "lWindow::lWindow: failed to create 'GLFWwindow'"); // bind event stuff glfwSetWindowUserPointer(m_handle, &m_event_callback); - BindGlfwEvents(); + bind_glfw_events(); // create graphics context - m_graphics_context = GraphicsContext::Create(GraphicsAPI::OpenGL, m_handle); - ASSERT(m_graphics_context, "lWindow::lWindow: failed to create 'GraphicsContext'"); + m_graphics_context = GraphicsContext::create(GraphicsAPI::OpenGL, m_handle); + lt_assert(m_graphics_context, "lWindow::lWindow: failed to create 'GraphicsContext'"); } lWindow::~lWindow() @@ -44,30 +44,30 @@ lWindow::~lWindow() glfwDestroyWindow(m_handle); } -void lWindow::PollEvents() +void lWindow::poll_events() { glfwPollEvents(); } -void lWindow::OnEvent(const Event &event) +void lWindow::on_event(const Event &event) { - switch (event.GetEventType()) + switch (event.get_event_type()) { /* closed */ case EventType::WindowClosed: b_Closed = true; break; /* resized */ - case EventType::WindowResized: OnWindowResize((const WindowResizedEvent &)event); break; + case EventType::WindowResized: on_window_resize((const WindowResizedEvent &)event); break; } } -void lWindow::OnWindowResize(const WindowResizedEvent &event) +void lWindow::on_window_resize(const WindowResizedEvent &event) { - m_properties.size = event.GetSize(); + m_properties.size = event.get_size(); } void lWindow:: - SetProperties(const WindowProperties &properties, bool overrideVisibility /* = false */) + set_properties(const WindowProperties &properties, bool overrideVisibility /* = false */) { // save the visibility status and re-assign if 'overrideVisibility' is false bool visible = overrideVisibility ? properties.visible : m_properties.visible; @@ -75,20 +75,20 @@ void lWindow:: m_properties.visible = visible; // set properties - SetTitle(properties.title); - SetSize(properties.size); - SetVSync(properties.vsync); - SetVisibility(visible); + set_title(properties.title); + set_size(properties.size); + set_v_sync(properties.vsync); + set_visibility(visible); } -void lWindow::SetTitle(const std::string &title) +void lWindow::set_title(const std::string &title) { m_properties.title = title; glfwSetWindowTitle(m_handle, title.c_str()); } -void lWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) +void lWindow::set_size(const glm::uvec2 &size, bool additive /* = false */) { m_properties.size.x = size.x == 0u ? m_properties.size.x : additive ? m_properties.size.x + size.x : @@ -101,14 +101,14 @@ void lWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) glfwSetWindowSize(m_handle, size.x, size.y); } -void lWindow::SetVSync(bool vsync, bool toggle /* = false */) +void lWindow::set_v_sync(bool vsync, bool toggle /* = false */) { m_properties.vsync = toggle ? !m_properties.vsync : vsync; glfwSwapInterval(m_properties.vsync); } -void lWindow::SetVisibility(bool visible, bool toggle) +void lWindow::set_visibility(bool visible, bool toggle) { m_properties.visible = toggle ? !m_properties.visible : visible; @@ -118,7 +118,7 @@ void lWindow::SetVisibility(bool visible, bool toggle) glfwHideWindow(m_handle); } -void lWindow::BindGlfwEvents() +void lWindow::bind_glfw_events() { //============================== MOUSE_EVENTS ==============================// /* cursor position */ diff --git a/modules/engine/src/platform/os/windows/w_window.cpp b/modules/engine/src/platform/os/windows/w_window.cpp index cfe6204..1eae06f 100644 --- a/modules/engine/src/platform/os/windows/w_window.cpp +++ b/modules/engine/src/platform/os/windows/w_window.cpp @@ -16,9 +16,9 @@ extern "C" namespace Light { -Scope Window::Create(std::function callback) +Scope Window::create(std::function callback) { - return CreateScope(callback); + return create_scope(callback); } wWindow::wWindow(std::function callback) @@ -26,7 +26,7 @@ wWindow::wWindow(std::function callback) , m_event_callback(callback) { // init glfw - ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); + lt_assert(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); // create window glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); @@ -35,15 +35,15 @@ wWindow::wWindow(std::function callback) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); - ASSERT(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); + lt_assert(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); // bind event stuff glfwSetWindowUserPointer(m_handle, &m_event_callback); - BindGlfwEvents(); + bind_glfw_events(); // create graphics context - m_graphics_context = GraphicsContext::Create(GraphicsAPI::DirectX, m_handle); - ASSERT(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'"); + m_graphics_context = GraphicsContext::create(GraphicsAPI::DirectX, m_handle); + lt_assert(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'"); } wWindow::~wWindow() @@ -51,30 +51,30 @@ wWindow::~wWindow() glfwDestroyWindow(m_handle); } -void wWindow::PollEvents() +void wWindow::poll_events() { glfwPollEvents(); } -void wWindow::OnEvent(const Event &event) +void wWindow::on_event(const Event &event) { - switch (event.GetEventType()) + switch (event.get_event_type()) { /* closed */ case EventType::WindowClosed: b_Closed = true; break; /* resized */ - case EventType::WindowResized: OnWindowResize((const WindowResizedEvent &)event); break; + case EventType::WindowResized: on_window_resize((const WindowResizedEvent &)event); break; } } -void wWindow::OnWindowResize(const WindowResizedEvent &event) +void wWindow::on_window_resize(const WindowResizedEvent &event) { - m_properties.size = event.GetSize(); + m_properties.size = event.get_size(); } void wWindow:: - SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */) + set_properties(const WindowProperties &properties, bool overrideVisiblity /* = false */) { // save the visibility status and re-assign if 'overrideVisibility' is false bool visible = overrideVisiblity ? properties.visible : m_properties.visible; @@ -82,20 +82,20 @@ void wWindow:: m_properties.visible = visible; // set properties - SetTitle(properties.title); - SetSize(properties.size); - SetVSync(properties.vsync); - SetVisibility(visible); + set_title(properties.title); + set_size(properties.size); + set_v_sync(properties.vsync); + set_visibility(visible); } -void wWindow::SetTitle(const std::string &title) +void wWindow::set_title(const std::string &title) { m_properties.title = title; glfwSetWindowTitle(m_handle, m_properties.title.c_str()); } -void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) +void wWindow::set_size(const glm::uvec2 &size, bool additive /* = false */) { m_properties.size.x = size.x == 0u ? m_properties.size.x : additive ? m_properties.size.x + size.x : @@ -108,14 +108,14 @@ void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) glfwSetWindowSize(m_handle, size.x, size.y); } -void wWindow::SetVSync(bool vsync, bool toggle /* = false */) +void wWindow::set_v_sync(bool vsync, bool toggle /* = false */) { m_properties.vsync = toggle ? !m_properties.vsync : vsync; glfwSwapInterval(m_properties.vsync); } -void wWindow::SetVisibility(bool visible, bool toggle) +void wWindow::set_visibility(bool visible, bool toggle) { m_properties.visible = toggle ? !m_properties.visible : visible; @@ -125,7 +125,7 @@ void wWindow::SetVisibility(bool visible, bool toggle) glfwHideWindow(m_handle); } -void wWindow::BindGlfwEvents() +void wWindow::bind_glfw_events() { //============================== MOUSE_EVENTS ==============================// /* cursor position */ diff --git a/modules/engine/src/scene/scene.cpp b/modules/engine/src/scene/scene.cpp index cdf2ee9..2df3822 100644 --- a/modules/engine/src/scene/scene.cpp +++ b/modules/engine/src/scene/scene.cpp @@ -14,7 +14,7 @@ Scene::~Scene() { } -void Scene::OnCreate() +void Scene::on_create() { /* native scripts */ { @@ -22,23 +22,23 @@ void Scene::OnCreate() if (nsc.instance == nullptr) { nsc.instance = nsc.CreateInstance(); - nsc.instance->OnCreate(); + nsc.instance->on_create(); } }); } } -void Scene::OnUpdate(float deltaTime) +void Scene::on_update(float deltaTime) { /* native scripts */ { m_registry.view().each([=](NativeScriptComponent &nsc) { - nsc.instance->OnUpdate(deltaTime); + nsc.instance->on_update(deltaTime); }); } } -void Scene::OnRender(const Ref &targetFrameBuffer /* = nullptr */) +void Scene::on_render(const Ref &targetFrameBuffer /* = nullptr */) { Camera *sceneCamera = nullptr; TransformComponent *sceneCameraTransform; @@ -59,29 +59,29 @@ void Scene::OnRender(const Ref &targetFrameBuffer /* = nullptr */) { if (sceneCamera) { - Renderer::BeginScene(sceneCamera, *sceneCameraTransform, targetFrameBuffer); + renderer::begin_scene(sceneCamera, *sceneCameraTransform, targetFrameBuffer); m_registry.group(entt::get) .each([](TransformComponent &transformComp, SpriteRendererComponent &spriteRendererComp) { - Renderer::DrawQuad( + renderer::draw_quad( transformComp, spriteRendererComp.tint, spriteRendererComp.texture ); }); - Renderer::EndScene(); + renderer::end_scene(); } } } -Entity Scene::CreateEntity(const std::string &name, const TransformComponent &transform) +Entity Scene::create_entity(const std::string &name, const TransformComponent &transform) { - return CreateEntityWithUUID(name, UUID(), transform); + return create_entity_with_uuid(name, UUID(), transform); } -Entity Scene::GetEntityByTag(const std::string &tag) +Entity Scene::get_entity_by_tag(const std::string &tag) { // TagComponent tagComp(tag); // entt::entity entity = entt::to_entity(m_registry, tagComp); @@ -89,19 +89,19 @@ Entity Scene::GetEntityByTag(const std::string &tag) m_registry.view().each([&](TagComponent &tagComp) { // if (tagComp.tag == tag) - // entity = Entity(entt::to_entity(m_registry, tagComp), this); + // entity = entity(entt::to_entity(m_registry, tagComp), this); }); - if (entity.IsValid()) + if (entity.is_valid()) return entity; else { - ASSERT("Scene::GetEntityByTag: failed to find entity by tag: {}", tag); - return Entity(); + lt_assert("Scene::get_entity_by_tag: failed to find entity by tag: {}", tag); + return {}; } } -Entity Scene::CreateEntityWithUUID( +Entity Scene::create_entity_with_uuid( const std::string &name, UUID uuid, const TransformComponent &transform diff --git a/modules/engine/src/time/timer.cpp b/modules/engine/src/time/timer.cpp index 7674f8a..1b4015b 100644 --- a/modules/engine/src/time/timer.cpp +++ b/modules/engine/src/time/timer.cpp @@ -10,9 +10,9 @@ DeltaTimer::DeltaTimer(): m_previous_frame(NULL), m_delta_time(60.0f / 1000.0f) { } -void DeltaTimer::Update() +void DeltaTimer::update() { - float currentFrame = timer.GetElapsedTime(); + float currentFrame = timer.get_elapsed_time(); m_delta_time = currentFrame - m_previous_frame; m_previous_frame = currentFrame; } diff --git a/modules/engine/src/user_interface/user_interface.cpp b/modules/engine/src/user_interface/user_interface.cpp index 6ee1cd8..6ceac29 100644 --- a/modules/engine/src/user_interface/user_interface.cpp +++ b/modules/engine/src/user_interface/user_interface.cpp @@ -18,29 +18,29 @@ namespace Light { UserInterface *UserInterface::s_Context = nullptr; -Scope UserInterface::Create( +Scope UserInterface::create( GLFWwindow *windowHandle, Ref sharedContext ) { Scope scopeUserInterface = nullptr; - switch (GraphicsContext::GetGraphicsAPI()) + switch (GraphicsContext::get_graphics_api()) { - case GraphicsAPI::OpenGL: scopeUserInterface = CreateScope(); break; + case GraphicsAPI::OpenGL: scopeUserInterface = create_scope(); break; - case GraphicsAPI::DirectX: LT_WIN(scopeUserInterface = CreateScope();) break; + case GraphicsAPI::DirectX: lt_win(scopeUserInterface = create_scope();) break; default: - ASSERT( + lt_assert( false, - "UserInterface::Create: invalid/unsupported 'GraphicsAPI' {}", - static_cast(GraphicsContext::GetGraphicsAPI()) + "UserInterface::create: invalid/unsupported 'GraphicsAPI' {}", + static_cast(GraphicsContext::get_graphics_api()) ); return nullptr; } - scopeUserInterface->Init(windowHandle, sharedContext); + scopeUserInterface->init(windowHandle, sharedContext); return std::move(scopeUserInterface); } @@ -51,7 +51,7 @@ UserInterface::UserInterface() | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus ) { - ASSERT( + lt_assert( !s_Context, "UserInterface::UserInterface: an instance of 'UserInterface' already exists, do not " "construct this class!" @@ -59,7 +59,7 @@ UserInterface::UserInterface() s_Context = this; } -void UserInterface::Init(GLFWwindow *windowHandle, Ref sharedContext) +void UserInterface::init(GLFWwindow *windowHandle, Ref sharedContext) { // create context IMGUI_CHECKVERSION(); @@ -84,7 +84,7 @@ void UserInterface::Init(GLFWwindow *windowHandle, Ref sharedCont // style ImGui::StyleColorsDark(); - PlatformImplementation(windowHandle, sharedContext); + platform_implementation(windowHandle, sharedContext); // keyboard map io.KeyMap[ImGuiKey_Tab] = Key::Tab; @@ -95,7 +95,7 @@ void UserInterface::Init(GLFWwindow *windowHandle, Ref sharedCont io.KeyMap[ImGuiKey_PageUp] = Key::PageUp; io.KeyMap[ImGuiKey_PageDown] = Key::PageDown; io.KeyMap[ImGuiKey_Home] = Key::Home; - io.KeyMap[ImGuiKey_End] = Key::End; + io.KeyMap[ImGuiKey_End] = Key::end; io.KeyMap[ImGuiKey_Insert] = Key::Insert; io.KeyMap[ImGuiKey_Delete] = Key::Delete; io.KeyMap[ImGuiKey_Backspace] = Key::BackSpace; @@ -116,10 +116,10 @@ void UserInterface::Init(GLFWwindow *windowHandle, Ref sharedCont 18.0f ); - SetDarkThemeColors(); + set_dark_theme_colors(); } -void UserInterface::DockspaceBegin() +void UserInterface::dockspace_begin() { ImGuiViewport *viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(viewport->Pos); @@ -143,12 +143,12 @@ void UserInterface::DockspaceBegin() style.WindowMinSize.x = minWinSizeX; } -void UserInterface::DockspaceEnd() +void UserInterface::dockspace_end() { ImGui::End(); } -void UserInterface::SetDarkThemeColors() +void UserInterface::set_dark_theme_colors() { ImGuiStyle &style = ImGui::GetStyle(); ImVec4(&colors)[55] = style.Colors; diff --git a/modules/engine/src/utils/file_manager.cpp b/modules/engine/src/utils/file_manager.cpp index cf4238e..d021298 100644 --- a/modules/engine/src/utils/file_manager.cpp +++ b/modules/engine/src/utils/file_manager.cpp @@ -4,7 +4,7 @@ namespace Light { -BasicFileHandle::BasicFileHandle( +basic_file_handle::basic_file_handle( uint8_t *data, uint32_t size, const std::string &path, @@ -19,7 +19,7 @@ BasicFileHandle::BasicFileHandle( { } -void BasicFileHandle::Release() +void basic_file_handle::release() { delete m_data; m_data = nullptr; @@ -27,7 +27,7 @@ void BasicFileHandle::Release() } -BasicFileHandle FileManager::ReadTextFile(const std::string &path) +basic_file_handle FileManager::read_text_file(const std::string &path) { // parse path info std::string name = path.substr(0, path.find('.') + -1); @@ -39,7 +39,7 @@ BasicFileHandle FileManager::ReadTextFile(const std::string &path) // check if (!file) { - LOG(warn, "Failed to load text file: {}", path); + lt_log(warn, "Failed to load text file: {}", path); file.close(); return NULL; } @@ -50,17 +50,17 @@ BasicFileHandle FileManager::ReadTextFile(const std::string &path) file.seekg(0, std::ios::beg); if (!size) - LOG(warn, "Empty text file: {}", path); + lt_log(warn, "Empty text file: {}", path); // read file uint8_t *data = new uint8_t[size]; file.read(reinterpret_cast(data), size); file.close(); - return BasicFileHandle(data, size, path, name, extension); + return basic_file_handle(data, size, path, name, extension); } -ImageFileHandle FileManager::ReadImageFile(const std::string &path, int32_t desiredComponents) +image_file_handle FileManager::read_image_file(const std::string &path, int32_t desiredComponents) { // parse path info std::string name = path.substr(0, path.find('.') + -1); @@ -78,15 +78,15 @@ ImageFileHandle FileManager::ReadImageFile(const std::string &path, int32_t desi // check if (!pixels) - LOG(warn, "Failed to load image file: <{}>", path); + lt_log(warn, "Failed to load image file: <{}>", path); else if (fetchedComponents != desiredComponents) - LOG(warn, + lt_log(warn, "Mismatch of fetched/desired components: <{}> ({}/{})", name + '.' + extension, fetchedComponents, desiredComponents); - return ImageFileHandle( + return image_file_handle( pixels, width * height, path, @@ -99,7 +99,7 @@ ImageFileHandle FileManager::ReadImageFile(const std::string &path, int32_t desi ); } -void ImageFileHandle::Release() +void image_file_handle::release() { stbi_image_free(reinterpret_cast(m_data)); m_data = nullptr; diff --git a/modules/engine/src/utils/resource_manager.cpp b/modules/engine/src/utils/resource_manager.cpp index 085ab4c..8af4d36 100644 --- a/modules/engine/src/utils/resource_manager.cpp +++ b/modules/engine/src/utils/resource_manager.cpp @@ -8,76 +8,76 @@ namespace Light { ResourceManager *ResourceManager::s_Context = nullptr; -Scope ResourceManager::Create() +Scope ResourceManager::create() { - return MakeScope(new ResourceManager()); + return make_scope(new ResourceManager()); } ResourceManager::ResourceManager(): m_shaders {}, m_textures {} { - ASSERT(!s_Context, "Repeated singleton construction"); + lt_assert(!s_Context, "Repeated singleton construction"); s_Context = this; } -void ResourceManager::LoadShaderImpl( +void ResourceManager::load_shader_impl( const std::string &name, const std::string &vertexPath, const std::string &pixelPath ) { // check - ASSERT(s_Context, "Uninitliazed singleton"); - ASSERT(!vertexPath.empty(), "Empty 'vertexPath'"); - ASSERT(!pixelPath.empty(), "Empty 'pixelPath'"); + lt_assert(s_Context, "Uninitliazed singleton"); + lt_assert(!vertexPath.empty(), "Empty 'vertexPath'"); + lt_assert(!pixelPath.empty(), "Empty 'pixelPath'"); // load files - BasicFileHandle vertexFile = FileManager::ReadTextFile(vertexPath); - BasicFileHandle pixelFile = FileManager::ReadTextFile(pixelPath); + basic_file_handle vertexFile = FileManager::read_text_file(vertexPath); + basic_file_handle pixelFile = FileManager::read_text_file(pixelPath); // check - ASSERT(vertexFile.IsValid(), "Failed to read vertex file: {}", vertexPath); - ASSERT(pixelFile.IsValid(), "Failed to read vertex file: {}", pixelPath); + lt_assert(vertexFile.is_valid(), "Failed to read vertex file: {}", vertexPath); + lt_assert(pixelFile.is_valid(), "Failed to read vertex file: {}", pixelPath); // create shader m_shaders[name] = Ref( - Shader::Create(vertexFile, pixelFile, GraphicsContext::GetSharedContext()) + Shader::create(vertexFile, pixelFile, GraphicsContext::get_shared_context()) ); // free file - vertexFile.Release(); - pixelFile.Release(); + vertexFile.release(); + pixelFile.release(); } -void ResourceManager::LoadTextureImpl( +void ResourceManager::load_texture_impl( const std::string &name, const std::string &path, unsigned int desiredComponents /* = 4u */ ) { - ASSERT(s_Context, "Uninitliazed singleton"); + lt_assert(s_Context, "Uninitliazed singleton"); // load file - ImageFileHandle imgFile = FileManager::ReadImageFile(path, desiredComponents); + image_file_handle imgFile = FileManager::read_image_file(path, desiredComponents); // create texture - m_textures[name] = Ref(Texture::Create( - imgFile.GetWidth(), - imgFile.GetHeight(), - imgFile.GetComponents(), + m_textures[name] = Ref(Texture::create( + imgFile.get_width(), + imgFile.get_height(), + imgFile.get_components(), imgFile.GetData(), - GraphicsContext::GetSharedContext(), + GraphicsContext::get_shared_context(), path )); // free file - imgFile.Release(); + imgFile.release(); } -void ResourceManager::ReleaseTextureImpl(const std::string &name) +void ResourceManager::release_texture_impl(const std::string &name) { if (!m_textures[name]) { - LOG(warn, "Failed to find texture named: {}", name); + lt_log(warn, "Failed to find texture named: {}", name); return; } diff --git a/modules/engine/src/utils/serializer.cpp b/modules/engine/src/utils/serializer.cpp index dd4818a..2134ded 100644 --- a/modules/engine/src/utils/serializer.cpp +++ b/modules/engine/src/utils/serializer.cpp @@ -76,7 +76,7 @@ SceneSerializer::SceneSerializer(const Ref &scene): m_scene(scene) { } -void SceneSerializer::Serialize(const std::string &filePath) +void SceneSerializer::serialize(const std::string &filePath) { YAML::Emitter out; out << YAML::BeginMap; // Scene @@ -86,10 +86,10 @@ void SceneSerializer::Serialize(const std::string &filePath) for (auto [entityID, storage] : m_scene->m_registry.storage()) { Entity entity = { static_cast(entityID), m_scene.get() }; - if (!entity.IsValid()) + if (!entity.is_valid()) return; - SerializeEntity(out, entity); + serialize_entity(out, entity); }; out << YAML::EndSeq; out << YAML::EndMap; @@ -98,11 +98,11 @@ void SceneSerializer::Serialize(const std::string &filePath) std::ofstream fout(filePath); if (!fout.is_open()) - LOG(trace, "Failed to create fout at: {}", filePath); + lt_log(trace, "Failed to create fout at: {}", filePath); fout << out.c_str(); } -bool SceneSerializer::Deserialize(const std::string &filePath) +bool SceneSerializer::deserialize(const std::string &filePath) { std::ifstream stream(filePath); std::stringstream ss; @@ -113,7 +113,7 @@ bool SceneSerializer::Deserialize(const std::string &filePath) return false; std::string sceneName = data["Scene"].as(); - LOG(trace, "Deserializing scene: '{}'", sceneName); + lt_log(trace, "Deserializing scene: '{}'", sceneName); auto entities = data["Entities"]; if (entities) @@ -125,19 +125,19 @@ bool SceneSerializer::Deserialize(const std::string &filePath) for (auto entity : entities) { - uint64_t uuid = entity["Entity"].as(); // #todo + uint64_t uuid = entity["entity"].as(); // #todo std::string name; auto tagComponent = entity["TagComponent"]; if (tagComponent) name = tagComponent["Tag"].as(); - LOG(trace, "Deserialized entity '{}' : '{}'", uuid, name); + lt_log(trace, "Deserialized entity '{}' : '{}'", uuid, name); - Entity deserializedEntity = m_scene->CreateEntityWithUUID(name, uuid); + Entity deserializedEntity = m_scene->create_entity_with_uuid(name, uuid); TagComponent gg = deserializedEntity.GetComponent(); - LOG(trace, gg.tag); + lt_log(trace, gg.tag); auto transformComponent = entity["TransformComponent"]; if (transformComponent) { @@ -163,11 +163,11 @@ bool SceneSerializer::Deserialize(const std::string &filePath) if (!texturePaths.contains(texturePath)) { - ResourceManager::LoadTexture(texturePath, texturePath); + ResourceManager::load_texture(texturePath, texturePath); texturePaths.insert(texturePath); } - entitySpriteRendererComponent.texture = ResourceManager::GetTexture(texturePath); + entitySpriteRendererComponent.texture = ResourceManager::get_texture(texturePath); } /* #TEMPORARY SOLUTION# */ @@ -177,31 +177,31 @@ bool SceneSerializer::Deserialize(const std::string &filePath) auto &entityCameraComponent = deserializedEntity.AddComponent(); const auto &cameraSpecifications = cameraComponent["Camera"]; - entityCameraComponent.camera.SetProjectionType( + entityCameraComponent.camera.set_projection_type( (SceneCamera::ProjectionType)cameraSpecifications["ProjectionType"].as() ); - entityCameraComponent.camera.SetOrthographicSize( + entityCameraComponent.camera.set_orthographic_size( cameraSpecifications["OrthographicSize"].as() ); - entityCameraComponent.camera.SetOrthographicNearPlane( + entityCameraComponent.camera.set_orthographic_near_plane( cameraSpecifications["OrthographicNearPlane"].as() ); - entityCameraComponent.camera.SetOrthographicFarPlane( + entityCameraComponent.camera.set_orthographic_far_plane( cameraSpecifications["OrthographicFarPlane"].as() ); - entityCameraComponent.camera.SetPerspectiveVerticalFOV( + entityCameraComponent.camera.set_perspective_vertical_fov( cameraSpecifications["PerspectiveVerticalFOV"].as() ); - entityCameraComponent.camera.SetPerspectiveNearPlane( + entityCameraComponent.camera.set_perspective_near_plane( cameraSpecifications["PerspectiveNearPlane"].as() ); - entityCameraComponent.camera.SetPerspectiveFarPlane( + entityCameraComponent.camera.set_perspective_far_plane( cameraSpecifications["PerspectiveFarPlane"].as() ); - entityCameraComponent.camera.SetBackgroundColor( + entityCameraComponent.camera.set_background_color( cameraSpecifications["BackgroundColor"].as() ); @@ -215,23 +215,23 @@ bool SceneSerializer::Deserialize(const std::string &filePath) return false; } -void SceneSerializer::SerializeBinary(const std::string &filePath) +void SceneSerializer::serialize_binary(const std::string &filePath) { - LOG(err, "NO_IMPLEMENT"); + lt_log(err, "NO_IMPLEMENT"); } -bool SceneSerializer::DeserializeBinary(const std::string &filePath) +bool SceneSerializer::deserialize_binary(const std::string &filePath) { - LOG(err, "NO_IMPLEMENT"); + lt_log(err, "NO_IMPLEMENT"); return false; } -void SceneSerializer::SerializeEntity(YAML::Emitter &out, Entity entity) +void SceneSerializer::serialize_entity(YAML::Emitter &out, Entity entity) { - out << YAML::BeginMap; // entity - out << YAML::Key << "Entity" << YAML::Value << entity.GetUUID(); // dummy uuid + out << YAML::BeginMap; // entity + out << YAML::Key << "entity" << YAML::Value << entity.get_uuid(); // dummy uuid - if (entity.HasComponent()) + if (entity.has_component()) { out << YAML::Key << "TagComponent"; out << YAML::BeginMap; // tag component @@ -242,7 +242,7 @@ void SceneSerializer::SerializeEntity(YAML::Emitter &out, Entity entity) out << YAML::EndMap; // tag component } - if (entity.HasComponent()) + if (entity.has_component()) { out << YAML::Key << "TransformComponent"; out << YAML::BeginMap; // transform component @@ -256,7 +256,7 @@ void SceneSerializer::SerializeEntity(YAML::Emitter &out, Entity entity) out << YAML::EndMap; // transform component; } - if (entity.HasComponent()) + if (entity.has_component()) { out << YAML::Key << "SpriteRendererComponent"; out << YAML::BeginMap; // sprite renderer component; @@ -271,9 +271,9 @@ void SceneSerializer::SerializeEntity(YAML::Emitter &out, Entity entity) } // #todo: - // if(entity.HasComponent()) + // if(entity.has_component()) - if (entity.HasComponent()) + if (entity.has_component()) { out << YAML::Key << "CameraComponent"; out << YAML::BeginMap; // camera component @@ -283,19 +283,19 @@ void SceneSerializer::SerializeEntity(YAML::Emitter &out, Entity entity) out << YAML::Key << "Camera" << YAML::Value; out << YAML::BeginMap; // camera out << YAML::Key << "OrthographicSize" << YAML::Value - << cameraComponent.camera.GetOrthographicSize(); + << cameraComponent.camera.get_orthographic_size(); out << YAML::Key << "OrthographicFarPlane" << YAML::Value - << cameraComponent.camera.GetOrthographicFarPlane(); + << cameraComponent.camera.get_orthographic_far_plane(); out << YAML::Key << "OrthographicNearPlane" << YAML::Value - << cameraComponent.camera.GetOrthographicNearPlane(); + << cameraComponent.camera.get_orthographic_near_plane(); out << YAML::Key << "PerspectiveVerticalFOV" << YAML::Value - << cameraComponent.camera.GetPerspectiveVerticalFOV(); + << cameraComponent.camera.get_perspective_vertical_fov(); out << YAML::Key << "PerspectiveFarPlane" << YAML::Value - << cameraComponent.camera.GetPerspectiveFarPlane(); + << cameraComponent.camera.get_perspective_far_plane(); out << YAML::Key << "PerspectiveNearPlane" << YAML::Value - << cameraComponent.camera.GetPerspectiveNearPlane(); + << cameraComponent.camera.get_perspective_near_plane(); out << YAML::Key << "ProjectionType" << YAML::Value - << (int)cameraComponent.camera.GetProjectionType(); + << (int)cameraComponent.camera.get_projection_type(); out << YAML::Key << "BackgroundColor" << YAML::Value << cameraComponent.camera.GetBackgroundColor(); out << YAML::EndMap; // camera diff --git a/modules/engine/src/utils/stringifier.cpp b/modules/engine/src/utils/stringifier.cpp index 1d21427..3da4c52 100644 --- a/modules/engine/src/utils/stringifier.cpp +++ b/modules/engine/src/utils/stringifier.cpp @@ -68,7 +68,7 @@ std::string Stringifier::spdlogLevel(unsigned int level) //==================== SPDLOG ====================// //==================== GRAPHICS_API ====================// -std::string Stringifier::GraphicsAPIToString(GraphicsAPI api) +std::string Stringifier::graphics_api_to_string(GraphicsAPI api) { switch (api) { diff --git a/modules/mirror/include/mirror/editor_layer.hpp b/modules/mirror/include/mirror/editor_layer.hpp index 53d04a7..259f43a 100644 --- a/modules/mirror/include/mirror/editor_layer.hpp +++ b/modules/mirror/include/mirror/editor_layer.hpp @@ -10,17 +10,31 @@ namespace Light { class EditorLayer: public Layer { +public: + EditorLayer(const std::string &name); + + ~EditorLayer(); + + void on_update(float deltaTime) override; + + void on_render() override; + + void on_user_interface_update() override; + private: std::string m_scene_dir; // #todo: add camera controller class to the engine glm::vec2 m_direction; + float m_speed = 1000.0f; Ref m_scene; Ref m_sceneHierarchyPanel; + Ref m_properties_panel; + Ref m_content_browser_panel; Ref m_framebuffer; @@ -28,16 +42,6 @@ private: Entity m_camera_entity; ImVec2 m_available_content_region_prev; - -public: - EditorLayer(const std::string &name); - ~EditorLayer(); - - void OnUpdate(float deltaTime) override; - - void OnRender() override; - - void OnUserInterfaceUpdate() override; }; } // namespace Light diff --git a/modules/mirror/include/mirror/panel/asset_browser.hpp b/modules/mirror/include/mirror/panel/asset_browser.hpp index 11915ae..dddffeb 100644 --- a/modules/mirror/include/mirror/panel/asset_browser.hpp +++ b/modules/mirror/include/mirror/panel/asset_browser.hpp @@ -8,6 +8,11 @@ namespace Light { class AssetBrowserPanel: public Panel { +public: + AssetBrowserPanel(Ref activeScene); + + void on_user_interface_update(); + private: enum class AssetType { @@ -18,24 +23,22 @@ private: Image, }; -public: - AssetBrowserPanel(Ref activeScene); - - void OnUserInterfaceUpdate(); - -private: std::filesystem::path m_current_directory; + const std::filesystem::path m_assets_path; - // TODO: Save configuration uint32_t m_file_size = 128u; + uint32_t m_file_padding = 8u; Ref m_active_scene; Ref m_directory_texture; + Ref m_scene_texture; + Ref m_image_texture; + Ref m_text_texture; }; diff --git a/modules/mirror/include/mirror/panel/panel.hpp b/modules/mirror/include/mirror/panel/panel.hpp index f21ab4d..6e9be8c 100644 --- a/modules/mirror/include/mirror/panel/panel.hpp +++ b/modules/mirror/include/mirror/panel/panel.hpp @@ -2,11 +2,12 @@ namespace Light { - class Panel - { - public: - Panel() = default; - virtual ~Panel() = default; - }; +class Panel +{ +public: + Panel() = default; -} \ No newline at end of file + virtual ~Panel() = default; +}; + +} // namespace Light diff --git a/modules/mirror/include/mirror/panel/properties.hpp b/modules/mirror/include/mirror/panel/properties.hpp index 99054a0..165a1be 100644 --- a/modules/mirror/include/mirror/panel/properties.hpp +++ b/modules/mirror/include/mirror/panel/properties.hpp @@ -7,19 +7,17 @@ namespace Light { class PropertiesPanel: public Panel { -private: - Entity m_entity_context; - public: PropertiesPanel() = default; + ~PropertiesPanel() = default; - void OnUserInterfaceUpdate(); + void on_user_interface_update(); - void SetEntityContext(Entity entity); + void set_entity_context(Entity entity); private: - void DrawVec3Control( + void draw_vec3_control( const std::string &label, glm::vec3 &values, float resetValue = 0.0f, @@ -27,7 +25,9 @@ private: ); template - void DrawComponent(const std::string &name, Entity entity, UIFunction function); + void draw_component(const std::string &name, Entity entity, UIFunction function); + + Entity m_entity_context; }; diff --git a/modules/mirror/include/mirror/panel/scene_hierarchy.hpp b/modules/mirror/include/mirror/panel/scene_hierarchy.hpp index 35f5cc2..8664955 100644 --- a/modules/mirror/include/mirror/panel/scene_hierarchy.hpp +++ b/modules/mirror/include/mirror/panel/scene_hierarchy.hpp @@ -11,21 +11,22 @@ class PropertiesPanel; class SceneHierarchyPanel: public Panel { -private: - Ref m_context; - Ref m_properties_panel_context; - Entity m_selection_context; - public: SceneHierarchyPanel(); SceneHierarchyPanel(Ref context, Ref propertiesPanel = nullptr); - void OnUserInterfaceUpdate(); + void on_user_interface_update(); - void SetContext(Ref context, Ref propertiesPanel = nullptr); + void set_context(Ref context, Ref propertiesPanel = nullptr); private: - void DrawNode(Entity entity, const std::string &label); + void draw_node(Entity entity, const std::string &label); + + Ref m_context; + + Ref m_properties_panel_context; + + Entity m_selection_context; }; } // namespace Light diff --git a/modules/mirror/src/editor_layer.cpp b/modules/mirror/src/editor_layer.cpp index 1cf94cb..7b27a6c 100644 --- a/modules/mirror/src/editor_layer.cpp +++ b/modules/mirror/src/editor_layer.cpp @@ -5,30 +5,30 @@ namespace Light { EditorLayer::EditorLayer(const std::string &name): Layer(name), m_scene_dir("") { - m_scene = CreateRef(); + m_scene = create_ref(); - m_properties_panel = CreateRef(); - m_sceneHierarchyPanel = CreateRef(m_scene, m_properties_panel); - m_content_browser_panel = CreateRef(m_scene); + m_properties_panel = create_ref(); + m_sceneHierarchyPanel = create_ref(m_scene, m_properties_panel); + m_content_browser_panel = create_ref(m_scene); - m_framebuffer = Framebuffer::Create({ 1, 1, 1 }, GraphicsContext::GetSharedContext()); + m_framebuffer = Framebuffer::create({ 1, 1, 1 }, GraphicsContext::get_shared_context()); if (m_scene_dir.empty()) { - m_camera_entity = m_scene->CreateEntity("Camera"); + m_camera_entity = m_scene->create_entity("Camera"); m_camera_entity.AddComponent(SceneCamera(), true); - ResourceManager::LoadTexture("Awesomeface", "Assets/Textures/awesomeface.png"); - Entity entity = m_scene->CreateEntity("Awesomeface", {}); + ResourceManager::load_texture("Awesomeface", "Assets/Textures/awesomeface.png"); + Entity entity = m_scene->create_entity("Awesomeface", {}); entity.AddComponent( - ResourceManager::GetTexture("Awesomeface"), + ResourceManager::get_texture("Awesomeface"), glm::vec4 { 0.0f, 1.0f, 1.0f, 1.0f } ); } else { SceneSerializer serializer(m_scene); - ASSERT(serializer.Deserialize(m_scene_dir), "Failed to de-serialize: {}", m_scene_dir); + lt_assert(serializer.deserialize(m_scene_dir), "Failed to de-serialize: {}", m_scene_dir); // m_camera_entity = m_scene->GetEntityByTag("Game Camera"); } @@ -39,54 +39,54 @@ EditorLayer::~EditorLayer() if (!m_scene_dir.empty()) { SceneSerializer serializer(m_scene); - serializer.Serialize(m_scene_dir); + serializer.serialize(m_scene_dir); } } -void EditorLayer::OnUpdate(float deltaTime) +void EditorLayer::on_update(float deltaTime) { - m_scene->OnUpdate(deltaTime); + m_scene->on_update(deltaTime); - m_direction.x = Input::GetKeyboardKey(Key::A) ? -1.0f : - Input::GetKeyboardKey(Key::D) ? 1.0f : - 0.0f; + m_direction.x = Input::get_keyboard_key(Key::A) ? -1.0f : + Input::get_keyboard_key(Key::D) ? 1.0f : + 0.0f; - m_direction.y = Input::GetKeyboardKey(Key::S) ? -1.0f : - Input::GetKeyboardKey(Key::W) ? 1.0f : - 0.0f; + m_direction.y = Input::get_keyboard_key(Key::S) ? -1.0f : + Input::get_keyboard_key(Key::W) ? 1.0f : + 0.0f; auto &cameraTranslation = m_camera_entity.GetComponent().translation; cameraTranslation += glm::vec3(m_direction * m_speed * deltaTime, 0.0f); - if (Input::GetKeyboardKey(Key::Escape)) - Application::Quit(); + if (Input::get_keyboard_key(Key::Escape)) + Application::quit(); } -void EditorLayer::OnRender() +void EditorLayer::on_render() { - m_scene->OnRender(m_framebuffer); + m_scene->on_render(m_framebuffer); } -void EditorLayer::OnUserInterfaceUpdate() +void EditorLayer::on_user_interface_update() { - UserInterface::DockspaceBegin(); + UserInterface::dockspace_begin(); ImGui::ShowDemoWindow(); if (ImGui::Begin("Game")) { - Input::ReceiveGameEvents(ImGui::IsWindowFocused()); + Input::receive_game_events(ImGui::IsWindowFocused()); ImVec2 regionAvail = ImGui::GetContentRegionAvail(); if (m_available_content_region_prev != regionAvail) { - m_framebuffer->Resize({ regionAvail.x, regionAvail.y }); + m_framebuffer->resize({ regionAvail.x, regionAvail.y }); auto &camera = m_camera_entity.GetComponent().camera; - camera.SetViewportSize(regionAvail.x, regionAvail.y); + camera.set_viewport_size(regionAvail.x, regionAvail.y); m_available_content_region_prev = regionAvail; } - if (GraphicsContext::GetGraphicsAPI() == GraphicsAPI::DirectX) + if (GraphicsContext::get_graphics_api() == GraphicsAPI::DirectX) ImGui::Image(m_framebuffer->GetColorAttachment(), regionAvail); else ImGui::Image( @@ -99,11 +99,11 @@ void EditorLayer::OnUserInterfaceUpdate() ImGui::End(); // Panels - m_sceneHierarchyPanel->OnUserInterfaceUpdate(); - m_properties_panel->OnUserInterfaceUpdate(); - m_content_browser_panel->OnUserInterfaceUpdate(); + m_sceneHierarchyPanel->on_user_interface_update(); + m_properties_panel->on_user_interface_update(); + m_content_browser_panel->on_user_interface_update(); - UserInterface::DockspaceEnd(); + UserInterface::dockspace_end(); } } // namespace Light diff --git a/modules/mirror/src/mirror.cpp b/modules/mirror/src/mirror.cpp index ee14cb7..db38767 100644 --- a/modules/mirror/src/mirror.cpp +++ b/modules/mirror/src/mirror.cpp @@ -19,10 +19,10 @@ public: properties.size = glm::uvec2(1280u, 720u); properties.vsync = true; - m_window->SetProperties(properties); + m_window->set_properties(properties); // Attach the sandbox layer - LayerStack::EmplaceLayer(("MirrorLayer")); + LayerStack::emplace_layer(("MirrorLayer")); } }; diff --git a/modules/mirror/src/panel/asset_browser.cpp b/modules/mirror/src/panel/asset_browser.cpp index 34f3d59..8705b34 100644 --- a/modules/mirror/src/panel/asset_browser.cpp +++ b/modules/mirror/src/panel/asset_browser.cpp @@ -10,18 +10,18 @@ AssetBrowserPanel::AssetBrowserPanel(Ref activeScene) , m_assets_path("Assets") , m_active_scene(activeScene) { - ResourceManager::LoadTexture("_Assets_Directory", "EngineResources/Icons/Asset_Directory.png"); - ResourceManager::LoadTexture("_Assets_Scene", "EngineResources/Icons/Asset_Scene.png"); - ResourceManager::LoadTexture("_Assets_Image", "EngineResources/Icons/Asset_Image.png"); - ResourceManager::LoadTexture("_Assets_Text", "EngineResources/Icons/Asset_Text.png"); + ResourceManager::load_texture("_Assets_Directory", "EngineResources/Icons/Asset_Directory.png"); + ResourceManager::load_texture("_Assets_Scene", "EngineResources/Icons/Asset_Scene.png"); + ResourceManager::load_texture("_Assets_Image", "EngineResources/Icons/Asset_Image.png"); + ResourceManager::load_texture("_Assets_Text", "EngineResources/Icons/Asset_Text.png"); - m_directory_texture = ResourceManager::GetTexture("_Assets_Directory"); - m_scene_texture = ResourceManager::GetTexture("_Assets_Scene"); - m_image_texture = ResourceManager::GetTexture("_Assets_Image"); - m_text_texture = ResourceManager::GetTexture("_Assets_Text"); + m_directory_texture = ResourceManager::get_texture("_Assets_Directory"); + m_scene_texture = ResourceManager::get_texture("_Assets_Scene"); + m_image_texture = ResourceManager::get_texture("_Assets_Image"); + m_text_texture = ResourceManager::get_texture("_Assets_Text"); } -void AssetBrowserPanel::OnUserInterfaceUpdate() +void AssetBrowserPanel::on_user_interface_update() { ImGui::Begin("Content Browser"); @@ -44,7 +44,7 @@ void AssetBrowserPanel::OnUserInterfaceUpdate() if (ImGui::BeginTable("ContentBrowser", columnCount)) { - m_directory_texture->Bind(0u); + m_directory_texture->bind(0u); for (auto &dirEntry : std::filesystem::directory_iterator(m_current_directory)) { const auto &path = dirEntry.path(); @@ -77,7 +77,7 @@ void AssetBrowserPanel::OnUserInterfaceUpdate() // Directory case AssetType::Directory: if (ImGui::ImageButton( - m_directory_texture->GetTexture(), + m_directory_texture->get_texture(), ImVec2(m_file_size, m_file_size), ImVec2 { 0.0f, 0.0f }, ImVec2 { 1.0f, 1.0f }, @@ -93,7 +93,7 @@ void AssetBrowserPanel::OnUserInterfaceUpdate() // Scene case AssetType::Scene: if (ImGui::ImageButton( - m_scene_texture->GetTexture(), + m_scene_texture->get_texture(), ImVec2(m_file_size, m_file_size), ImVec2 { 0.0f, 0.0f }, ImVec2 { 1.0f, 1.0f }, @@ -103,15 +103,15 @@ void AssetBrowserPanel::OnUserInterfaceUpdate() )) { SceneSerializer serializer(m_active_scene); - LOG(info, "Attempting to deserialize: {}", path.string()); - serializer.Deserialize(path.string()); + lt_log(info, "Attempting to deserialize: {}", path.string()); + serializer.deserialize(path.string()); } break; // Image case AssetType::Image: if (ImGui::ImageButton( - m_image_texture->GetTexture(), + m_image_texture->get_texture(), ImVec2(m_file_size, m_file_size), ImVec2 { 0.0f, 0.0f }, ImVec2 { 1.0f, 1.0f }, @@ -126,7 +126,7 @@ void AssetBrowserPanel::OnUserInterfaceUpdate() // Text case AssetType::Text: if (ImGui::ImageButton( - m_text_texture->GetTexture(), + m_text_texture->get_texture(), ImVec2(m_file_size, m_file_size), ImVec2 { 0.0f, 0.0f }, ImVec2 { 1.0f, 1.0f }, diff --git a/modules/mirror/src/panel/properties.cpp b/modules/mirror/src/panel/properties.cpp index 7e22d74..e6ed717 100644 --- a/modules/mirror/src/panel/properties.cpp +++ b/modules/mirror/src/panel/properties.cpp @@ -8,13 +8,13 @@ namespace Light { -void PropertiesPanel::OnUserInterfaceUpdate() +void PropertiesPanel::on_user_interface_update() { ImGui::Begin("Properties"); - if (m_entity_context.IsValid()) + if (m_entity_context.is_valid()) { - if (m_entity_context.HasComponent()) + if (m_entity_context.has_component()) { auto &tagComponent = m_entity_context.GetComponent(); @@ -37,18 +37,18 @@ void PropertiesPanel::OnUserInterfaceUpdate() if (ImGui::Selectable( "SpriteRenderer", false, - m_entity_context.HasComponent() ? + m_entity_context.has_component() ? ImGuiSelectableFlags_Disabled : NULL )) m_entity_context.AddComponent( - Light::ResourceManager::GetTexture("awesomeface") + Light::ResourceManager::get_texture("awesomeface") ); if (ImGui::Selectable( "Camera", false, - m_entity_context.HasComponent() ? + m_entity_context.has_component() ? ImGuiSelectableFlags_Disabled : NULL )) @@ -58,15 +58,15 @@ void PropertiesPanel::OnUserInterfaceUpdate() } ImGui::PopItemWidth(); - DrawComponent( + draw_component( "Transform Component", m_entity_context, [&](auto &transformComponent) { - DrawVec3Control("Translation", transformComponent.translation); + draw_vec3_control("Translation", transformComponent.translation); } ); - DrawComponent( + draw_component( "SpriteRenderer Component", m_entity_context, [&](auto &spriteRendererComponent) { @@ -74,13 +74,13 @@ void PropertiesPanel::OnUserInterfaceUpdate() } ); - DrawComponent( + draw_component( "Camera Component", m_entity_context, [&](auto &cameraComponent) { auto &camera = cameraComponent.camera; - SceneCamera::ProjectionType projectionType = camera.GetProjectionType(); + SceneCamera::ProjectionType projectionType = camera.get_projection_type(); const char *projectionTypesString[] = { "Orthographic", "Perspective" }; if (ImGui::BeginCombo("ProjectionType", projectionTypesString[(int)projectionType])) @@ -91,7 +91,7 @@ void PropertiesPanel::OnUserInterfaceUpdate() if (ImGui::Selectable(projectionTypesString[i], isSelected)) { projectionType = (SceneCamera::ProjectionType)i; - camera.SetProjectionType(projectionType); + camera.set_projection_type(projectionType); } if (isSelected) @@ -105,36 +105,36 @@ void PropertiesPanel::OnUserInterfaceUpdate() { float orthoSize, nearPlane, farPlane; - orthoSize = camera.GetOrthographicSize(); - nearPlane = camera.GetOrthographicNearPlane(); - farPlane = camera.GetOrthographicFarPlane(); + orthoSize = camera.get_orthographic_size(); + nearPlane = camera.get_orthographic_near_plane(); + farPlane = camera.get_orthographic_far_plane(); if (ImGui::DragFloat("Orthographic Size", &orthoSize)) - camera.SetOrthographicSize(orthoSize); + camera.set_orthographic_size(orthoSize); if (ImGui::DragFloat("Near Plane", &nearPlane)) - camera.SetOrthographicNearPlane(nearPlane); + camera.set_orthographic_near_plane(nearPlane); if (ImGui::DragFloat("Far Plane", &farPlane)) - camera.SetOrthographicFarPlane(farPlane); + camera.set_orthographic_far_plane(farPlane); } else // perspective { float verticalFOV, nearPlane, farPlane; - verticalFOV = glm::degrees(camera.GetPerspectiveVerticalFOV()); - nearPlane = camera.GetPerspectiveNearPlane(); - farPlane = camera.GetPerspectiveFarPlane(); + verticalFOV = glm::degrees(camera.get_perspective_vertical_fov()); + nearPlane = camera.get_perspective_near_plane(); + farPlane = camera.get_perspective_far_plane(); if (ImGui::DragFloat("Vertical FOV", &verticalFOV)) - camera.SetPerspectiveVerticalFOV(glm::radians(verticalFOV)); + camera.set_perspective_vertical_fov(glm::radians(verticalFOV)); if (ImGui::DragFloat("Near Plane", &nearPlane)) - camera.SetPerspectiveNearPlane(nearPlane); + camera.set_perspective_near_plane(nearPlane); if (ImGui::DragFloat("Far Plane", &farPlane)) - camera.SetPerspectiveFarPlane(farPlane); + camera.set_perspective_far_plane(farPlane); } ImGui::Separator(); @@ -145,12 +145,12 @@ void PropertiesPanel::OnUserInterfaceUpdate() ImGui::End(); } -void PropertiesPanel::SetEntityContext(Entity entity) +void PropertiesPanel::set_entity_context(Entity entity) { m_entity_context = entity; } -void PropertiesPanel::DrawVec3Control( +void PropertiesPanel::draw_vec3_control( const std::string &label, glm::vec3 &values, float resetValue /*= 0.0f*/, @@ -220,13 +220,13 @@ void PropertiesPanel::DrawVec3Control( template -void PropertiesPanel::DrawComponent( +void PropertiesPanel::draw_component( const std::string &name, Entity entity, UIFunction userInterfaceFunction ) { - if (!entity.HasComponent()) + if (!entity.has_component()) return; auto &component = entity.GetComponent(); @@ -252,7 +252,7 @@ void PropertiesPanel::DrawComponent( if (ImGui::BeginPopup("ComponentSettings")) { if (ImGui::Selectable("Remove component")) - entity.RemoveComponent(); + entity.remove_component(); ImGui::EndPopup(); } diff --git a/modules/mirror/src/panel/scene_hierarchy.cpp b/modules/mirror/src/panel/scene_hierarchy.cpp index 59cd9b4..e744ef1 100644 --- a/modules/mirror/src/panel/scene_hierarchy.cpp +++ b/modules/mirror/src/panel/scene_hierarchy.cpp @@ -20,7 +20,7 @@ SceneHierarchyPanel:: { } -void SceneHierarchyPanel::OnUserInterfaceUpdate() +void SceneHierarchyPanel::on_user_interface_update() { if (m_context) { @@ -31,15 +31,14 @@ void SceneHierarchyPanel::OnUserInterfaceUpdate() Entity entity(static_cast(entityID), m_context.get()); const std::string &tag = entity.GetComponent(); - DrawNode(entity, tag); + draw_node(entity, tag); }; } ImGui::End(); } -void SceneHierarchyPanel:: - SetContext(Ref context, Ref propertiesPanel /* = nullptr */) +void SceneHierarchyPanel::set_context(Ref context, Ref propertiesPanel) { if (propertiesPanel) m_properties_panel_context = propertiesPanel; @@ -47,7 +46,7 @@ void SceneHierarchyPanel:: m_context = context; } -void SceneHierarchyPanel::DrawNode(Entity entity, const std::string &label) +void SceneHierarchyPanel::draw_node(Entity entity, const std::string &label) { ImGuiTreeNodeFlags flags = (m_selection_context == entity ? ImGuiTreeNodeFlags_Selected : NULL) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth; @@ -57,7 +56,7 @@ void SceneHierarchyPanel::DrawNode(Entity entity, const std::string &label) if (ImGui::IsItemClicked()) { m_selection_context = entity; - m_properties_panel_context->SetEntityContext(entity); + m_properties_panel_context->set_entity_context(entity); } if (expanded)