style: PascalCase functions to snake_case

This commit is contained in:
light7734 2025-07-05 15:36:53 +03:30
parent 586571fcb0
commit ff56283c19
Signed by: light7734
GPG key ID: 8C30176798F1A6BA
127 changed files with 1530 additions and 1405 deletions

View file

@ -5,55 +5,55 @@
namespace Light {
// Ref (Ref)
template<typename T>
using Ref = std::shared_ptr<T>;
template<typename t>
using Ref = std::shared_ptr<t>;
template<typename T, typename... Args>
constexpr Ref<T> CreateRef(Args &&...args)
template<typename t, typename... Args>
constexpr Ref<t> create_ref(Args &&...args)
{
return std::make_shared<T>(std::forward<Args>(args)...);
return std::make_shared<t>(std::forward<Args>(args)...);
}
template<typename T>
constexpr Ref<T> MakeRef(T *rawPointer)
template<typename t>
constexpr Ref<t> make_ref(t *rawPointer)
{
return std::shared_ptr<T>(rawPointer);
return std::shared_ptr<t>(rawPointer);
}
// Scope (std::unique_ptr)
template<typename T>
using Scope = std::unique_ptr<T>;
template<typename t>
using Scope = std::unique_ptr<t>;
template<typename T, typename... Args>
constexpr std::unique_ptr<T> CreateScope(Args &&...args)
template<typename t, typename... Args>
constexpr std::unique_ptr<t> create_scope(Args &&...args)
{
return std::make_unique<T>(std::forward<Args>(args)...);
return std::make_unique<t>(std::forward<Args>(args)...);
}
template<typename T>
constexpr std::unique_ptr<T> MakeScope(T *rawPointer)
template<typename t>
constexpr std::unique_ptr<t> make_scope(t *rawPointer)
{
return std::unique_ptr<T>(rawPointer);
return std::unique_ptr<t>(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<T> 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
//======================================================================//

View file

@ -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;
}

View file

@ -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 <builtins.h>
#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 <signal.h>
#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

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -19,7 +19,7 @@ private:
static Application *s_Context;
private:
Scope<Logger> m_logger;
Scope<logger> m_logger;
Scope<Instrumentor> m_instrumentor;
Scope<LayerStack> m_layer_stack;
Scope<Input> 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();

View file

@ -23,7 +23,7 @@ protected:
bool b_Closed;
public:
static Scope<Window> Create(std::function<void(Event &)> callback);
static Scope<Window> create(std::function<void(Event &)> 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;
}

View file

@ -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)

View file

@ -26,29 +26,29 @@ private:
unsigned int m_current_session_count;
public:
static Scope<Instrumentor> Create();
static Scope<Instrumentor> 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()

View file

@ -5,19 +5,19 @@
#include <engine/base/base.hpp>
#include <spdlog/spdlog.h>
#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<spdlog::logger> m_engine_logger, m_file_logger;
std::string m_log_file_path;
public:
static Scope<Logger> Create();
static Scope<logger> create();
static inline Ref<spdlog::logger> GetEngineLogger()
static inline Ref<spdlog::logger> get_engine_logger()
{
return s_Context->m_engine_logger;
}
static inline Ref<spdlog::logger> GetFileLogger()
static inline Ref<spdlog::logger> get_file_logger()
{
return s_Context->m_file_logger;
}
void LogDebugData();
void log_debug_data();
private:
Logger();
logger();
};
} // namespace Light

View file

@ -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

View file

@ -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();
}
};

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -37,10 +37,10 @@ enum class BlendFactor : uint8_t
class Blender
{
public:
static Scope<Blender> Create(Ref<SharedContext> sharedContext);
static Scope<Blender> create(Ref<SharedContext> 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;

View file

@ -15,12 +15,12 @@ enum class ConstantBufferIndex
class ConstantBuffer
{
public:
static Scope<ConstantBuffer> Create(ConstantBufferIndex index, unsigned int size, Ref<SharedContext> sharedContext);
static Scope<ConstantBuffer> create(ConstantBufferIndex index, unsigned int size, Ref<SharedContext> 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<VertexBuffer> Create(float* vertices, unsigned int stride, unsigned int count, Ref<SharedContext> sharedContext);
static Ref<VertexBuffer> create(float* vertices, unsigned int stride, unsigned int count, Ref<SharedContext> 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<IndexBuffer> Create(unsigned int* indices, unsigned int count, Ref<SharedContext> sharedContext);
static Ref<IndexBuffer> create(unsigned int* indices, unsigned int count, Ref<SharedContext> sharedContext);
virtual ~IndexBuffer() = default;
virtual void Bind() = 0;
virtual void UnBind() = 0;
virtual void bind() = 0;
virtual void un_bind() = 0;
protected:
IndexBuffer() = default;

View file

@ -17,12 +17,12 @@ struct FramebufferSpecification
class Framebuffer
{
public:
static Ref<Framebuffer> Create(const FramebufferSpecification& specification, Ref<SharedContext> sharedContext);
static Ref<Framebuffer> create(const FramebufferSpecification& specification, Ref<SharedContext> 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;

View file

@ -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<UserInterface> m_user_interface;
Scope<Renderer> m_renderer;
Scope<renderer> m_renderer;
protected:
GraphicsAPI m_graphics_api;
Ref<SharedContext> m_shared_context = nullptr;
public:
static Scope<GraphicsContext> Create(GraphicsAPI api, GLFWwindow* windowHandle);
static Scope<GraphicsContext> 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<SharedContext> GetSharedContext() { return s_Context->m_shared_context; }
static inline GraphicsAPI get_graphics_api() { return s_Context->m_graphics_api; }
static inline Ref<SharedContext> 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:

View file

@ -12,22 +12,22 @@ class SharedContext;
class RenderCommand
{
public:
static Scope<RenderCommand> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
static Scope<RenderCommand> create(GLFWwindow *windowHandle, Ref<SharedContext> 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,

View file

@ -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<Renderer> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
static Scope<renderer> create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
static inline void DrawQuad(
static inline void draw_quad(
const glm::vec3 &position,
const glm::vec2 &size,
const glm::vec4 &tint,
Ref<Texture> 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> 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> texture)
static void draw_quad(const glm::mat4 &transform, const glm::vec4 &tint, Ref<Texture> 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> texture)
static void draw_quad(const glm::mat4 &transform, Ref<Texture> 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<Framebuffer> &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> sharedContext);
renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
void DrawQuadImpl(
void draw_quad_impl(
const glm::vec3 &position,
const glm::vec2 &size,
const glm::vec4 &tint,
Ref<Texture> 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> 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> texture);
void DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint, Ref<Texture> texture);
void DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint);
void DrawQuadImpl(const glm::mat4 &transform, Ref<Texture> texture);
void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint, Ref<Texture> texture);
void draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint);
void draw_quad_impl(const glm::mat4 &transform, Ref<Texture> texture);
void BeginSceneImpl(
void begin_scene_impl(
Camera *camera,
const glm::mat4 &cameraTransform,
const Ref<Framebuffer> &targetFrameBuffer = nullptr
);
void FlushScene();
void EndSceneImpl();
void flush_scene();
void end_scene_impl();
};
} // namespace Light

View file

@ -39,22 +39,22 @@ private:
public:
QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> 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);
}

View file

@ -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

View file

@ -39,24 +39,24 @@ private:
public:
TextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> 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);
}

View file

@ -40,24 +40,24 @@ private:
public:
TintedTextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> 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);
}

View file

@ -20,16 +20,16 @@ public:
};
public:
static Ref<Shader> Create(
BasicFileHandle vertexFile,
BasicFileHandle pixelFile,
static Ref<Shader> create(
basic_file_handle vertexFile,
basic_file_handle pixelFile,
Ref<SharedContext> sharedContext
);
virtual ~Shader() = default;
virtual void Bind() = 0;
virtual void UnBind() = 0;
virtual void bind() = 0;
virtual void un_bind() = 0;
protected:
Shader() = default;

View file

@ -10,16 +10,16 @@ class SharedContext;
class Texture
{
public:
static Ref<Texture> Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref<SharedContext> sharedContext, const std::string& filePath);
static Ref<Texture> create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref<SharedContext> 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; }

View file

@ -34,7 +34,7 @@ enum class VertexElementType
class VertexLayout
{
public:
static Ref<VertexLayout> Create(
static Ref<VertexLayout> create(
Ref<VertexBuffer> vertexBuffer,
Ref<Shader> shader,
const std::vector<std::pair<std::string, VertexElementType>> &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;

View file

@ -25,22 +25,22 @@ private:
bool m_game_events;
public:
static Scope<Input> Create();
static Scope<Input> 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

View file

@ -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,

View file

@ -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;
}

View file

@ -20,27 +20,27 @@ private:
std::vector<Layer *>::iterator m_end;
public:
static Scope<LayerStack> Create();
static Scope<LayerStack> create();
~LayerStack();
// #todo: is this needed?
template<typename T, typename... Args>
static inline void EmplaceLayer(Args &&...args)
template<typename t, typename... Args>
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

View file

@ -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);
}}

View file

@ -23,8 +23,8 @@ private:
public:
dxBlender(Ref<dxSharedContext> sharedContext);
void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override;
void Disable() override;
void enable(BlendFactor srcFactor, BlendFactor dstFactor) override;
void disable() override;
};
} // namespace Light

View file

@ -27,10 +27,10 @@ public:
Ref<dxSharedContext> 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<dxSharedContext> sharedContext);
~dxIndexBuffer();
void Bind() override;
void UnBind() override;
void bind() override;
void un_bind() override;
};
} // namespace Light

View file

@ -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

View file

@ -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

View file

@ -17,15 +17,15 @@ private:
public:
dxRenderCommand(Ref<dxSharedContext> 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

View file

@ -22,16 +22,16 @@ private:
public:
dxShader(
BasicFileHandle vertexFile,
BasicFileHandle pixelFile,
basic_file_handle vertexFile,
basic_file_handle pixelFile,
Ref<dxSharedContext> sharedContext
);
~dxShader();
void Bind() override;
void UnBind() override;
void bind() override;
void un_bind() override;
inline Microsoft::WRL::ComPtr<ID3DBlob> GetVertexBlob()
inline Microsoft::WRL::ComPtr<ID3DBlob> get_vertex_blob()
{
return m_vertex_blob;
}

View file

@ -16,19 +16,19 @@ private:
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_render_target_view = nullptr;
public:
inline Microsoft::WRL::ComPtr<ID3D11Device> GetDevice()
inline Microsoft::WRL::ComPtr<ID3D11Device> get_device()
{
return m_device;
}
inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> GetDeviceContext()
inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> get_device_context()
{
return m_deviceContext;
}
inline Microsoft::WRL::ComPtr<IDXGISwapChain> GetSwapChain()
inline Microsoft::WRL::ComPtr<IDXGISwapChain> get_swap_chain()
{
return m_swap_chain;
}
inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> GetRenderTargetView()
inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> get_render_target_view()
{
return m_render_target_view;
}

View file

@ -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

View file

@ -17,13 +17,13 @@ public:
dxUserInterface() = default;
~dxUserInterface();
void PlatformImplementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
override;
void Begin() override;
void End() override;
void begin() override;
void end() override;
void LogDebugData() override;
void log_debug_data() override;
};
} // namespace Light

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
{

View file

@ -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

View file

@ -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;
};

View file

@ -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

View file

@ -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

View file

@ -16,13 +16,13 @@ public:
glUserInterface() = default;
~glUserInterface();
void PlatformImplementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
override;
void Begin() override;
void End() override;
void begin() override;
void end() override;
void LogDebugData() override;
void log_debug_data() override;
};
} // namespace Light

View file

@ -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

View file

@ -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

View file

@ -16,9 +16,9 @@ extern "C"
namespace Light {
Scope<Window> Window::Create(std::function<void(Event &)> callback)
Scope<Window> Window::create(std::function<void(Event &)> callback)
{
return CreateScope<wWindow>(callback);
return create_scope<wWindow>(callback);
}
wWindow::wWindow(std::function<void(Event &)> callback)
@ -26,7 +26,7 @@ wWindow::wWindow(std::function<void(Event &)> 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<void(Event &)> 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 */

View file

@ -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

View file

@ -12,14 +12,14 @@ struct NativeScriptComponent
NativeScript *(*CreateInstance)();
void (*DestroyInstance)(NativeScriptComponent *);
template<typename T>
void Bind()
template<typename t>
void bind()
{
CreateInstance = []() {
return static_cast<NativeScript *>(new T());
return static_cast<NativeScript *>(new t());
};
DestroyInstance = [](NativeScriptComponent *nsc) {
delete (T *)(nsc->instance);
delete (t *)(nsc->instance);
nsc->instance = nullptr;
};
}

View file

@ -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<typename T>
T &GetComponent()
template<typename t>
t &GetComponent()
{
return m_entity.GetComponent<T>();
return m_entity.GetComponent<t>();
}
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)
{
}
};

View file

@ -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();
}
};

View file

@ -15,38 +15,39 @@ private:
public:
Entity(entt::entity handle = entt::null, Scene *registry = nullptr);
~Entity();
template<typename T, typename... Args>
inline T &AddComponent(Args &&...args)
template<typename t, typename... Args>
inline t &AddComponent(Args &&...args)
{
return m_scene->m_registry.emplace<T>(m_handle, std::forward<Args>(args)...);
return m_scene->m_registry.emplace<t>(m_handle, std::forward<Args>(args)...);
}
template<typename T>
inline T &GetComponent()
template<typename t>
inline t &GetComponent()
{
return m_scene->m_registry.get<T>(m_handle);
return m_scene->m_registry.get<t>(m_handle);
}
template<typename T>
inline bool HasComponent()
template<typename t>
inline bool has_component()
{
return m_scene->m_registry.any_of<T>(m_handle);
return m_scene->m_registry.any_of<t>(m_handle);
}
template<typename T>
inline void RemoveComponent()
template<typename t>
inline void remove_component()
{
m_scene->m_registry.remove<T>(m_handle);
m_scene->m_registry.remove<t>(m_handle);
}
inline uint64_t GetUUID()
inline uint64_t get_uuid()
{
return GetComponent<UUIDComponent>().uuid;
}
inline bool IsValid() const
inline bool is_valid() const
{
return m_handle != entt::null && m_scene != nullptr;
}

View file

@ -26,20 +26,20 @@ public:
Scene();
~Scene();
void OnCreate();
void on_create();
void OnUpdate(float deltaTime);
void OnRender(const Ref<Framebuffer> &targetFrameBuffer = nullptr);
void on_update(float deltaTime);
void on_render(const Ref<Framebuffer> &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()

View file

@ -13,7 +13,7 @@ private:
public:
Timer();
inline float GetElapsedTime() const
inline float get_elapsed_time() const
{
return (std::chrono::duration_cast<std::chrono::milliseconds>(
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;
}

View file

@ -21,33 +21,33 @@ private:
ImGuiWindowFlags m_dockspace_flags;
public:
static Scope<UserInterface> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
static Scope<UserInterface> create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
UserInterface(const UserInterface &) = delete;
UserInterface &operator=(const UserInterface &) = delete;
virtual ~UserInterface() = default;
void Init(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
void init(GLFWwindow *windowHandle, Ref<SharedContext> 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> 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

View file

@ -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

View file

@ -19,37 +19,37 @@ private:
std::unordered_map<std::string, Ref<Texture>> m_textures;
public:
static Scope<ResourceManager> Create();
static Scope<ResourceManager> 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<Shader> GetShader(const std::string &name)
static inline Ref<Shader> get_shader(const std::string &name)
{
return s_Context->m_shaders[name];
}
static inline Ref<Texture> GetTexture(const std::string &name)
static inline Ref<Texture> 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

View file

@ -12,14 +12,14 @@ class SceneSerializer
public:
SceneSerializer(const Ref<Scene> &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<Scene> m_scene;

View file

@ -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

113
modules/engine/rename.py Normal file
View file

@ -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()

View file

@ -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;
}

View file

@ -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)
{

View file

@ -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

View file

@ -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);
}

View file

@ -4,22 +4,22 @@ namespace Light {
Instrumentor *Instrumentor::s_Context = nullptr;
Scope<Instrumentor> Instrumentor::Create()
Scope<Instrumentor> Instrumentor::create()
{
return MakeScope<Instrumentor>(new Instrumentor);
return make_scope<Instrumentor>(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

View file

@ -4,19 +4,19 @@
namespace Light {
Logger *Logger::s_Context = nullptr;
logger *logger::s_Context = nullptr;
Scope<Logger> Logger::Create()
Scope<logger> logger::create()
{
return MakeScope<Logger>(new Logger());
return make_scope<logger>(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

View file

@ -10,21 +10,21 @@
namespace Light {
Scope<Blender> Blender::Create(Ref<SharedContext> sharedContext)
Scope<Blender> Blender::create(Ref<SharedContext> sharedContext)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateScope<glBlender>();
case GraphicsAPI::OpenGL: return create_scope<glBlender>();
case GraphicsAPI::DirectX:
LT_WIN(return CreateScope<dxBlender>(std::static_pointer_cast<dxSharedContext>(sharedContext
lt_win(return create_scope<dxBlender>(std::static_pointer_cast<dxSharedContext>(sharedContext
));)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
}
}

View file

@ -13,28 +13,28 @@ namespace Light {
//================================================== CONSTANT_BUFFER
//==================================================//
Scope<ConstantBuffer> ConstantBuffer::Create(
Scope<ConstantBuffer> ConstantBuffer::create(
ConstantBufferIndex index,
unsigned int size,
Ref<SharedContext> sharedContext
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateScope<glConstantBuffer>(index, size);
case GraphicsAPI::OpenGL: return create_scope<glConstantBuffer>(index, size);
case GraphicsAPI::DirectX:
LT_WIN(return CreateScope<dxConstantBuffer>(
lt_win(return create_scope<dxConstantBuffer>(
index,
size,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}
@ -44,19 +44,19 @@ Scope<ConstantBuffer> ConstantBuffer::Create(
//================================================== VERTEX_BUFFER
//==================================================//
Ref<VertexBuffer> VertexBuffer::Create(
Ref<VertexBuffer> VertexBuffer::create(
float *vertices,
unsigned int stride,
unsigned int count,
Ref<SharedContext> sharedContext
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateRef<glVertexBuffer>(vertices, stride, count);
case GraphicsAPI::OpenGL: return create_ref<glVertexBuffer>(vertices, stride, count);
case GraphicsAPI::DirectX:
LT_WIN(return CreateRef<dxVertexBuffer>(
lt_win(return create_ref<dxVertexBuffer>(
vertices,
stride,
count,
@ -64,10 +64,10 @@ Ref<VertexBuffer> VertexBuffer::Create(
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}
@ -76,28 +76,28 @@ Ref<VertexBuffer> VertexBuffer::Create(
//==================================================//
//======================================== INDEX_BUFFER ========================================//
Ref<IndexBuffer> IndexBuffer::Create(
Ref<IndexBuffer> IndexBuffer::create(
unsigned int *indices,
unsigned int count,
Ref<SharedContext> sharedContext
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateRef<glIndexBuffer>(indices, count);
case GraphicsAPI::OpenGL: return create_ref<glIndexBuffer>(indices, count);
case GraphicsAPI::DirectX:
LT_WIN(return CreateRef<dxIndexBuffer>(
lt_win(return create_ref<dxIndexBuffer>(
indices,
count,
std::dynamic_pointer_cast<dxSharedContext>(sharedContext)
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}

View file

@ -10,26 +10,26 @@
namespace Light {
Ref<Framebuffer> Framebuffer::Create(
Ref<Framebuffer> Framebuffer::create(
const FramebufferSpecification &specification,
Ref<SharedContext> sharedContext
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateRef<glFramebuffer>(specification);
case GraphicsAPI::OpenGL: return create_ref<glFramebuffer>(specification);
case GraphicsAPI::DirectX:
LT_WIN(return CreateRef<dxFramebuffer>(
lt_win(return create_ref<dxFramebuffer>(
specification,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}

View file

@ -21,7 +21,7 @@ GraphicsContext::~GraphicsContext()
{
}
Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow *windowHandle)
Scope<GraphicsContext> GraphicsContext::create(GraphicsAPI api, GLFWwindow *windowHandle)
{
// terminate 'GraphicsContext' dependent classes
if (s_Context)
@ -50,30 +50,30 @@ Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow *wind
{
// opengl
case GraphicsAPI::OpenGL:
scopeGfx = CreateScope<glGraphicsContext>(windowHandle);
scopeGfx = create_scope<glGraphicsContext>(windowHandle);
s_Context = scopeGfx.get();
break;
// directx
case GraphicsAPI::DirectX:
LT_WIN(scopeGfx = CreateScope<dxGraphicsContext>(windowHandle); s_Context = scopeGfx.get();
lt_win(scopeGfx = create_scope<dxGraphicsContext>(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);
}

View file

@ -10,25 +10,25 @@
namespace Light {
Scope<RenderCommand> RenderCommand::Create(
Scope<RenderCommand> RenderCommand::create(
GLFWwindow *windowHandle,
Ref<SharedContext> sharedContext
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateScope<glRenderCommand>(windowHandle);
case GraphicsAPI::OpenGL: return create_scope<glRenderCommand>(windowHandle);
case GraphicsAPI::DirectX:
LT_WIN(return CreateScope<dxRenderCommand>(
lt_win(return create_scope<dxRenderCommand>(
(std::static_pointer_cast<dxSharedContext>)(sharedContext)
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}

View file

@ -12,9 +12,9 @@
namespace Light {
Renderer *Renderer::s_Context = nullptr;
renderer *renderer::s_Context = nullptr;
Renderer::Renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
renderer::renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
: m_quad_renderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext)
, m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext)
, m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext)
@ -25,40 +25,40 @@ Renderer::Renderer(GLFWwindow *windowHandle, Ref<SharedContext> 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> Renderer::Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
Scope<renderer> renderer::create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
{
return MakeScope<Renderer>(new Renderer(windowHandle, sharedContext));
return make_scope<renderer>(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> 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> texture)
void renderer::draw_quad_impl(const glm::vec3 &position, const glm::vec2 &size, Ref<Texture> 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> texture)
void renderer::draw_quad_impl(const glm::mat4 &transform, Ref<Texture> 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> 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> texture)
void renderer::draw_quad_impl(const glm::mat4 &transform, const glm::vec4 &tint, Ref<Texture> 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<Framebuffer> &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();
}
}

View file

@ -17,20 +17,20 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedCon
, m_max_vertices(maxVertices)
{
// #todo: don't use relative path
ResourceManager::LoadShader(
ResourceManager::load_shader(
"LT_ENGINE_RESOURCES_QUAD_SHADER",
"Assets/Shaders/Quad/Quad_VS.glsl",
"Assets/Shaders/Quad/Quad_PS.glsl"
);
m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER");
m_shader = ResourceManager::get_shader("LT_ENGINE_RESOURCES_QUAD_SHADER");
m_vertex_buffer = Ref<VertexBuffer>(
VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)
VertexBuffer::create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)
);
m_index_buffer = Ref<IndexBuffer>(
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
IndexBuffer::create(nullptr, (maxVertices / 4) * 6, sharedContext)
);
m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
m_vertex_layout = Ref<VertexLayout>(VertexLayout::create(
m_vertex_buffer,
m_shader,
{ { "POSITION", VertexElementType::Float4 }, { "COLOR", VertexElementType::Float4 } },
@ -38,13 +38,13 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedCon
));
}
bool QuadRendererProgram::Advance()
bool QuadRendererProgram::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;
}
@ -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

View file

@ -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>(
VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)
VertexBuffer::create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)
);
m_index_buffer = Ref<IndexBuffer>(
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
IndexBuffer::create(nullptr, (maxVertices / 4) * 6, sharedContext)
);
m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
m_vertex_layout = Ref<VertexLayout>(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

View file

@ -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>(
VertexBuffer::Create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext)
VertexBuffer::create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext)
);
m_index_buffer = Ref<IndexBuffer>(
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
IndexBuffer::create(nullptr, (maxVertices / 4) * 6, sharedContext)
);
m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
m_vertex_layout = Ref<VertexLayout>(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

View file

@ -10,29 +10,29 @@
namespace Light {
Ref<Shader> Shader::Create(
BasicFileHandle vertexFile,
BasicFileHandle pixelFile,
Ref<Shader> Shader::create(
basic_file_handle vertexFile,
basic_file_handle pixelFile,
Ref<SharedContext> sharedContext
)
{
// load shader source
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateRef<glShader>(vertexFile, pixelFile);
case GraphicsAPI::OpenGL: return create_ref<glShader>(vertexFile, pixelFile);
case GraphicsAPI::DirectX:
LT_WIN(return CreateRef<dxShader>(
lt_win(return create_ref<dxShader>(
vertexFile,
pixelFile,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}

View file

@ -10,7 +10,7 @@
namespace Light {
Ref<Texture> Texture::Create(
Ref<Texture> Texture::create(
unsigned int width,
unsigned int height,
unsigned int components,
@ -19,13 +19,13 @@ Ref<Texture> Texture::Create(
const std::string &filePath
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL:
return CreateRef<glTexture>(width, height, components, pixels, filePath);
return create_ref<glTexture>(width, height, components, pixels, filePath);
case GraphicsAPI::DirectX:
LT_WIN(return CreateRef<dxTexture>(
lt_win(return create_ref<dxTexture>(
width,
height,
components,
@ -35,10 +35,10 @@ Ref<Texture> Texture::Create(
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}

View file

@ -10,29 +10,29 @@
namespace Light {
Ref<VertexLayout> VertexLayout::Create(
Ref<VertexLayout> VertexLayout::create(
Ref<VertexBuffer> vertexBuffer,
Ref<Shader> shader,
const std::vector<std::pair<std::string, VertexElementType>> &elements,
Ref<SharedContext> sharedContext
)
{
switch (GraphicsContext::GetGraphicsAPI())
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL: return CreateRef<glVertexLayout>(vertexBuffer, elements);
case GraphicsAPI::OpenGL: return create_ref<glVertexLayout>(vertexBuffer, elements);
case GraphicsAPI::DirectX:
LT_WIN(return CreateRef<dxVertexLayout>(
lt_win(return create_ref<dxVertexLayout>(
shader,
elements,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);)
default:
ASSERT(
lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}

View file

@ -10,9 +10,9 @@ namespace Light {
Input *Input::s_Context = nullptr;
Scope<Input> Input::Create()
Scope<Input> 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;

View file

@ -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);
}
}

View file

@ -9,15 +9,18 @@ namespace Light {
LayerStack *LayerStack::s_Context = nullptr;
Scope<LayerStack> LayerStack::Create()
Scope<LayerStack> LayerStack::create()
{
return MakeScope<LayerStack>(new LayerStack());
return make_scope<LayerStack>(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

View file

@ -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);
}

View file

@ -47,10 +47,10 @@ dxBlender::dxBlender(Ref<dxSharedContext> 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

View file

@ -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 ========================================//

View file

@ -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));
}

View file

@ -24,12 +24,12 @@ dxGraphicsContext::dxGraphicsContext(GLFWwindow *windowHandle)
m_shared_context = std::make_shared<dxSharedContext>();
// 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<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(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<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(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<ID3D11Resource> 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<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_shared_context);
HRESULT hr;
Microsoft::WRL::ComPtr<ID3D11Debug> debugInterface = nullptr;
DXC(context->GetDevice()->QueryInterface(__uuidof(ID3D11Debug), &debugInterface));
dxc(context->get_device()->QueryInterface(__uuidof(ID3D11Debug), &debugInterface));
Microsoft::WRL::ComPtr<ID3D11InfoQueue> 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<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(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

View file

@ -7,49 +7,49 @@ dxRenderCommand::dxRenderCommand(Ref<dxSharedContext> 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<ID3D11Resource> 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

View file

@ -5,8 +5,8 @@
namespace Light {
dxShader::dxShader(
BasicFileHandle vertexFile,
BasicFileHandle pixelFile,
basic_file_handle vertexFile,
basic_file_handle pixelFile,
Ref<dxSharedContext> sharedContext
)
: m_context(sharedContext)
@ -16,11 +16,11 @@ dxShader::dxShader(
{
Microsoft::WRL::ComPtr<ID3DBlob> 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

View file

@ -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());
}

View file

@ -11,7 +11,7 @@
namespace Light {
void dxUserInterface::PlatformImplementation(
void dxUserInterface::platform_implementation(
GLFWwindow *windowHandle,
Ref<SharedContext> sharedContext
)
@ -20,7 +20,7 @@ void dxUserInterface::PlatformImplementation(
Ref<dxSharedContext> context = std::dynamic_pointer_cast<dxSharedContext>(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

View file

@ -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<dxShader> dxpShader = std::dynamic_pointer_cast<dxShader>(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;
}
}

View file

@ -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);
}

Some files were not shown because too many files have changed in this diff Show more