style: PascalCase member variables to snake_case

This commit is contained in:
light7734 2025-07-05 14:23:01 +03:30
parent 0cedb2b0ba
commit 586571fcb0
Signed by: light7734
GPG key ID: 8C30176798F1A6BA
100 changed files with 1035 additions and 1035 deletions

View file

@ -8,27 +8,27 @@ namespace Light {
class Camera class Camera
{ {
private: private:
glm::vec4 m_BackgroundColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); glm::vec4 m_background_color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
protected: protected:
glm::mat4 m_Projection; glm::mat4 m_projection;
public: public:
Camera() = default; Camera() = default;
inline const glm::mat4 &GetProjection() const inline const glm::mat4 &GetProjection() const
{ {
return m_Projection; return m_projection;
} }
inline const glm::vec4 &GetBackgroundColor() const inline const glm::vec4 &GetBackgroundColor() const
{ {
return m_BackgroundColor; return m_background_color;
} }
inline void SetBackgroundColor(const glm::vec4 &color) inline void SetBackgroundColor(const glm::vec4 &color)
{ {
m_BackgroundColor = color; m_background_color = color;
} }
}; };

View file

@ -8,16 +8,16 @@ namespace Light {
class OrthographicCamera class OrthographicCamera
{ {
private: private:
glm::vec2 m_Position; glm::vec2 m_position;
float m_AspectRatio; float m_aspect_ratio;
float m_ZoomLevel; float m_zoom_level;
const glm::vec3 m_Up; const glm::vec3 m_up;
glm::mat4 m_Projection; glm::mat4 m_projection;
glm::mat4 m_View; glm::mat4 m_view;
glm::vec4 m_ClearColor; glm::vec4 m_clear_color;
public: public:
OrthographicCamera( OrthographicCamera(
@ -35,16 +35,16 @@ public:
inline const glm::mat4 &GetView() const inline const glm::mat4 &GetView() const
{ {
return m_View; return m_view;
} }
inline const glm::mat4 &GetProjection() const inline const glm::mat4 &GetProjection() const
{ {
return m_Projection; return m_projection;
} }
inline const glm::vec4 &GetClearColor() const inline const glm::vec4 &GetClearColor() const
{ {
return m_ClearColor; return m_clear_color;
} }
// CAMERA_CONTROLLER // // CAMERA_CONTROLLER //

View file

@ -27,11 +27,11 @@ public:
}; };
private: private:
OrthographicSpecification m_OrthographicSpecification; OrthographicSpecification m_orthographic_specification;
PerspectiveSpecification m_PerspectiveSpecification; PerspectiveSpecification m_perspective_specification;
float m_AspectRatio; float m_aspect_ratio;
ProjectionType m_ProjectionType; ProjectionType m_projection_type;
public: public:
SceneCamera(); SceneCamera();
@ -50,33 +50,33 @@ public:
inline float GetOrthographicSize() const inline float GetOrthographicSize() const
{ {
return m_OrthographicSpecification.size; return m_orthographic_specification.size;
} }
inline float GetOrthographicFarPlane() const inline float GetOrthographicFarPlane() const
{ {
return m_OrthographicSpecification.farPlane; return m_orthographic_specification.farPlane;
} }
inline float GetOrthographicNearPlane() const inline float GetOrthographicNearPlane() const
{ {
return m_OrthographicSpecification.nearPlane; return m_orthographic_specification.nearPlane;
} }
inline float GetPerspectiveVerticalFOV() const inline float GetPerspectiveVerticalFOV() const
{ {
return m_PerspectiveSpecification.verticalFOV; return m_perspective_specification.verticalFOV;
} }
inline float GetPerspectiveFarPlane() const inline float GetPerspectiveFarPlane() const
{ {
return m_PerspectiveSpecification.farPlane; return m_perspective_specification.farPlane;
} }
inline float GetPerspectiveNearPlane() const inline float GetPerspectiveNearPlane() const
{ {
return m_PerspectiveSpecification.nearPlane; return m_perspective_specification.nearPlane;
} }
inline ProjectionType GetProjectionType() const inline ProjectionType GetProjectionType() const
{ {
return m_ProjectionType; return m_projection_type;
} }
private: private:

View file

@ -19,14 +19,14 @@ private:
static Application *s_Context; static Application *s_Context;
private: private:
Scope<Logger> m_Logger; Scope<Logger> m_logger;
Scope<Instrumentor> m_Instrumentor; Scope<Instrumentor> m_instrumentor;
Scope<LayerStack> m_LayerStack; Scope<LayerStack> m_layer_stack;
Scope<Input> m_Input; Scope<Input> m_input;
Scope<ResourceManager> m_ResourceManager; Scope<ResourceManager> m_resource_manager;
protected: protected:
Scope<Window> m_Window; Scope<Window> m_window;
public: public:
Application(const Application &) = delete; Application(const Application &) = delete;

View file

@ -11,14 +11,14 @@ private:
static std::uniform_int_distribution<uint64_t> s_UniformDistribution; static std::uniform_int_distribution<uint64_t> s_UniformDistribution;
private: private:
uint64_t m_UUID; uint64_t m_uuid;
public: public:
UUID(uint64_t uuid = -1); UUID(uint64_t uuid = -1);
operator uint64_t() const operator uint64_t() const
{ {
return m_UUID; return m_uuid;
} }
}; };

View file

@ -18,14 +18,14 @@ struct WindowProperties
class Window class Window
{ {
protected: protected:
Scope<GraphicsContext> m_GraphicsContext; Scope<GraphicsContext> m_graphics_context;
WindowProperties m_Properties; WindowProperties m_properties;
bool b_Closed; bool b_Closed;
public: public:
static Scope<Window> Create(std::function<void(Event &)> callback); static Scope<Window> Create(std::function<void(Event &)> callback);
Window(): m_GraphicsContext(nullptr), m_Properties {}, b_Closed(false) Window(): m_graphics_context(nullptr), m_properties {}, b_Closed(false)
{ {
} }
@ -61,22 +61,22 @@ public:
//============================== GETTERS ==============================// //============================== GETTERS ==============================//
inline GraphicsContext *GetGfxContext() const inline GraphicsContext *GetGfxContext() const
{ {
return m_GraphicsContext.get(); return m_graphics_context.get();
} }
inline const WindowProperties &GetProperties() const inline const WindowProperties &GetProperties() const
{ {
return m_Properties; return m_properties;
} }
inline const std::string &GetTitle() const inline const std::string &GetTitle() const
{ {
return m_Properties.title; return m_properties.title;
} }
inline const glm::uvec2 &GetSize() const inline const glm::uvec2 &GetSize() const
{ {
return m_Properties.size; return m_properties.size;
} }
inline bool IsClosed() const inline bool IsClosed() const
@ -85,11 +85,11 @@ public:
} }
inline bool IsVSync() const inline bool IsVSync() const
{ {
return m_Properties.vsync; return m_properties.vsync;
} }
inline bool IsVisible() const inline bool IsVisible() const
{ {
return m_Properties.visible; return m_properties.visible;
} }
//============================== GETTERS ==============================// //============================== GETTERS ==============================//

View file

@ -21,9 +21,9 @@ private:
static Instrumentor *s_Context; static Instrumentor *s_Context;
private: private:
std::ofstream m_OutputFileStream; std::ofstream m_output_file_stream;
unsigned int m_CurrentSessionCount; unsigned int m_current_session_count;
public: public:
static Scope<Instrumentor> Create(); static Scope<Instrumentor> Create();
@ -54,8 +54,8 @@ private:
class InstrumentorTimer class InstrumentorTimer
{ {
private: private:
ScopeProfileResult m_Result; ScopeProfileResult m_result;
std::chrono::time_point<std::chrono::steady_clock> m_Start; std::chrono::time_point<std::chrono::steady_clock> m_start;
public: public:
InstrumentorTimer(const std::string &scopeName); InstrumentorTimer(const std::string &scopeName);

View file

@ -32,19 +32,19 @@ private:
static Logger *s_Context; static Logger *s_Context;
private: private:
Ref<spdlog::logger> m_EngineLogger, m_FileLogger; Ref<spdlog::logger> m_engine_logger, m_file_logger;
std::string m_LogFilePath; std::string m_log_file_path;
public: public:
static Scope<Logger> Create(); static Scope<Logger> Create();
static inline Ref<spdlog::logger> GetEngineLogger() static inline Ref<spdlog::logger> GetEngineLogger()
{ {
return s_Context->m_EngineLogger; return s_Context->m_engine_logger;
} }
static inline Ref<spdlog::logger> GetFileLogger() static inline Ref<spdlog::logger> GetFileLogger()
{ {
return s_Context->m_FileLogger; return s_Context->m_file_logger;
} }
void LogDebugData(); void LogDebugData();

View file

@ -9,22 +9,22 @@ namespace Light {
class SetCharEvent: public Event class SetCharEvent: public Event
{ {
private: private:
const unsigned int m_Character; const unsigned int m_character;
public: public:
SetCharEvent(unsigned int character): m_Character(character) SetCharEvent(unsigned int character): m_character(character)
{ {
} }
inline int GetCharacter() const inline int GetCharacter() const
{ {
return m_Character; return m_character;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "CharSet: " << m_Character; ss << "CharSet: " << m_character;
return ss.str(); return ss.str();
} }
EVENT_TYPE(SetChar) EVENT_TYPE(SetChar)

View file

@ -9,22 +9,22 @@ namespace Light {
class KeyPressedEvent: public Event class KeyPressedEvent: public Event
{ {
private: private:
const int m_Key; const int m_key;
public: public:
KeyPressedEvent(int key): m_Key(key) KeyPressedEvent(int key): m_key(key)
{ {
} }
inline int GetKey() const inline int GetKey() const
{ {
return m_Key; return m_key;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "KeyPressed: " << m_Key; ss << "KeyPressed: " << m_key;
return ss.str(); return ss.str();
} }
EVENT_TYPE(KeyPressed) EVENT_TYPE(KeyPressed)
@ -34,22 +34,22 @@ public:
class KeyRepeatEvent: public Event class KeyRepeatEvent: public Event
{ {
private: private:
const int m_Key; const int m_key;
public: public:
KeyRepeatEvent(int key): m_Key(key) KeyRepeatEvent(int key): m_key(key)
{ {
} }
inline int GetKey() const inline int GetKey() const
{ {
return m_Key; return m_key;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "KeyRepeated: " << m_Key; ss << "KeyRepeated: " << m_key;
return ss.str(); return ss.str();
} }
EVENT_TYPE(KeyRepeated) EVENT_TYPE(KeyRepeated)
@ -59,22 +59,22 @@ public:
class KeyReleasedEvent: public Event class KeyReleasedEvent: public Event
{ {
private: private:
const int m_Key; const int m_key;
public: public:
KeyReleasedEvent(int key): m_Key(key) KeyReleasedEvent(int key): m_key(key)
{ {
} }
inline int GetKey() const inline int GetKey() const
{ {
return m_Key; return m_key;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "KeyReleased: " << m_Key; ss << "KeyReleased: " << m_key;
return ss.str(); return ss.str();
} }
EVENT_TYPE(KeyReleased) EVENT_TYPE(KeyReleased)

View file

@ -10,31 +10,31 @@ namespace Light {
class MouseMovedEvent: public Event class MouseMovedEvent: public Event
{ {
private: private:
const glm::vec2 m_Position; const glm::vec2 m_position;
public: public:
MouseMovedEvent(float x, float y): m_Position(x, y) MouseMovedEvent(float x, float y): m_position(x, y)
{ {
} }
inline const glm::vec2 &GetPosition() const inline const glm::vec2 &GetPosition() const
{ {
return m_Position; return m_position;
} }
inline float GetX() const inline float GetX() const
{ {
return m_Position.x; return m_position.x;
} }
inline float GetY() const inline float GetY() const
{ {
return m_Position.y; return m_position.y;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "MouseMoved: " << m_Position.x << ", " << m_Position.y; ss << "MouseMoved: " << m_position.x << ", " << m_position.y;
return ss.str(); return ss.str();
} }
EVENT_TYPE(MouseMoved) EVENT_TYPE(MouseMoved)
@ -44,22 +44,22 @@ public:
class WheelScrolledEvent: public Event class WheelScrolledEvent: public Event
{ {
private: private:
const float m_Offset; const float m_offset;
public: public:
WheelScrolledEvent(float offset): m_Offset(offset) WheelScrolledEvent(float offset): m_offset(offset)
{ {
} }
inline float GetOffset() const inline float GetOffset() const
{ {
return m_Offset; return m_offset;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "WheelScrolled: " << m_Offset; ss << "WheelScrolled: " << m_offset;
return ss.str(); return ss.str();
} }
EVENT_TYPE(WheelScrolled) EVENT_TYPE(WheelScrolled)
@ -69,22 +69,22 @@ public:
class ButtonPressedEvent: public Event class ButtonPressedEvent: public Event
{ {
private: private:
const int m_Button; const int m_button;
public: public:
ButtonPressedEvent(int button): m_Button(button) ButtonPressedEvent(int button): m_button(button)
{ {
} }
inline int GetButton() const inline int GetButton() const
{ {
return m_Button; return m_button;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "ButtonPressed: " << m_Button; ss << "ButtonPressed: " << m_button;
return ss.str(); return ss.str();
} }
EVENT_TYPE(ButtonPressed) EVENT_TYPE(ButtonPressed)
@ -94,22 +94,22 @@ public:
class ButtonReleasedEvent: public Event class ButtonReleasedEvent: public Event
{ {
private: private:
const int m_Button; const int m_button;
public: public:
ButtonReleasedEvent(int button): m_Button(button) ButtonReleasedEvent(int button): m_button(button)
{ {
} }
inline int GetButton() const inline int GetButton() const
{ {
return m_Button; return m_button;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "ButtonReleased: " << m_Button; ss << "ButtonReleased: " << m_button;
return ss.str(); return ss.str();
} }
EVENT_TYPE(ButtonReleased) EVENT_TYPE(ButtonReleased)

View file

@ -21,22 +21,22 @@ public:
class WindowMovedEvent: public Event class WindowMovedEvent: public Event
{ {
private: private:
const glm::ivec2 m_Position; const glm::ivec2 m_position;
public: public:
WindowMovedEvent(int x, int y): m_Position(x, y) WindowMovedEvent(int x, int y): m_position(x, y)
{ {
} }
const glm::ivec2 &GetPosition() const const glm::ivec2 &GetPosition() const
{ {
return m_Position; return m_position;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "WindwoMoved: " << m_Position.x << ", " << m_Position.y; ss << "WindwoMoved: " << m_position.x << ", " << m_position.y;
return ss.str(); return ss.str();
; ;
} }
@ -47,22 +47,22 @@ public:
class WindowResizedEvent: public Event class WindowResizedEvent: public Event
{ {
private: private:
const glm::uvec2 m_Size; const glm::uvec2 m_size;
public: public:
WindowResizedEvent(unsigned int width, unsigned int height): m_Size(width, height) WindowResizedEvent(unsigned int width, unsigned int height): m_size(width, height)
{ {
} }
const glm::uvec2 &GetSize() const const glm::uvec2 &GetSize() const
{ {
return m_Size; return m_size;
} }
virtual std::string GetInfoLog() const override virtual std::string GetInfoLog() const override
{ {
std::stringstream ss; std::stringstream ss;
ss << "WindowResized: " << m_Size.x << ", " << m_Size.y; ss << "WindowResized: " << m_size.x << ", " << m_size.y;
return ss.str(); return ss.str();
} }
EVENT_TYPE(WindowResized) EVENT_TYPE(WindowResized)

View file

@ -29,12 +29,12 @@ private:
static GraphicsContext* s_Context; static GraphicsContext* s_Context;
private: private:
Scope<UserInterface> m_UserInterface; Scope<UserInterface> m_user_interface;
Scope<Renderer> m_Renderer; Scope<Renderer> m_renderer;
protected: protected:
GraphicsAPI m_GraphicsAPI; GraphicsAPI m_graphics_api;
Ref<SharedContext> m_SharedContext = nullptr; Ref<SharedContext> m_shared_context = nullptr;
public: public:
static Scope<GraphicsContext> Create(GraphicsAPI api, GLFWwindow* windowHandle); static Scope<GraphicsContext> Create(GraphicsAPI api, GLFWwindow* windowHandle);
@ -46,11 +46,11 @@ public:
virtual void LogDebugData() = 0; virtual void LogDebugData() = 0;
static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; } static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_graphics_api; }
static inline Ref<SharedContext> GetSharedContext() { return s_Context->m_SharedContext; } static inline Ref<SharedContext> GetSharedContext() { 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_UserInterface.get(); } inline UserInterface* GetUserInterface() { return m_user_interface.get(); }
protected: protected:
GraphicsContext() = default; GraphicsContext() = default;

View file

@ -31,20 +31,20 @@ private:
static Renderer *s_Context; static Renderer *s_Context;
// renderer programs // renderer programs
QuadRendererProgram m_QuadRenderer; QuadRendererProgram m_quad_renderer;
TextureRendererProgram m_TextureRenderer; TextureRendererProgram m_texture_renderer;
TintedTextureRendererProgram m_TintedTextureRenderer; TintedTextureRendererProgram m_tinted_texture_renderer;
// constant buffers // constant buffers
Scope<ConstantBuffer> m_ViewProjectionBuffer; Scope<ConstantBuffer> m_view_projection_buffer;
Scope<RenderCommand> m_RenderCommand; Scope<RenderCommand> m_render_command;
Scope<Blender> m_Blender; Scope<Blender> m_blender;
Camera *m_DefaultFramebufferCamera; Camera *m_default_framebuffer_camera;
Ref<Framebuffer> m_TargetFramebuffer; Ref<Framebuffer> m_target_framebuffer;
bool m_ShouldClearBackbuffer; bool m_should_clear_backbuffer;
public: public:
static Scope<Renderer> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext); static Scope<Renderer> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);

View file

@ -25,16 +25,16 @@ public:
}; };
private: private:
Ref<Shader> m_Shader; Ref<Shader> m_shader;
Ref<VertexBuffer> m_VertexBuffer; Ref<VertexBuffer> m_vertex_buffer;
Ref<IndexBuffer> m_IndexBuffer; Ref<IndexBuffer> m_index_buffer;
Ref<VertexLayout> m_VertexLayout; Ref<VertexLayout> m_vertex_layout;
QuadVertexData *m_MapCurrent = nullptr; QuadVertexData *m_map_current = nullptr;
QuadVertexData *m_MapEnd = nullptr; QuadVertexData *m_map_end = nullptr;
unsigned int m_QuadCount = 0u; unsigned int m_quad_count = 0u;
unsigned int m_MaxVertices = 0u; unsigned int m_max_vertices = 0u;
public: public:
QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext); QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
@ -48,11 +48,11 @@ public:
inline QuadVertexData *GetMapCurrent() inline QuadVertexData *GetMapCurrent()
{ {
return m_MapCurrent; return m_map_current;
} }
inline unsigned int GetQuadCount() const inline unsigned int GetQuadCount() const
{ {
return m_QuadCount; return m_quad_count;
} }
inline constexpr unsigned int GetVertexSize() const inline constexpr unsigned int GetVertexSize() const
{ {

View file

@ -25,16 +25,16 @@ public:
}; };
private: private:
Ref<Shader> m_Shader; Ref<Shader> m_shader;
Ref<VertexBuffer> m_VertexBuffer; Ref<VertexBuffer> m_vertex_buffer;
Ref<IndexBuffer> m_IndexBuffer; Ref<IndexBuffer> m_index_buffer;
Ref<VertexLayout> m_VertexLayout; Ref<VertexLayout> m_vertex_layout;
TextureVertexData *m_MapCurrent = nullptr; TextureVertexData *m_map_current = nullptr;
TextureVertexData *m_MapEnd = nullptr; TextureVertexData *m_map_end = nullptr;
unsigned int m_QuadCount; unsigned int m_quad_count;
unsigned int m_MaxVertices; unsigned int m_max_vertices;
public: public:
TextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext); TextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
@ -48,12 +48,12 @@ public:
inline TextureVertexData *GetMapCurrent() inline TextureVertexData *GetMapCurrent()
{ {
return m_MapCurrent; return m_map_current;
} }
inline unsigned int GetQuadCount() const inline unsigned int GetQuadCount() const
{ {
return m_QuadCount; return m_quad_count;
} }
inline constexpr unsigned int GetVertexSize() const inline constexpr unsigned int GetVertexSize() const

View file

@ -26,16 +26,16 @@ public:
}; };
private: private:
Ref<Shader> m_Shader; Ref<Shader> m_shader;
Ref<VertexBuffer> m_VertexBuffer; Ref<VertexBuffer> m_vertex_buffer;
Ref<IndexBuffer> m_IndexBuffer; Ref<IndexBuffer> m_index_buffer;
Ref<VertexLayout> m_VertexLayout; Ref<VertexLayout> m_vertex_layout;
TintedTextureVertexData *m_MapCurrent = nullptr; TintedTextureVertexData *m_map_current = nullptr;
TintedTextureVertexData *m_MapEnd = nullptr; TintedTextureVertexData *m_map_end = nullptr;
unsigned int m_QuadCount; unsigned int m_quad_count;
unsigned int m_MaxVertices; unsigned int m_max_vertices;
public: public:
TintedTextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext); TintedTextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
@ -49,12 +49,12 @@ public:
inline TintedTextureVertexData *GetMapCurrent() inline TintedTextureVertexData *GetMapCurrent()
{ {
return m_MapCurrent; return m_map_current;
} }
inline unsigned int GetQuadCount() const inline unsigned int GetQuadCount() const
{ {
return m_QuadCount; return m_quad_count;
} }
inline constexpr unsigned int GetVertexSize() const inline constexpr unsigned int GetVertexSize() const

View file

@ -21,13 +21,13 @@ public:
virtual void* GetTexture() = 0; virtual void* GetTexture() = 0;
inline const std::string& GetFilePath() const { return m_FilePath; } inline const std::string& GetFilePath() const { return m_file_path; }
protected: protected:
Texture(const std::string& filePath); Texture(const std::string& filePath);
protected: protected:
std::string m_FilePath; std::string m_file_path;
}; };
} // namespace Light } // namespace Light

View file

@ -14,15 +14,15 @@ private:
static Input *s_Context; static Input *s_Context;
private: private:
std::array<bool, 348> m_KeyboadKeys; std::array<bool, 348> m_keyboad_keys;
std::array<bool, 8> m_MouseButtons; std::array<bool, 8> m_mouse_buttons;
glm::vec2 m_MousePosition; glm::vec2 m_mouse_position;
glm::vec2 m_MouseDelta; glm::vec2 m_mouse_delta;
float m_MouseWheelDelta; float m_mouse_wheel_delta;
bool m_UserInterfaceEvents; bool m_user_interface_events;
bool m_GameEvents; bool m_game_events;
public: public:
static Scope<Input> Create(); static Scope<Input> Create();
@ -38,27 +38,27 @@ public:
static inline bool GetKeyboardKey(int code) static inline bool GetKeyboardKey(int code)
{ {
return s_Context->m_KeyboadKeys[code]; return s_Context->m_keyboad_keys[code];
} }
static inline bool GetMouseButton(int code) static inline bool GetMouseButton(int code)
{ {
return s_Context->m_MouseButtons[code]; return s_Context->m_mouse_buttons[code];
} }
static inline const glm::vec2 &GetMousePosition(int code) static inline const glm::vec2 &GetMousePosition(int code)
{ {
return s_Context->m_MousePosition; return s_Context->m_mouse_position;
} }
void OnEvent(const Event &inputEvent); void OnEvent(const Event &inputEvent);
inline bool IsReceivingInputEvents() const inline bool IsReceivingInputEvents() const
{ {
return m_UserInterfaceEvents; return m_user_interface_events;
} }
inline bool IsReceivingGameEvents() const inline bool IsReceivingGameEvents() const
{ {
return m_GameEvents; return m_game_events;
} }
private: private:

View file

@ -30,7 +30,7 @@ class WindowGainFocusEvent;
class Layer class Layer
{ {
protected: protected:
std::string m_LayerName; std::string m_layer_name;
public: public:
Layer(const std::string &name); Layer(const std::string &name);
@ -38,7 +38,7 @@ public:
inline const std::string &GetName() const inline const std::string &GetName() const
{ {
return m_LayerName; return m_layer_name;
} }
/* update */ /* update */

View file

@ -14,10 +14,10 @@ private:
static LayerStack *s_Context; static LayerStack *s_Context;
private: private:
std::vector<Layer *> m_Layers; std::vector<Layer *> m_layers;
std::vector<Layer *>::iterator m_Begin; std::vector<Layer *>::iterator m_begin;
std::vector<Layer *>::iterator m_End; std::vector<Layer *>::iterator m_end;
public: public:
static Scope<LayerStack> Create(); static Scope<LayerStack> Create();
@ -42,24 +42,24 @@ public:
inline bool IsEmpty() inline bool IsEmpty()
{ {
return m_Layers.empty(); return m_layers.empty();
} }
std::vector<Layer *>::iterator begin() std::vector<Layer *>::iterator begin()
{ {
return m_Layers.begin(); return m_layers.begin();
} }
std::vector<Layer *>::iterator end() std::vector<Layer *>::iterator end()
{ {
return m_Layers.end(); return m_layers.end();
} }
std::vector<Layer *>::reverse_iterator rbegin() std::vector<Layer *>::reverse_iterator rbegin()
{ {
return m_Layers.rbegin(); return m_layers.rbegin();
} }
std::vector<Layer *>::reverse_iterator rend() std::vector<Layer *>::reverse_iterator rend()
{ {
return m_Layers.rend(); return m_layers.rend();
} }
private: private:

View file

@ -12,13 +12,13 @@ class dxSharedContext;
class dxBlender: public Blender class dxBlender: public Blender
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
const std::unordered_map<BlendFactor, D3D11_BLEND> m_FactorMap; const std::unordered_map<BlendFactor, D3D11_BLEND> m_factor_map;
Microsoft::WRL::ComPtr<ID3D11BlendState> m_BlendState; Microsoft::WRL::ComPtr<ID3D11BlendState> m_blend_state;
D3D11_BLEND_DESC m_Desc; D3D11_BLEND_DESC m_desc;
public: public:
dxBlender(Ref<dxSharedContext> sharedContext); dxBlender(Ref<dxSharedContext> sharedContext);

View file

@ -13,12 +13,12 @@ class dxSharedContext;
class dxConstantBuffer: public ConstantBuffer class dxConstantBuffer: public ConstantBuffer
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_Buffer; Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
D3D11_MAPPED_SUBRESOURCE m_Map; D3D11_MAPPED_SUBRESOURCE m_map;
unsigned int m_Index; unsigned int m_index;
public: public:
dxConstantBuffer( dxConstantBuffer(
@ -37,12 +37,12 @@ public:
class dxVertexBuffer: public VertexBuffer class dxVertexBuffer: public VertexBuffer
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_Buffer; Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
D3D11_MAPPED_SUBRESOURCE m_Map; D3D11_MAPPED_SUBRESOURCE m_map;
unsigned int m_Stride; unsigned int m_stride;
public: public:
dxVertexBuffer( dxVertexBuffer(
@ -64,9 +64,9 @@ public:
class dxIndexBuffer: public IndexBuffer class dxIndexBuffer: public IndexBuffer
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_Buffer; Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
public: public:
dxIndexBuffer(unsigned int *indices, unsigned int count, Ref<dxSharedContext> sharedContext); dxIndexBuffer(unsigned int *indices, unsigned int count, Ref<dxSharedContext> sharedContext);

View file

@ -12,15 +12,15 @@ class dxSharedContext;
class dxFramebuffer: public Framebuffer class dxFramebuffer: public Framebuffer
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
FramebufferSpecification m_Specification; FramebufferSpecification m_specification;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView; Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_render_target_view;
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_ColorAttachment; Microsoft::WRL::ComPtr<ID3D11Texture2D> m_color_attachment;
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_DepthStencilAttachment; Microsoft::WRL::ComPtr<ID3D11Texture2D> m_depth_stencil_attachment;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_ShaderResourceView; Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_shader_resource_view;
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_DepthStencilView; Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depth_stencil_view;
public: public:
dxFramebuffer( dxFramebuffer(
@ -30,7 +30,7 @@ public:
inline void *GetColorAttachment() override inline void *GetColorAttachment() override
{ {
return (void *)m_ShaderResourceView.Get(); return (void *)m_shader_resource_view.Get();
} }
void BindAsTarget(const glm::vec4 &clearColor) override; void BindAsTarget(const glm::vec4 &clearColor) override;

View file

@ -12,9 +12,9 @@ namespace Light {
class dxGraphicsContext: public GraphicsContext class dxGraphicsContext: public GraphicsContext
{ {
private: private:
GLFWwindow *m_WindowHandle; GLFWwindow *m_window_handle;
Microsoft::WRL::ComPtr<ID3D11Debug> m_DebugInterface; Microsoft::WRL::ComPtr<ID3D11Debug> m_debug_interface;
public: public:
dxGraphicsContext(GLFWwindow *windowHandle); dxGraphicsContext(GLFWwindow *windowHandle);

View file

@ -12,7 +12,7 @@ class dxSharedContext;
class dxRenderCommand: public RenderCommand class dxRenderCommand: public RenderCommand
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
public: public:
dxRenderCommand(Ref<dxSharedContext> sharedContext); dxRenderCommand(Ref<dxSharedContext> sharedContext);

View file

@ -13,12 +13,12 @@ class dxSharedContext;
class dxShader: public Shader class dxShader: public Shader
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_VertexShader; Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertex_shader;
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_PixelShader; Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixel_shader;
Microsoft::WRL::ComPtr<ID3DBlob> m_VertexBlob; Microsoft::WRL::ComPtr<ID3DBlob> m_vertex_blob;
public: public:
dxShader( dxShader(
@ -33,7 +33,7 @@ public:
inline Microsoft::WRL::ComPtr<ID3DBlob> GetVertexBlob() inline Microsoft::WRL::ComPtr<ID3DBlob> GetVertexBlob()
{ {
return m_VertexBlob; return m_vertex_blob;
} }
}; };

View file

@ -10,44 +10,44 @@ namespace Light {
class dxSharedContext: public SharedContext class dxSharedContext: public SharedContext
{ {
private: private:
Microsoft::WRL::ComPtr<ID3D11Device> m_Device = nullptr; Microsoft::WRL::ComPtr<ID3D11Device> m_device = nullptr;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_DeviceContext = nullptr; Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_deviceContext = nullptr;
Microsoft::WRL::ComPtr<IDXGISwapChain> m_SwapChain = nullptr; Microsoft::WRL::ComPtr<IDXGISwapChain> m_swap_chain = nullptr;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView = nullptr; Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_render_target_view = nullptr;
public: public:
inline Microsoft::WRL::ComPtr<ID3D11Device> GetDevice() inline Microsoft::WRL::ComPtr<ID3D11Device> GetDevice()
{ {
return m_Device; return m_device;
} }
inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> GetDeviceContext() inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> GetDeviceContext()
{ {
return m_DeviceContext; return m_deviceContext;
} }
inline Microsoft::WRL::ComPtr<IDXGISwapChain> GetSwapChain() inline Microsoft::WRL::ComPtr<IDXGISwapChain> GetSwapChain()
{ {
return m_SwapChain; return m_swap_chain;
} }
inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> GetRenderTargetView() inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> GetRenderTargetView()
{ {
return m_RenderTargetView; return m_render_target_view;
} }
inline Microsoft::WRL::ComPtr<ID3D11Device> &GetDeviceRef() inline Microsoft::WRL::ComPtr<ID3D11Device> &GetDeviceRef()
{ {
return m_Device; return m_device;
} }
inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> &GetDeviceContextRef() inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> &GetDeviceContextRef()
{ {
return m_DeviceContext; return m_deviceContext;
} }
inline Microsoft::WRL::ComPtr<IDXGISwapChain> &GetSwapChainRef() inline Microsoft::WRL::ComPtr<IDXGISwapChain> &GetSwapChainRef()
{ {
return m_SwapChain; return m_swap_chain;
} }
inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> &GetRenderTargetViewRef() inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> &GetRenderTargetViewRef()
{ {
return m_RenderTargetView; return m_render_target_view;
} }
}; };

View file

@ -12,11 +12,11 @@ class dxSharedContext;
class dxTexture: public Texture class dxTexture: public Texture
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_Texture2D; Microsoft::WRL::ComPtr<ID3D11Texture2D> m_texture_2d;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_ShaderResourceView; Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_shader_resource_view;
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_SamplerState; Microsoft::WRL::ComPtr<ID3D11SamplerState> m_sampler_state;
public: public:
dxTexture( dxTexture(

View file

@ -14,9 +14,9 @@ class dxSharedContext;
class dxVertexLayout: public VertexLayout class dxVertexLayout: public VertexLayout
{ {
private: private:
Ref<dxSharedContext> m_Context; Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_InputLayout; Microsoft::WRL::ComPtr<ID3D11InputLayout> m_input_layout;
public: public:
dxVertexLayout( dxVertexLayout(

View file

@ -8,7 +8,7 @@ namespace Light {
class glBlender: public Blender class glBlender: public Blender
{ {
private: private:
std::unordered_map<BlendFactor, unsigned int> m_FactorMap; std::unordered_map<BlendFactor, unsigned int> m_factor_map;
public: public:
glBlender(); glBlender();

View file

@ -9,8 +9,8 @@ namespace Light {
class glConstantBuffer: public ConstantBuffer class glConstantBuffer: public ConstantBuffer
{ {
private: private:
unsigned int m_BufferID; unsigned int m_buffer_id;
unsigned int m_Index; unsigned int m_index;
public: public:
glConstantBuffer(ConstantBufferIndex index, unsigned int size); glConstantBuffer(ConstantBufferIndex index, unsigned int size);
@ -26,7 +26,7 @@ public:
class glVertexBuffer: public VertexBuffer class glVertexBuffer: public VertexBuffer
{ {
private: private:
unsigned int m_BufferID; unsigned int m_buffer_id;
public: public:
glVertexBuffer(float *vertices, unsigned int stride, unsigned int count); glVertexBuffer(float *vertices, unsigned int stride, unsigned int count);
@ -43,7 +43,7 @@ public:
class glIndexBuffer: public IndexBuffer class glIndexBuffer: public IndexBuffer
{ {
private: private:
unsigned int m_BufferID; unsigned int m_buffer_id;
public: public:
glIndexBuffer(unsigned int *indices, unsigned int count); glIndexBuffer(unsigned int *indices, unsigned int count);

View file

@ -8,10 +8,10 @@ namespace Light {
class glFramebuffer: public Framebuffer class glFramebuffer: public Framebuffer
{ {
private: private:
FramebufferSpecification m_Specification; FramebufferSpecification m_specification;
unsigned int m_BufferID; unsigned int m_buffer_id;
unsigned int m_ColorAttachmentID, m_DepthStencilAttachmentID; unsigned int m_color_attachment_id, m_depth_stencil_attachment_id;
public: public:
glFramebuffer(const FramebufferSpecification &specification); glFramebuffer(const FramebufferSpecification &specification);
@ -24,7 +24,7 @@ public:
inline void *GetColorAttachment() override inline void *GetColorAttachment() override
{ {
return (void *)m_ColorAttachmentID; return (void *)m_color_attachment_id;
} }
}; };

View file

@ -10,7 +10,7 @@ namespace Light {
class glGraphicsContext: public GraphicsContext class glGraphicsContext: public GraphicsContext
{ {
private: private:
GLFWwindow *m_WindowHandle; GLFWwindow *m_window_handle;
public: public:
glGraphicsContext(GLFWwindow *windowHandle); glGraphicsContext(GLFWwindow *windowHandle);

View file

@ -10,7 +10,7 @@ namespace Light {
class glRenderCommand: public RenderCommand class glRenderCommand: public RenderCommand
{ {
private: private:
GLFWwindow *m_WindowHandle; GLFWwindow *m_window_handle;
public: public:
glRenderCommand(GLFWwindow *windowHandle); glRenderCommand(GLFWwindow *windowHandle);

View file

@ -9,7 +9,7 @@ namespace Light {
class glShader: public Shader class glShader: public Shader
{ {
private: private:
unsigned int m_ShaderID; unsigned int m_shader_id;
public: public:
glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile); glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile);

View file

@ -8,7 +8,7 @@ namespace Light {
class glTexture: public Texture class glTexture: public Texture
{ {
private: private:
unsigned int m_TextureID; unsigned int m_texture_id;
public: public:
glTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, const std::string& filePath); glTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, const std::string& filePath);

View file

@ -10,7 +10,7 @@ namespace Light {
class glUserInterface: public UserInterface class glUserInterface: public UserInterface
{ {
private: private:
GLFWwindow *m_WindowHandle; GLFWwindow *m_window_handle;
public: public:
glUserInterface() = default; glUserInterface() = default;

View file

@ -18,7 +18,7 @@ struct glVertexElementDesc
class glVertexLayout: public VertexLayout class glVertexLayout: public VertexLayout
{ {
private: private:
unsigned int m_ArrayID; unsigned int m_array_id;
public: public:
glVertexLayout( glVertexLayout(

View file

@ -13,9 +13,9 @@ class WindowResizedEvent;
class lWindow: public Window class lWindow: public Window
{ {
private: private:
GLFWwindow *m_Handle; GLFWwindow *m_handle;
std::function<void(Event &)> m_EventCallback; std::function<void(Event &)> m_event_callback;
public: public:
lWindow(std::function<void(Event &)> callback); lWindow(std::function<void(Event &)> callback);

View file

@ -22,8 +22,8 @@ Scope<Window> Window::Create(std::function<void(Event &)> callback)
} }
wWindow::wWindow(std::function<void(Event &)> callback) wWindow::wWindow(std::function<void(Event &)> callback)
: m_Handle(nullptr) : m_handle(nullptr)
, m_EventCallback(callback) , m_event_callback(callback)
{ {
// init glfw // init glfw
ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'");
@ -34,21 +34,21 @@ wWindow::wWindow(std::function<void(Event &)> callback)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
ASSERT(m_Handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); ASSERT(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'");
// bind event stuff // bind event stuff
glfwSetWindowUserPointer(m_Handle, &m_EventCallback); glfwSetWindowUserPointer(m_handle, &m_event_callback);
BindGlfwEvents(); BindGlfwEvents();
// create graphics context // create graphics context
m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle); m_graphics_context = GraphicsContext::Create(GraphicsAPI::DirectX, m_handle);
ASSERT(m_GraphicsContext, "wWindow::wWindow: failed to create 'GraphicsContext'"); ASSERT(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'");
} }
wWindow::~wWindow() wWindow::~wWindow()
{ {
glfwDestroyWindow(m_Handle); glfwDestroyWindow(m_handle);
} }
void wWindow::PollEvents() void wWindow::PollEvents()
@ -70,16 +70,16 @@ void wWindow::OnEvent(const Event &event)
void wWindow::OnWindowResize(const WindowResizedEvent &event) void wWindow::OnWindowResize(const WindowResizedEvent &event)
{ {
m_Properties.size = event.GetSize(); m_properties.size = event.GetSize();
} }
void wWindow:: void wWindow::
SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */) SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */)
{ {
// save the visibility status and re-assign if 'overrideVisibility' is false // save the visibility status and re-assign if 'overrideVisibility' is false
bool visible = overrideVisiblity ? properties.visible : m_Properties.visible; bool visible = overrideVisiblity ? properties.visible : m_properties.visible;
m_Properties = properties; m_properties = properties;
m_Properties.visible = visible; m_properties.visible = visible;
// set properties // set properties
SetTitle(properties.title); SetTitle(properties.title);
@ -90,46 +90,46 @@ void wWindow::
void wWindow::SetTitle(const std::string &title) void wWindow::SetTitle(const std::string &title)
{ {
m_Properties.title = title; m_properties.title = title;
glfwSetWindowTitle(m_Handle, m_Properties.title.c_str()); glfwSetWindowTitle(m_handle, m_properties.title.c_str());
} }
void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */)
{ {
m_Properties.size.x = size.x == 0u ? m_Properties.size.x : m_properties.size.x = size.x == 0u ? m_properties.size.x :
additive ? m_Properties.size.x + size.x : additive ? m_properties.size.x + size.x :
size.x; size.x;
m_Properties.size.y = size.y == 0u ? m_Properties.size.y : m_properties.size.y = size.y == 0u ? m_properties.size.y :
additive ? m_Properties.size.y + size.y : additive ? m_properties.size.y + size.y :
size.y; size.y;
glfwSetWindowSize(m_Handle, size.x, size.y); glfwSetWindowSize(m_handle, size.x, size.y);
} }
void wWindow::SetVSync(bool vsync, bool toggle /* = false */) void wWindow::SetVSync(bool vsync, bool toggle /* = false */)
{ {
m_Properties.vsync = toggle ? !m_Properties.vsync : vsync; m_properties.vsync = toggle ? !m_properties.vsync : vsync;
glfwSwapInterval(m_Properties.vsync); glfwSwapInterval(m_properties.vsync);
} }
void wWindow::SetVisibility(bool visible, bool toggle) void wWindow::SetVisibility(bool visible, bool toggle)
{ {
m_Properties.visible = toggle ? !m_Properties.visible : visible; m_properties.visible = toggle ? !m_properties.visible : visible;
if (m_Properties.visible) if (m_properties.visible)
glfwShowWindow(m_Handle); glfwShowWindow(m_handle);
else else
glfwHideWindow(m_Handle); glfwHideWindow(m_handle);
} }
void wWindow::BindGlfwEvents() void wWindow::BindGlfwEvents()
{ {
//============================== MOUSE_EVENTS ==============================// //============================== MOUSE_EVENTS ==============================//
/* cursor position */ /* cursor position */
glfwSetCursorPosCallback(m_Handle, [](GLFWwindow *window, double xpos, double ypos) { glfwSetCursorPosCallback(m_handle, [](GLFWwindow *window, double xpos, double ypos) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -138,7 +138,7 @@ void wWindow::BindGlfwEvents()
}); });
/* mouse button */ /* mouse button */
glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow *window, int button, int action, int mods) { glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int mods) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -155,7 +155,7 @@ void wWindow::BindGlfwEvents()
}); });
/* scroll */ /* scroll */
glfwSetScrollCallback(m_Handle, [](GLFWwindow *window, double xoffset, double yoffset) { glfwSetScrollCallback(m_handle, [](GLFWwindow *window, double xoffset, double yoffset) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -167,7 +167,7 @@ void wWindow::BindGlfwEvents()
//============================== KEYBOARD_EVENTS ==============================// //============================== KEYBOARD_EVENTS ==============================//
/* key */ /* key */
glfwSetKeyCallback( glfwSetKeyCallback(
m_Handle, m_handle,
[](GLFWwindow *window, int key, int scancode, int action, int mods) { [](GLFWwindow *window, int key, int scancode, int action, int mods) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -185,7 +185,7 @@ void wWindow::BindGlfwEvents()
} }
); );
/* char */ /* char */
glfwSetCharCallback(m_Handle, [](GLFWwindow *window, unsigned int character) { glfwSetCharCallback(m_handle, [](GLFWwindow *window, unsigned int character) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -197,7 +197,7 @@ void wWindow::BindGlfwEvents()
//============================== WINDOW_EVENTS ==============================// //============================== WINDOW_EVENTS ==============================//
/* window position */ /* window position */
glfwSetWindowPosCallback(m_Handle, [](GLFWwindow *window, int xpos, int ypos) { glfwSetWindowPosCallback(m_handle, [](GLFWwindow *window, int xpos, int ypos) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowMovedEvent event(xpos, ypos); WindowMovedEvent event(xpos, ypos);
@ -206,7 +206,7 @@ void wWindow::BindGlfwEvents()
}); });
/* window size */ /* window size */
glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow *window, int width, int height) { glfwSetWindowSizeCallback(m_handle, [](GLFWwindow *window, int width, int height) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowResizedEvent event(width, height); WindowResizedEvent event(width, height);
@ -215,7 +215,7 @@ void wWindow::BindGlfwEvents()
}); });
/* window close */ /* window close */
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow *window) { glfwSetWindowCloseCallback(m_handle, [](GLFWwindow *window) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowClosedEvent event; WindowClosedEvent event;
@ -224,7 +224,7 @@ void wWindow::BindGlfwEvents()
}); });
/* window focus */ /* window focus */
glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow *window, int focus) { glfwSetWindowFocusCallback(m_handle, [](GLFWwindow *window, int focus) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);

View file

@ -13,9 +13,9 @@ class WindowResizedEvent;
class wWindow: public Window class wWindow: public Window
{ {
private: private:
GLFWwindow *m_Handle; GLFWwindow *m_handle;
std::function<void(Event &)> m_EventCallback; std::function<void(Event &)> m_event_callback;
public: public:
wWindow(std::function<void(Event &)> callback); wWindow(std::function<void(Event &)> callback);

View file

@ -10,8 +10,8 @@ class NativeScript
friend class Scene; friend class Scene;
private: private:
Entity m_Entity; Entity m_entity;
unsigned int m_UniqueIdentifier = 0; // :#todo unsigned int m_unique_identifier = 0; // :#todo
public: public:
NativeScript() = default; NativeScript() = default;
@ -19,13 +19,13 @@ public:
inline unsigned int GetUID() const inline unsigned int GetUID() const
{ {
return m_UniqueIdentifier; return m_unique_identifier;
} }
template<typename T> template<typename T>
T &GetComponent() T &GetComponent()
{ {
return m_Entity.GetComponent<T>(); return m_entity.GetComponent<T>();
} }
protected: protected:

View file

@ -10,8 +10,8 @@ namespace Light {
class Entity class Entity
{ {
private: private:
entt::entity m_Handle; entt::entity m_handle;
Scene *m_Scene; Scene *m_scene;
public: public:
Entity(entt::entity handle = entt::null, Scene *registry = nullptr); Entity(entt::entity handle = entt::null, Scene *registry = nullptr);
@ -20,25 +20,25 @@ public:
template<typename T, typename... Args> template<typename T, typename... Args>
inline T &AddComponent(Args &&...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> template<typename T>
inline T &GetComponent() inline T &GetComponent()
{ {
return m_Scene->m_Registry.get<T>(m_Handle); return m_scene->m_registry.get<T>(m_handle);
} }
template<typename T> template<typename T>
inline bool HasComponent() inline bool HasComponent()
{ {
return m_Scene->m_Registry.any_of<T>(m_Handle); return m_scene->m_registry.any_of<T>(m_handle);
} }
template<typename T> template<typename T>
inline void RemoveComponent() inline void RemoveComponent()
{ {
m_Scene->m_Registry.remove<T>(m_Handle); m_scene->m_registry.remove<T>(m_handle);
} }
inline uint64_t GetUUID() inline uint64_t GetUUID()
@ -48,12 +48,12 @@ public:
inline bool IsValid() const inline bool IsValid() const
{ {
return m_Handle != entt::null && m_Scene != nullptr; return m_handle != entt::null && m_scene != nullptr;
} }
operator uint32_t() operator uint32_t()
{ {
return (uint32_t)m_Handle; return (uint32_t)m_handle;
} }
}; };

View file

@ -20,7 +20,7 @@ private:
friend class SceneHierarchyPanel; friend class SceneHierarchyPanel;
private: private:
entt::registry m_Registry; entt::registry m_registry;
public: public:
Scene(); Scene();

View file

@ -8,7 +8,7 @@ namespace Light {
class Timer class Timer
{ {
private: private:
std::chrono::time_point<std::chrono::steady_clock> m_Start; std::chrono::time_point<std::chrono::steady_clock> m_start;
public: public:
Timer(); Timer();
@ -16,7 +16,7 @@ public:
inline float GetElapsedTime() const inline float GetElapsedTime() const
{ {
return (std::chrono::duration_cast<std::chrono::milliseconds>( return (std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - m_Start std::chrono::steady_clock::now() - m_start
) )
.count()) .count())
/ 1000.; / 1000.;
@ -24,7 +24,7 @@ public:
inline void Reset() inline void Reset()
{ {
m_Start = std::chrono::steady_clock::now(); m_start = std::chrono::steady_clock::now();
} }
}; };
@ -33,8 +33,8 @@ class DeltaTimer
private: private:
Timer timer; Timer timer;
float m_PreviousFrame; float m_previous_frame;
float m_DeltaTime; float m_delta_time;
public: public:
DeltaTimer(); DeltaTimer();
@ -43,7 +43,7 @@ public:
inline float GetDeltaTime() const inline float GetDeltaTime() const
{ {
return m_DeltaTime; return m_delta_time;
} }
}; };

View file

@ -18,7 +18,7 @@ private:
static UserInterface *s_Context; static UserInterface *s_Context;
private: private:
ImGuiWindowFlags m_DockspaceFlags; ImGuiWindowFlags m_dockspace_flags;
public: public:
static Scope<UserInterface> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext); static Scope<UserInterface> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);

View file

@ -20,34 +20,34 @@ public:
// getters // getters
inline uint8_t *GetData() inline uint8_t *GetData()
{ {
return m_Data; return m_data;
} }
inline uint32_t GetSize() inline uint32_t GetSize()
{ {
return m_Size; return m_size;
} }
inline const std::string &GetPath() inline const std::string &GetPath()
{ {
return m_Path; return m_path;
} }
inline const std::string &GetName() inline const std::string &GetName()
{ {
return m_Name; return m_name;
} }
inline const std::string &GetExtension() inline const std::string &GetExtension()
{ {
return m_Extension; return m_extension;
} }
inline const std::string &GetNameWithExtension() inline const std::string &GetNameWithExtension()
{ {
return m_Name + '.' + m_Extension; return m_name + '.' + m_extension;
} }
inline bool IsValid() const inline bool IsValid() const
{ {
return !!m_Data; return !!m_data;
} }
// operators // operators
@ -58,11 +58,11 @@ public:
protected: protected:
// made protected for custom Free(): // made protected for custom Free():
uint8_t *m_Data; uint8_t *m_data;
uint32_t m_Size; uint32_t m_size;
private: private:
const std::string m_Path, m_Name, m_Extension; const std::string m_path, m_name, m_extension;
}; };
class ImageFileHandle: public BasicFileHandle class ImageFileHandle: public BasicFileHandle
@ -80,10 +80,10 @@ public:
uint32_t desiredComponents uint32_t desiredComponents
) )
: BasicFileHandle(data, size, path, name, extension) : BasicFileHandle(data, size, path, name, extension)
, m_Width(width) , m_width(width)
, m_Height(height) , m_height(height)
, m_Components(components) , m_components(components)
, m_DesiredComponents(desiredComponents) , m_desired_components(desiredComponents)
{ {
} }
@ -92,23 +92,23 @@ public:
// getters // getters
inline uint32_t GetWidth() const inline uint32_t GetWidth() const
{ {
return m_Width; return m_width;
} }
inline uint32_t GetHeight() const inline uint32_t GetHeight() const
{ {
return m_Height; return m_height;
} }
inline uint32_t GetComponents() const inline uint32_t GetComponents() const
{ {
return m_Components; return m_components;
} }
inline uint32_t GetDesiredComponents() const inline uint32_t GetDesiredComponents() const
{ {
return m_DesiredComponents; return m_desired_components;
} }
private: private:
uint32_t m_Width, m_Height, m_Components, m_DesiredComponents; uint32_t m_width, m_height, m_components, m_desired_components;
}; };
class FileManager class FileManager

View file

@ -15,8 +15,8 @@ private:
static ResourceManager *s_Context; static ResourceManager *s_Context;
private: private:
std::unordered_map<std::string, Ref<Shader>> m_Shaders; std::unordered_map<std::string, Ref<Shader>> m_shaders;
std::unordered_map<std::string, Ref<Texture>> m_Textures; std::unordered_map<std::string, Ref<Texture>> m_textures;
public: public:
static Scope<ResourceManager> Create(); static Scope<ResourceManager> Create();
@ -47,11 +47,11 @@ public:
static inline Ref<Shader> GetShader(const std::string &name) static inline Ref<Shader> GetShader(const std::string &name)
{ {
return s_Context->m_Shaders[name]; return s_Context->m_shaders[name];
} }
static inline Ref<Texture> GetTexture(const std::string &name) static inline Ref<Texture> GetTexture(const std::string &name)
{ {
return s_Context->m_Textures[name]; return s_Context->m_textures[name];
} }
private: private:

View file

@ -22,7 +22,7 @@ private:
void SerializeEntity(YAML::Emitter &out, Entity entity); void SerializeEntity(YAML::Emitter &out, Entity entity);
private: private:
Ref<Scene> m_Scene; Ref<Scene> m_scene;
}; };

View file

@ -10,26 +10,26 @@ OrthographicCamera::OrthographicCamera(
float zoomLevel, float zoomLevel,
const glm::vec4 &clearColor /* = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f) */ const glm::vec4 &clearColor /* = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f) */
) )
: m_Up(0.0f, 1.0f, 0.0f) : m_up(0.0f, 1.0f, 0.0f)
, m_Position(position) , m_position(position)
, m_AspectRatio(aspectRatio) , m_aspect_ratio(aspectRatio)
, m_ZoomLevel(zoomLevel) , m_zoom_level(zoomLevel)
, m_ClearColor(clearColor) , m_clear_color(clearColor)
{ {
} }
void OrthographicCamera::CalculateView() void OrthographicCamera::CalculateView()
{ {
m_View = glm::lookAt(glm::vec3(m_Position, 100.0f), glm::vec3(m_Position, 0.0f), m_Up); m_view = glm::lookAt(glm::vec3(m_position, 100.0f), glm::vec3(m_position, 0.0f), m_up);
} }
void OrthographicCamera::CalculateProjection() void OrthographicCamera::CalculateProjection()
{ {
m_Projection = glm::ortho( m_projection = glm::ortho(
-m_ZoomLevel * m_AspectRatio, -m_zoom_level * m_aspect_ratio,
+m_ZoomLevel * m_AspectRatio, +m_zoom_level * m_aspect_ratio,
-m_ZoomLevel, -m_zoom_level,
+m_ZoomLevel, +m_zoom_level,
FLT_MAX, FLT_MAX,
FLT_MIN FLT_MIN
); );
@ -37,13 +37,13 @@ void OrthographicCamera::CalculateProjection()
void OrthographicCamera::OnResize(const glm::vec2 &size) void OrthographicCamera::OnResize(const glm::vec2 &size)
{ {
m_AspectRatio = size.x / size.y; m_aspect_ratio = size.x / size.y;
CalculateProjection(); CalculateProjection();
} }
void OrthographicCamera::Move(const glm::vec2 &position) void OrthographicCamera::Move(const glm::vec2 &position)
{ {
m_Position += position; m_position += position;
} }
} // namespace Light } // namespace Light

View file

@ -4,82 +4,82 @@
namespace Light { namespace Light {
SceneCamera::SceneCamera() SceneCamera::SceneCamera()
: m_OrthographicSpecification { 1000.0f, -1.0f, 10000.0f } : m_orthographic_specification { 1000.0f, -1.0f, 10000.0f }
, m_PerspectiveSpecification { glm::radians(45.0f), 0.01f, 10000.0f } , m_perspective_specification { glm::radians(45.0f), 0.01f, 10000.0f }
, m_AspectRatio(16.0f / 9.0f) , m_aspect_ratio(16.0f / 9.0f)
, m_ProjectionType(ProjectionType::Orthographic) , m_projection_type(ProjectionType::Orthographic)
{ {
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetViewportSize(unsigned int width, unsigned int height) void SceneCamera::SetViewportSize(unsigned int width, unsigned int height)
{ {
m_AspectRatio = width / (float)height; m_aspect_ratio = width / (float)height;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetProjectionType(ProjectionType projectionType) void SceneCamera::SetProjectionType(ProjectionType projectionType)
{ {
m_ProjectionType = projectionType; m_projection_type = projectionType;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetOrthographicSize(float size) void SceneCamera::SetOrthographicSize(float size)
{ {
m_OrthographicSpecification.size = size; m_orthographic_specification.size = size;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetOrthographicFarPlane(float farPlane) void SceneCamera::SetOrthographicFarPlane(float farPlane)
{ {
m_OrthographicSpecification.farPlane = farPlane; m_orthographic_specification.farPlane = farPlane;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetOrthographicNearPlane(float nearPlane) void SceneCamera::SetOrthographicNearPlane(float nearPlane)
{ {
m_OrthographicSpecification.nearPlane = nearPlane; m_orthographic_specification.nearPlane = nearPlane;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetPerspectiveVerticalFOV(float verticalFOV) void SceneCamera::SetPerspectiveVerticalFOV(float verticalFOV)
{ {
m_PerspectiveSpecification.verticalFOV = verticalFOV; m_perspective_specification.verticalFOV = verticalFOV;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetPerspectiveFarPlane(float farPlane) void SceneCamera::SetPerspectiveFarPlane(float farPlane)
{ {
m_PerspectiveSpecification.farPlane = farPlane; m_perspective_specification.farPlane = farPlane;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::SetPerspectiveNearPlane(float nearPlane) void SceneCamera::SetPerspectiveNearPlane(float nearPlane)
{ {
m_PerspectiveSpecification.nearPlane = nearPlane; m_perspective_specification.nearPlane = nearPlane;
CalculateProjection(); CalculateProjection();
} }
void SceneCamera::CalculateProjection() void SceneCamera::CalculateProjection()
{ {
if (m_ProjectionType == ProjectionType::Orthographic) if (m_projection_type == ProjectionType::Orthographic)
{ {
m_Projection = glm::ortho( m_projection = glm::ortho(
-m_OrthographicSpecification.size * 0.5f * m_AspectRatio, -m_orthographic_specification.size * 0.5f * m_aspect_ratio,
m_OrthographicSpecification.size * 0.5f * m_AspectRatio, m_orthographic_specification.size * 0.5f * m_aspect_ratio,
-m_OrthographicSpecification.size * 0.5f, -m_orthographic_specification.size * 0.5f,
m_OrthographicSpecification.size * 0.5f, m_orthographic_specification.size * 0.5f,
m_OrthographicSpecification.farPlane, m_orthographic_specification.farPlane,
m_OrthographicSpecification.nearPlane m_orthographic_specification.nearPlane
); );
} }
else // perspective else // perspective
{ {
m_Projection = glm::perspective( m_projection = glm::perspective(
m_PerspectiveSpecification.verticalFOV, m_perspective_specification.verticalFOV,
m_AspectRatio, m_aspect_ratio,
m_PerspectiveSpecification.nearPlane, m_perspective_specification.nearPlane,
m_PerspectiveSpecification.farPlane m_perspective_specification.farPlane
); );
} }
} }

View file

@ -14,101 +14,101 @@ namespace Light {
Application *Application::s_Context = nullptr; Application *Application::s_Context = nullptr;
Application::Application() Application::Application()
: m_Instrumentor(nullptr) : m_instrumentor(nullptr)
, m_LayerStack(nullptr) , m_layer_stack(nullptr)
, m_Input(nullptr) , m_input(nullptr)
, m_Window(nullptr) , m_window(nullptr)
{ {
ASSERT(!s_Context, "Repeated singleton construction"); ASSERT(!s_Context, "Repeated singleton construction");
s_Context = this; s_Context = this;
m_Logger = Logger::Create(); m_logger = Logger::Create();
LogDebugData(); LogDebugData();
m_Instrumentor = Instrumentor::Create(); m_instrumentor = Instrumentor::Create();
m_Instrumentor->BeginSession("Logs/ProfileResults_Startup.json"); m_instrumentor->BeginSession("Logs/ProfileResults_Startup.json");
m_LayerStack = LayerStack::Create(); m_layer_stack = LayerStack::Create();
m_Input = Input::Create(); m_input = Input::Create();
m_ResourceManager = 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::OnEvent, this, std::placeholders::_1));
} }
Application::~Application() Application::~Application()
{ {
LOG(trace, "Application::~Application()"); LOG(trace, "Application::~Application()");
m_Instrumentor->EndSession(); // ProfileResults_Termination // m_instrumentor->EndSession(); // ProfileResults_Termination //
} }
void Application::GameLoop() void Application::GameLoop()
{ {
// check // check
ASSERT(!m_LayerStack->IsEmpty(), "LayerStack is empty"); ASSERT(!m_layer_stack->IsEmpty(), "LayerStack is empty");
// log debug data // log debug data
m_Logger->LogDebugData(); m_logger->LogDebugData();
m_Window->GetGfxContext()->LogDebugData(); m_window->GetGfxContext()->LogDebugData();
m_Window->GetGfxContext()->GetUserInterface()->LogDebugData(); m_window->GetGfxContext()->GetUserInterface()->LogDebugData();
// reveal window // reveal window
m_Window->SetVisibility(true); m_window->SetVisibility(true);
m_Instrumentor->EndSession(); // ProfileResults_GameLoop // m_instrumentor->EndSession(); // ProfileResults_GameLoop //
m_Instrumentor->BeginSession("Logs/ProfileResults_GameLoop.json"); m_instrumentor->BeginSession("Logs/ProfileResults_GameLoop.json");
/* game loop */ /* game loop */
DeltaTimer deltaTimer; DeltaTimer deltaTimer;
while (!m_Window->IsClosed()) while (!m_window->IsClosed())
{ {
{ {
// update layers // update layers
LT_PROFILE_SCOPE("GameLoop::Update"); LT_PROFILE_SCOPE("GameLoop::Update");
for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++)
(*it)->OnUpdate(deltaTimer.GetDeltaTime()); (*it)->OnUpdate(deltaTimer.GetDeltaTime());
} }
{ {
// render layers // render layers
LT_PROFILE_SCOPE("GameLoop::Render"); LT_PROFILE_SCOPE("GameLoop::Render");
m_Window->GetGfxContext()->GetRenderer()->BeginFrame(); m_window->GetGfxContext()->GetRenderer()->BeginFrame();
for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++)
(*it)->OnRender(); (*it)->OnRender();
m_Window->GetGfxContext()->GetRenderer()->EndFrame(); m_window->GetGfxContext()->GetRenderer()->EndFrame();
} }
{ {
// render user interface // render user interface
LT_PROFILE_SCOPE("GameLoop::UserInterface"); LT_PROFILE_SCOPE("GameLoop::UserInterface");
m_Window->GetGfxContext()->GetUserInterface()->Begin(); m_window->GetGfxContext()->GetUserInterface()->Begin();
for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) for (auto it = m_layer_stack->begin(); it != m_layer_stack->end(); it++)
(*it)->OnUserInterfaceUpdate(); (*it)->OnUserInterfaceUpdate();
m_Window->GetGfxContext()->GetUserInterface()->End(); m_window->GetGfxContext()->GetUserInterface()->End();
} }
{ {
// poll events // poll events
LT_PROFILE_SCOPE("GameLoop::Events"); LT_PROFILE_SCOPE("GameLoop::Events");
m_Window->PollEvents(); m_window->PollEvents();
} }
/// update delta time /// update delta time
deltaTimer.Update(); deltaTimer.Update();
} }
m_Instrumentor->EndSession(); // ProfileResults_GameLoop // m_instrumentor->EndSession(); // ProfileResults_GameLoop //
m_Instrumentor->BeginSession("Logs/ProfileResults_Termination.json"); m_instrumentor->BeginSession("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::OnEvent(const Event &event)
@ -116,10 +116,10 @@ void Application::OnEvent(const Event &event)
// window // window
if (event.HasCategory(WindowEventCategory)) if (event.HasCategory(WindowEventCategory))
{ {
m_Window->OnEvent(event); m_window->OnEvent(event);
if (event.GetEventType() == EventType::WindowResized) if (event.GetEventType() == EventType::WindowResized)
m_Window->GetGfxContext()->GetRenderer()->OnWindowResize( m_window->GetGfxContext()->GetRenderer()->OnWindowResize(
(const WindowResizedEvent &)event (const WindowResizedEvent &)event
); );
} }
@ -127,15 +127,15 @@ void Application::OnEvent(const Event &event)
// input // input
if (event.HasCategory(InputEventCategory)) if (event.HasCategory(InputEventCategory))
{ {
m_Input->OnEvent(event); m_input->OnEvent(event);
if (!m_Input->IsReceivingGameEvents()) // return if the event is an input event and 'Input' if (!m_input->IsReceivingGameEvents()) // return if the event is an input event and 'Input'
// has disabled the game events // has disabled the game events
return; return;
} }
/* layers */ /* layers */
for (auto it = m_LayerStack->rbegin(); it != m_LayerStack->rend(); it++) for (auto it = m_layer_stack->rbegin(); it != m_layer_stack->rend(); it++)
if ((*it)->OnEvent(event)) if ((*it)->OnEvent(event))
return; return;
} }

View file

@ -5,7 +5,7 @@ namespace Light {
std::mt19937_64 UUID::s_Engine = std::mt19937_64(std::random_device()()); std::mt19937_64 UUID::s_Engine = std::mt19937_64(std::random_device()());
std::uniform_int_distribution<uint64_t> UUID::s_UniformDistribution; std::uniform_int_distribution<uint64_t> UUID::s_UniformDistribution;
UUID::UUID(uint64_t uuid /* = -1 */): m_UUID(uuid == -1 ? s_UniformDistribution(s_Engine) : uuid) UUID::UUID(uint64_t uuid /* = -1 */): m_uuid(uuid == -1 ? s_UniformDistribution(s_Engine) : uuid)
{ {
} }

View file

@ -9,7 +9,7 @@ Scope<Instrumentor> Instrumentor::Create()
return MakeScope<Instrumentor>(new Instrumentor); return MakeScope<Instrumentor>(new Instrumentor);
} }
Instrumentor::Instrumentor(): m_CurrentSessionCount(0u) Instrumentor::Instrumentor(): m_current_session_count(0u)
{ {
// #todo: maintenance // #todo: maintenance
ASSERT( ASSERT(
@ -23,42 +23,42 @@ void Instrumentor::BeginSessionImpl(const std::string &outputPath)
{ {
std::filesystem::create_directory(outputPath.substr(0, outputPath.find_last_of('/') + 1)); std::filesystem::create_directory(outputPath.substr(0, outputPath.find_last_of('/') + 1));
m_OutputFileStream.open(outputPath); m_output_file_stream.open(outputPath);
m_OutputFileStream << "{\"traceEvents\":["; m_output_file_stream << "{\"traceEvents\":[";
} }
void Instrumentor::EndSessionImpl() void Instrumentor::EndSessionImpl()
{ {
if (m_CurrentSessionCount == 0u) if (m_current_session_count == 0u)
LOG(warn, "0 profiling for the ended session"); LOG(warn, "0 profiling for the ended session");
m_CurrentSessionCount = 0u; m_current_session_count = 0u;
m_OutputFileStream << "]}"; m_output_file_stream << "]}";
m_OutputFileStream.flush(); m_output_file_stream.flush();
m_OutputFileStream.close(); m_output_file_stream.close();
} }
void Instrumentor::SubmitScopeProfileImpl(const ScopeProfileResult &profileResult) void Instrumentor::SubmitScopeProfileImpl(const ScopeProfileResult &profileResult)
{ {
if (m_CurrentSessionCount++ == 0u) if (m_current_session_count++ == 0u)
m_OutputFileStream << "{"; m_output_file_stream << "{";
else else
m_OutputFileStream << ",{"; m_output_file_stream << ",{";
m_OutputFileStream << "\"name\":\"" << profileResult.name << "\","; m_output_file_stream << "\"name\":\"" << profileResult.name << "\",";
m_OutputFileStream << "\"cat\": \"scope\","; m_output_file_stream << "\"cat\": \"scope\",";
m_OutputFileStream << "\"ph\": \"X\","; m_output_file_stream << "\"ph\": \"X\",";
m_OutputFileStream << "\"ts\":" << profileResult.start << ","; m_output_file_stream << "\"ts\":" << profileResult.start << ",";
m_OutputFileStream << "\"dur\":" << profileResult.duration << ","; m_output_file_stream << "\"dur\":" << profileResult.duration << ",";
m_OutputFileStream << "\"pid\":0,"; m_output_file_stream << "\"pid\":0,";
m_OutputFileStream << "\"tid\":" << profileResult.threadID << ""; m_output_file_stream << "\"tid\":" << profileResult.threadID << "";
m_OutputFileStream << "}"; m_output_file_stream << "}";
} }
InstrumentorTimer::InstrumentorTimer(const std::string &scopeName) InstrumentorTimer::InstrumentorTimer(const std::string &scopeName)
: m_Result({ scopeName, 0, 0, 0 }) : m_result({ scopeName, 0, 0, 0 })
, m_Start(std::chrono::steady_clock::now()) , m_start(std::chrono::steady_clock::now())
{ {
} }
@ -66,15 +66,15 @@ InstrumentorTimer::~InstrumentorTimer()
{ {
auto end = std::chrono::steady_clock::now(); auto end = std::chrono::steady_clock::now();
m_Result.start = std::chrono::time_point_cast<std::chrono::microseconds>(m_Start) m_result.start = std::chrono::time_point_cast<std::chrono::microseconds>(m_start)
.time_since_epoch() .time_since_epoch()
.count(); .count();
m_Result.duration = std::chrono::time_point_cast<std::chrono::microseconds>(end) m_result.duration = std::chrono::time_point_cast<std::chrono::microseconds>(end)
.time_since_epoch() .time_since_epoch()
.count() .count()
- m_Result.start; - m_result.start;
Instrumentor::SubmitScopeProfile(m_Result); Instrumentor::SubmitScopeProfile(m_result);
} }
} // namespace Light } // namespace Light

View file

@ -12,9 +12,9 @@ Scope<Logger> Logger::Create()
} }
Logger::Logger() Logger::Logger()
: m_EngineLogger(nullptr) : m_engine_logger(nullptr)
, m_FileLogger(nullptr) , m_file_logger(nullptr)
, m_LogFilePath(LT_LOG_FILE_LOCATION) , m_log_file_path(LT_LOG_FILE_LOCATION)
{ {
ASSERT(!s_Context, "An instance of 'Logger' already exists, do not construct this class!"); ASSERT(!s_Context, "An instance of 'Logger' already exists, do not construct this class!");
s_Context = this; s_Context = this;
@ -24,16 +24,16 @@ Logger::Logger()
spdlog::set_pattern("%^[%H:%M:%S]%g@%! ==> %v%$"); spdlog::set_pattern("%^[%H:%M:%S]%g@%! ==> %v%$");
#ifndef LIGHT_DIST #ifndef LIGHT_DIST
spdlog::set_pattern("%^[%H:%M:%S]%! ==> %v%$"); spdlog::set_pattern("%^[%H:%M:%S]%! ==> %v%$");
m_EngineLogger = spdlog::stdout_color_mt("Engine"); m_engine_logger = spdlog::stdout_color_mt("Engine");
#endif #endif
m_FileLogger = spdlog::basic_logger_mt("File", m_LogFilePath); m_file_logger = spdlog::basic_logger_mt("File", m_log_file_path);
m_FileLogger->set_pattern("%^[%M:%S:%e] <%l>: %v%$"); m_file_logger->set_pattern("%^[%M:%S:%e] <%l>: %v%$");
// set level // set level
#if defined(LIGHT_DEBUG) #if defined(LIGHT_DEBUG)
m_EngineLogger->set_level(spdlog::level::trace); m_engine_logger->set_level(spdlog::level::trace);
m_ClientLogger->set_level(spdlog::level::trace); m_client_logger->set_level(spdlog::level::trace);
#elif defined(LIGHT_RELEASE) #elif defined(LIGHT_RELEASE)
s_EngineLogger->set_level(spdlog::level::info); s_EngineLogger->set_level(spdlog::level::info);
s_ClientLogger->set_level(spdlog::level::info); s_ClientLogger->set_level(spdlog::level::info);
@ -45,8 +45,8 @@ void Logger::LogDebugData()
// #todo: improve // #todo: improve
LOG(info, "________________________________________"); LOG(info, "________________________________________");
LOG(info, "Logger::"); LOG(info, "Logger::");
LOG(info, " EngineLevel : {}", Stringifier::spdlogLevel(m_EngineLogger->level())); LOG(info, " EngineLevel : {}", Stringifier::spdlogLevel(m_engine_logger->level()));
LOG(info, " FileLevel : {}", Stringifier::spdlogLevel(m_FileLogger->level())); LOG(info, " FileLevel : {}", Stringifier::spdlogLevel(m_file_logger->level()));
LOG(info, " DefaultLevel: {}", Stringifier::spdlogLevel(spdlog::get_level())); LOG(info, " DefaultLevel: {}", Stringifier::spdlogLevel(spdlog::get_level()));
LOG(info, "________________________________________"); LOG(info, "________________________________________");
} }

View file

@ -26,8 +26,8 @@ Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow *wind
// terminate 'GraphicsContext' dependent classes // terminate 'GraphicsContext' dependent classes
if (s_Context) if (s_Context)
{ {
s_Context->m_Renderer.reset(); s_Context->m_renderer.reset();
s_Context->m_UserInterface.reset(); s_Context->m_user_interface.reset();
delete s_Context; delete s_Context;
} }
@ -68,12 +68,12 @@ Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow *wind
} }
// create 'GraphicsContext' dependent classes // create 'GraphicsContext' dependent classes
s_Context->m_UserInterface = UserInterface::Create(windowHandle, s_Context->m_SharedContext); s_Context->m_user_interface = UserInterface::Create(windowHandle, s_Context->m_shared_context);
s_Context->m_Renderer = Renderer::Create(windowHandle, s_Context->m_SharedContext); s_Context->m_renderer = Renderer::Create(windowHandle, s_Context->m_shared_context);
// check // check
ASSERT(s_Context->m_UserInterface, "Failed to create UserInterface"); ASSERT(s_Context->m_user_interface, "Failed to create UserInterface");
ASSERT(s_Context->m_Renderer, "Failed to create Renderer"); ASSERT(s_Context->m_renderer, "Failed to create Renderer");
return std::move(scopeGfx); return std::move(scopeGfx);
} }

View file

@ -15,28 +15,28 @@ 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_QuadRenderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext) : m_quad_renderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext)
, m_TextureRenderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext) , m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext)
, m_TintedTextureRenderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext) , m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext)
, m_ViewProjectionBuffer(nullptr) , m_view_projection_buffer(nullptr)
, m_RenderCommand(nullptr) , m_render_command(nullptr)
, m_Blender(nullptr) , m_blender(nullptr)
, m_DefaultFramebufferCamera(nullptr) , m_default_framebuffer_camera(nullptr)
, m_TargetFramebuffer(nullptr) , m_target_framebuffer(nullptr)
, m_ShouldClearBackbuffer(false) , m_should_clear_backbuffer(false)
{ {
ASSERT(!s_Context, "An instance of 'Renderer' already exists, do not construct this class!"); ASSERT(!s_Context, "An instance of 'Renderer' already exists, do not construct this class!");
s_Context = this; s_Context = this;
m_ViewProjectionBuffer = ConstantBuffer::Create( m_view_projection_buffer = ConstantBuffer::Create(
ConstantBufferIndex::ViewProjection, ConstantBufferIndex::ViewProjection,
sizeof(glm::mat4), sizeof(glm::mat4),
sharedContext sharedContext
); );
m_RenderCommand = RenderCommand::Create(windowHandle, sharedContext); m_render_command = RenderCommand::Create(windowHandle, sharedContext);
m_Blender = Blender::Create(sharedContext); m_blender = Blender::Create(sharedContext);
m_Blender->Enable(BlendFactor::SRC_ALPHA, BlendFactor::INVERSE_SRC_ALPHA); 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)
@ -46,7 +46,7 @@ Scope<Renderer> Renderer::Create(GLFWwindow *windowHandle, Ref<SharedContext> sh
void Renderer::OnWindowResize(const WindowResizedEvent &event) void Renderer::OnWindowResize(const WindowResizedEvent &event)
{ {
m_RenderCommand->SetViewport(0u, 0u, event.GetSize().x, event.GetSize().y); m_render_command->SetViewport(0u, 0u, event.GetSize().x, event.GetSize().y);
} }
//======================================== DRAW_QUAD ========================================// //======================================== DRAW_QUAD ========================================//
@ -91,7 +91,7 @@ void Renderer::DrawQuadImpl(const glm::vec3 &position, const glm::vec2 &size, Re
void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint) void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint)
{ {
// locals // locals
QuadRendererProgram::QuadVertexData *bufferMap = m_QuadRenderer.GetMapCurrent(); QuadRendererProgram::QuadVertexData *bufferMap = m_quad_renderer.GetMapCurrent();
// top left // top left
bufferMap[0].position = transform * glm::vec4(-0.5f, -0.5f, 0.0f, 1.0f); bufferMap[0].position = transform * glm::vec4(-0.5f, -0.5f, 0.0f, 1.0f);
@ -110,7 +110,7 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint)
bufferMap[3].tint = tint; bufferMap[3].tint = tint;
// advance // advance
if (!m_QuadRenderer.Advance()) if (!m_quad_renderer.Advance())
{ {
LOG(warn, "Exceeded LT_MAX_QUAD_RENDERER_VERTICES: {}", LT_MAX_QUAD_RENDERER_VERTICES); LOG(warn, "Exceeded LT_MAX_QUAD_RENDERER_VERTICES: {}", LT_MAX_QUAD_RENDERER_VERTICES);
FlushScene(); FlushScene();
@ -126,7 +126,7 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, Ref<Texture> texture)
texture->Bind(); texture->Bind();
// locals // locals
TextureRendererProgram::TextureVertexData *bufferMap = m_TextureRenderer.GetMapCurrent(); TextureRendererProgram::TextureVertexData *bufferMap = m_texture_renderer.GetMapCurrent();
// top left // top left
bufferMap[0].position = transform * glm::vec4(-0.5f, -0.5f, 0.0f, 1.0f); bufferMap[0].position = transform * glm::vec4(-0.5f, -0.5f, 0.0f, 1.0f);
@ -145,7 +145,7 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, Ref<Texture> texture)
bufferMap[3].texcoord = { 0.0f, 1.0f }; bufferMap[3].texcoord = { 0.0f, 1.0f };
// advance // advance
if (!m_TextureRenderer.Advance()) if (!m_texture_renderer.Advance())
{ {
LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES
); );
@ -160,7 +160,7 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint, R
texture->Bind(); texture->Bind();
// locals // locals
TintedTextureRendererProgram::TintedTextureVertexData *bufferMap = m_TintedTextureRenderer TintedTextureRendererProgram::TintedTextureVertexData *bufferMap = m_tinted_texture_renderer
.GetMapCurrent(); .GetMapCurrent();
// top left // top left
@ -184,7 +184,7 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, const glm::vec4 &tint, R
bufferMap[3].texcoord = { 0.0f, 1.0f }; bufferMap[3].texcoord = { 0.0f, 1.0f };
// advance // advance
if (!m_TintedTextureRenderer.Advance()) if (!m_tinted_texture_renderer.Advance())
{ {
LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES
); );
@ -200,13 +200,13 @@ void Renderer::BeginFrame()
void Renderer::EndFrame() void Renderer::EndFrame()
{ {
m_RenderCommand->SwapBuffers(); m_render_command->SwapBuffers();
m_RenderCommand->ClearBackBuffer( m_render_command->ClearBackBuffer(
m_DefaultFramebufferCamera ? m_DefaultFramebufferCamera->GetBackgroundColor() : m_default_framebuffer_camera ? m_default_framebuffer_camera->GetBackgroundColor() :
glm::vec4(0.0f) glm::vec4(0.0f)
); );
m_DefaultFramebufferCamera = nullptr; m_default_framebuffer_camera = nullptr;
} }
void Renderer::BeginSceneImpl( void Renderer::BeginSceneImpl(
@ -216,89 +216,89 @@ void Renderer::BeginSceneImpl(
) )
{ {
// determine the target frame buffer // determine the target frame buffer
m_TargetFramebuffer = targetFrameBuffer; m_target_framebuffer = targetFrameBuffer;
if (targetFrameBuffer) if (targetFrameBuffer)
targetFrameBuffer->BindAsTarget(camera->GetBackgroundColor()); targetFrameBuffer->BindAsTarget(camera->GetBackgroundColor());
else else
{ {
m_DefaultFramebufferCamera = camera; m_default_framebuffer_camera = camera;
m_RenderCommand->DefaultTargetFramebuffer(); m_render_command->DefaultTargetFramebuffer();
} }
// update view projection buffer // update view projection buffer
glm::mat4 *map = (glm::mat4 *)m_ViewProjectionBuffer->Map(); glm::mat4 *map = (glm::mat4 *)m_view_projection_buffer->Map();
map[0] = camera->GetProjection() * glm::inverse(cameraTransform); map[0] = camera->GetProjection() * glm::inverse(cameraTransform);
m_ViewProjectionBuffer->UnMap(); m_view_projection_buffer->UnMap();
// map renderers // map renderers
m_QuadRenderer.Map(); m_quad_renderer.Map();
m_TextureRenderer.Map(); m_texture_renderer.Map();
m_TintedTextureRenderer.Map(); m_tinted_texture_renderer.Map();
} }
void Renderer::FlushScene() void Renderer::FlushScene()
{ {
/* tinted texture renderer */ /* tinted texture renderer */
m_TintedTextureRenderer.UnMap(); m_tinted_texture_renderer.UnMap();
if (m_TintedTextureRenderer.GetQuadCount()) if (m_tinted_texture_renderer.GetQuadCount())
{ {
m_TintedTextureRenderer.Bind(); m_tinted_texture_renderer.Bind();
m_RenderCommand->DrawIndexed(m_TintedTextureRenderer.GetQuadCount() * 6u); m_render_command->DrawIndexed(m_tinted_texture_renderer.GetQuadCount() * 6u);
} }
/* quad renderer */ /* quad renderer */
m_QuadRenderer.UnMap(); m_quad_renderer.UnMap();
if (m_QuadRenderer.GetQuadCount()) if (m_quad_renderer.GetQuadCount())
{ {
m_QuadRenderer.Bind(); m_quad_renderer.Bind();
m_RenderCommand->DrawIndexed(m_QuadRenderer.GetQuadCount() * 6u); m_render_command->DrawIndexed(m_quad_renderer.GetQuadCount() * 6u);
} }
/* texture renderer */ /* texture renderer */
m_TextureRenderer.UnMap(); m_texture_renderer.UnMap();
if (m_TextureRenderer.GetQuadCount()) if (m_texture_renderer.GetQuadCount())
{ {
m_TextureRenderer.Bind(); m_texture_renderer.Bind();
m_RenderCommand->DrawIndexed(m_TextureRenderer.GetQuadCount() * 6u); m_render_command->DrawIndexed(m_texture_renderer.GetQuadCount() * 6u);
} }
m_QuadRenderer.Map(); m_quad_renderer.Map();
m_TextureRenderer.Map(); m_texture_renderer.Map();
m_TintedTextureRenderer.Map(); m_tinted_texture_renderer.Map();
} }
void Renderer::EndSceneImpl() void Renderer::EndSceneImpl()
{ {
/* tinted texture renderer */ /* tinted texture renderer */
m_TintedTextureRenderer.UnMap(); m_tinted_texture_renderer.UnMap();
if (m_TintedTextureRenderer.GetQuadCount()) if (m_tinted_texture_renderer.GetQuadCount())
{ {
m_TintedTextureRenderer.Bind(); m_tinted_texture_renderer.Bind();
m_RenderCommand->DrawIndexed(m_TintedTextureRenderer.GetQuadCount() * 6u); m_render_command->DrawIndexed(m_tinted_texture_renderer.GetQuadCount() * 6u);
} }
/* quad renderer */ /* quad renderer */
m_QuadRenderer.UnMap(); m_quad_renderer.UnMap();
if (m_QuadRenderer.GetQuadCount()) if (m_quad_renderer.GetQuadCount())
{ {
m_QuadRenderer.Bind(); m_quad_renderer.Bind();
m_RenderCommand->DrawIndexed(m_QuadRenderer.GetQuadCount() * 6u); m_render_command->DrawIndexed(m_quad_renderer.GetQuadCount() * 6u);
} }
/* texture renderer */ /* texture renderer */
m_TextureRenderer.UnMap(); m_texture_renderer.UnMap();
if (m_TextureRenderer.GetQuadCount()) if (m_texture_renderer.GetQuadCount())
{ {
m_TextureRenderer.Bind(); m_texture_renderer.Bind();
m_RenderCommand->DrawIndexed(m_TextureRenderer.GetQuadCount() * 6u); m_render_command->DrawIndexed(m_texture_renderer.GetQuadCount() * 6u);
} }
// reset frame buffer // reset frame buffer
if (m_TargetFramebuffer) if (m_target_framebuffer)
{ {
m_TargetFramebuffer = nullptr; m_target_framebuffer = nullptr;
m_RenderCommand->DefaultTargetFramebuffer(); m_render_command->DefaultTargetFramebuffer();
} }
} }

View file

@ -8,13 +8,13 @@
namespace Light { namespace Light {
QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext) QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext)
: m_Shader(nullptr) : m_shader(nullptr)
, m_IndexBuffer(nullptr) , m_index_buffer(nullptr)
, m_VertexLayout(nullptr) , m_vertex_layout(nullptr)
, m_MapCurrent(nullptr) , m_map_current(nullptr)
, m_MapEnd(nullptr) , m_map_end(nullptr)
, m_QuadCount(0u) , m_quad_count(0u)
, m_MaxVertices(maxVertices) , m_max_vertices(maxVertices)
{ {
// #todo: don't use relative path // #todo: don't use relative path
ResourceManager::LoadShader( ResourceManager::LoadShader(
@ -23,16 +23,16 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedCon
"Assets/Shaders/Quad/Quad_PS.glsl" "Assets/Shaders/Quad/Quad_PS.glsl"
); );
m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER"); m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER");
m_VertexBuffer = Ref<VertexBuffer>( m_vertex_buffer = Ref<VertexBuffer>(
VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext) VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)
); );
m_IndexBuffer = Ref<IndexBuffer>( m_index_buffer = Ref<IndexBuffer>(
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext) IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
); );
m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create( m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
m_VertexBuffer, m_vertex_buffer,
m_Shader, m_shader,
{ { "POSITION", VertexElementType::Float4 }, { "COLOR", VertexElementType::Float4 } }, { { "POSITION", VertexElementType::Float4 }, { "COLOR", VertexElementType::Float4 } },
sharedContext sharedContext
)); ));
@ -40,37 +40,37 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedCon
bool QuadRendererProgram::Advance() bool QuadRendererProgram::Advance()
{ {
m_MapCurrent += 4; m_map_current += 4;
if (m_MapCurrent >= m_MapEnd) if (m_map_current >= m_map_end)
{ {
LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_MaxVertices); LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices);
return false; return false;
} }
m_QuadCount++; m_quad_count++;
return true; return true;
} }
void QuadRendererProgram::Map() void QuadRendererProgram::Map()
{ {
m_QuadCount = 0u; m_quad_count = 0u;
m_MapCurrent = (QuadRendererProgram::QuadVertexData *)m_VertexBuffer->Map(); m_map_current = (QuadRendererProgram::QuadVertexData *)m_vertex_buffer->Map();
m_MapEnd = m_MapCurrent + m_MaxVertices; m_map_end = m_map_current + m_max_vertices;
} }
void QuadRendererProgram::UnMap() void QuadRendererProgram::UnMap()
{ {
m_VertexBuffer->UnMap(); m_vertex_buffer->UnMap();
} }
void QuadRendererProgram::Bind() void QuadRendererProgram::Bind()
{ {
m_Shader->Bind(); m_shader->Bind();
m_VertexLayout->Bind(); m_vertex_layout->Bind();
m_VertexBuffer->Bind(); m_vertex_buffer->Bind();
m_IndexBuffer->Bind(); m_index_buffer->Bind();
} }
} // namespace Light } // namespace Light

View file

@ -11,13 +11,13 @@ TextureRendererProgram::TextureRendererProgram(
unsigned int maxVertices, unsigned int maxVertices,
Ref<SharedContext> sharedContext Ref<SharedContext> sharedContext
) )
: m_Shader(nullptr) : m_shader(nullptr)
, m_IndexBuffer(nullptr) , m_index_buffer(nullptr)
, m_VertexLayout(nullptr) , m_vertex_layout(nullptr)
, m_MapCurrent(nullptr) , m_map_current(nullptr)
, m_MapEnd(nullptr) , m_map_end(nullptr)
, m_QuadCount(0u) , m_quad_count(0u)
, m_MaxVertices(maxVertices) , m_max_vertices(maxVertices)
{ {
// #todo: don't use relative path // #todo: don't use relative path
ResourceManager::LoadShader( ResourceManager::LoadShader(
@ -26,16 +26,16 @@ TextureRendererProgram::TextureRendererProgram(
"Assets/Shaders/Texture/Texture_PS.glsl" "Assets/Shaders/Texture/Texture_PS.glsl"
); );
m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER"); m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER");
m_VertexBuffer = Ref<VertexBuffer>( m_vertex_buffer = Ref<VertexBuffer>(
VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext) VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)
); );
m_IndexBuffer = Ref<IndexBuffer>( m_index_buffer = Ref<IndexBuffer>(
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext) IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
); );
m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create( m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
m_VertexBuffer, m_vertex_buffer,
m_Shader, m_shader,
{ { "POSITION", VertexElementType::Float4 }, { "TEXCOORD", VertexElementType::Float2 } }, { { "POSITION", VertexElementType::Float4 }, { "TEXCOORD", VertexElementType::Float2 } },
sharedContext sharedContext
)); ));
@ -43,36 +43,36 @@ TextureRendererProgram::TextureRendererProgram(
bool TextureRendererProgram::Advance() bool TextureRendererProgram::Advance()
{ {
if (m_MapCurrent + 4 >= m_MapEnd) if (m_map_current + 4 >= m_map_end)
{ {
LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_MaxVertices); LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices);
return false; return false;
} }
m_MapCurrent += 4; m_map_current += 4;
m_QuadCount++; m_quad_count++;
return true; return true;
} }
void TextureRendererProgram::Map() void TextureRendererProgram::Map()
{ {
m_QuadCount = 0u; m_quad_count = 0u;
m_MapCurrent = (TextureRendererProgram::TextureVertexData *)m_VertexBuffer->Map(); m_map_current = (TextureRendererProgram::TextureVertexData *)m_vertex_buffer->Map();
m_MapEnd = m_MapCurrent + m_MaxVertices; m_map_end = m_map_current + m_max_vertices;
} }
void TextureRendererProgram::UnMap() void TextureRendererProgram::UnMap()
{ {
m_VertexBuffer->UnMap(); m_vertex_buffer->UnMap();
} }
void TextureRendererProgram::Bind() void TextureRendererProgram::Bind()
{ {
m_Shader->Bind(); m_shader->Bind();
m_VertexLayout->Bind(); m_vertex_layout->Bind();
m_VertexBuffer->Bind(); m_vertex_buffer->Bind();
m_IndexBuffer->Bind(); m_index_buffer->Bind();
} }
} // namespace Light } // namespace Light

View file

@ -11,13 +11,13 @@ TintedTextureRendererProgram::TintedTextureRendererProgram(
unsigned int maxVertices, unsigned int maxVertices,
Ref<SharedContext> sharedContext Ref<SharedContext> sharedContext
) )
: m_Shader(nullptr) : m_shader(nullptr)
, m_IndexBuffer(nullptr) , m_index_buffer(nullptr)
, m_VertexLayout(nullptr) , m_vertex_layout(nullptr)
, m_MapCurrent(nullptr) , m_map_current(nullptr)
, m_MapEnd(nullptr) , m_map_end(nullptr)
, m_QuadCount(0u) , m_quad_count(0u)
, m_MaxVertices(maxVertices) , m_max_vertices(maxVertices)
{ {
// #todo: don't use relative path // #todo: don't use relative path
ResourceManager::LoadShader( ResourceManager::LoadShader(
@ -26,16 +26,16 @@ TintedTextureRendererProgram::TintedTextureRendererProgram(
"Assets/Shaders/TintedTexture/TintedTexture_PS.glsl" "Assets/Shaders/TintedTexture/TintedTexture_PS.glsl"
); );
m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER"); m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER");
m_VertexBuffer = Ref<VertexBuffer>( m_vertex_buffer = Ref<VertexBuffer>(
VertexBuffer::Create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext) VertexBuffer::Create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext)
); );
m_IndexBuffer = Ref<IndexBuffer>( m_index_buffer = Ref<IndexBuffer>(
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext) IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
); );
m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create( m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
m_VertexBuffer, m_vertex_buffer,
m_Shader, m_shader,
{ { "POSITION", VertexElementType::Float4 }, { { "POSITION", VertexElementType::Float4 },
{ "TINT", VertexElementType::Float4 }, { "TINT", VertexElementType::Float4 },
{ "TEXCOORD", VertexElementType::Float2 } }, { "TEXCOORD", VertexElementType::Float2 } },
@ -45,37 +45,37 @@ TintedTextureRendererProgram::TintedTextureRendererProgram(
bool TintedTextureRendererProgram::Advance() bool TintedTextureRendererProgram::Advance()
{ {
m_MapCurrent += 4; m_map_current += 4;
if (m_MapCurrent >= m_MapEnd) if (m_map_current >= m_map_end)
{ {
LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_MaxVertices); LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_max_vertices);
return false; return false;
} }
m_QuadCount++; m_quad_count++;
return true; return true;
} }
void TintedTextureRendererProgram::Map() void TintedTextureRendererProgram::Map()
{ {
m_QuadCount = 0u; m_quad_count = 0u;
m_MapCurrent = (TintedTextureRendererProgram::TintedTextureVertexData *)m_VertexBuffer->Map(); m_map_current = (TintedTextureRendererProgram::TintedTextureVertexData *)m_vertex_buffer->Map();
m_MapEnd = m_MapCurrent + m_MaxVertices; m_map_end = m_map_current + m_max_vertices;
} }
void TintedTextureRendererProgram::UnMap() void TintedTextureRendererProgram::UnMap()
{ {
m_VertexBuffer->UnMap(); m_vertex_buffer->UnMap();
} }
void TintedTextureRendererProgram::Bind() void TintedTextureRendererProgram::Bind()
{ {
m_Shader->Bind(); m_shader->Bind();
m_VertexLayout->Bind(); m_vertex_layout->Bind();
m_VertexBuffer->Bind(); m_vertex_buffer->Bind();
m_IndexBuffer->Bind(); m_index_buffer->Bind();
} }
} // namespace Light } // namespace Light

View file

@ -44,7 +44,7 @@ Ref<Texture> Texture::Create(
} }
} }
Texture::Texture(const std::string &filePath): m_FilePath(filePath) Texture::Texture(const std::string &filePath): m_file_path(filePath)
{ {
} }

View file

@ -16,13 +16,13 @@ Scope<Input> Input::Create()
} }
Input::Input() Input::Input()
: m_KeyboadKeys {} : m_keyboad_keys {}
, m_MouseButtons {} , m_mouse_buttons {}
, m_MousePosition {} , m_mouse_position {}
, m_MouseDelta {} , m_mouse_delta {}
, m_MouseWheelDelta {} , m_mouse_wheel_delta {}
, m_UserInterfaceEvents(true) , m_user_interface_events(true)
, m_GameEvents(true) , m_game_events(true)
{ {
ASSERT( ASSERT(
!s_Context, !s_Context,
@ -35,26 +35,26 @@ Input::Input()
void Input::ReceiveUserInterfaceEventsImpl(bool receive, bool toggle /* = false */) void Input::ReceiveUserInterfaceEventsImpl(bool receive, bool toggle /* = false */)
{ {
m_UserInterfaceEvents = toggle ? !m_UserInterfaceEvents : receive; m_user_interface_events = toggle ? !m_user_interface_events : receive;
} }
void Input::ReceieveGameEventsImpl(bool receive, bool toggle /*= false*/) void Input::ReceieveGameEventsImpl(bool receive, bool toggle /*= false*/)
{ {
bool prev = m_GameEvents; bool prev = m_game_events;
m_GameEvents = toggle ? !m_UserInterfaceEvents : receive; m_game_events = toggle ? !m_user_interface_events : receive;
if (m_GameEvents != prev) if (m_game_events != prev)
RestartInputState(); RestartInputState();
} }
void Input::RestartInputState() void Input::RestartInputState()
{ {
m_KeyboadKeys.fill(false); m_keyboad_keys.fill(false);
m_MouseButtons.fill(false); m_mouse_buttons.fill(false);
m_MousePosition = glm::vec2(0.0f); m_mouse_position = glm::vec2(0.0f);
m_MouseDelta = glm::vec2(0.0f); m_mouse_delta = glm::vec2(0.0f);
m_MouseWheelDelta = 0.0f; m_mouse_wheel_delta = 0.0f;
} }
void Input::OnEvent(const Event &inputEvent) void Input::OnEvent(const Event &inputEvent)
@ -67,13 +67,13 @@ void Input::OnEvent(const Event &inputEvent)
{ {
const MouseMovedEvent &event = (const MouseMovedEvent &)inputEvent; const MouseMovedEvent &event = (const MouseMovedEvent &)inputEvent;
if (m_GameEvents) if (m_game_events)
{ {
m_MouseDelta = event.GetPosition() - m_MousePosition; m_mouse_delta = event.GetPosition() - m_mouse_position;
m_MousePosition = event.GetPosition(); m_mouse_position = event.GetPosition();
} }
if (m_UserInterfaceEvents) if (m_user_interface_events)
io.MousePos = ImVec2(event.GetX(), event.GetY()); io.MousePos = ImVec2(event.GetX(), event.GetY());
return; return;
@ -82,10 +82,10 @@ void Input::OnEvent(const Event &inputEvent)
{ {
const ButtonPressedEvent &event = (const ButtonPressedEvent &)inputEvent; const ButtonPressedEvent &event = (const ButtonPressedEvent &)inputEvent;
if (m_GameEvents) if (m_game_events)
m_MouseButtons[event.GetButton()] = true; m_mouse_buttons[event.GetButton()] = true;
if (m_UserInterfaceEvents) if (m_user_interface_events)
io.MouseDown[event.GetButton()] = true; io.MouseDown[event.GetButton()] = true;
return; return;
@ -94,10 +94,10 @@ void Input::OnEvent(const Event &inputEvent)
{ {
const ButtonReleasedEvent &event = (const ButtonReleasedEvent &)inputEvent; const ButtonReleasedEvent &event = (const ButtonReleasedEvent &)inputEvent;
if (m_GameEvents) if (m_game_events)
m_MouseButtons[event.GetButton()] = false; m_mouse_buttons[event.GetButton()] = false;
if (m_UserInterfaceEvents) if (m_user_interface_events)
io.MouseDown[event.GetButton()] = false; io.MouseDown[event.GetButton()] = false;
return; return;
@ -106,10 +106,10 @@ void Input::OnEvent(const Event &inputEvent)
{ {
const WheelScrolledEvent &event = (const WheelScrolledEvent &)inputEvent; const WheelScrolledEvent &event = (const WheelScrolledEvent &)inputEvent;
if (m_GameEvents) if (m_game_events)
m_MouseWheelDelta = event.GetOffset(); m_mouse_wheel_delta = event.GetOffset();
if (m_UserInterfaceEvents) if (m_user_interface_events)
io.MouseWheel = event.GetOffset(); io.MouseWheel = event.GetOffset();
return; return;
@ -119,10 +119,10 @@ void Input::OnEvent(const Event &inputEvent)
{ {
const KeyPressedEvent &event = (const KeyPressedEvent &)inputEvent; const KeyPressedEvent &event = (const KeyPressedEvent &)inputEvent;
if (m_GameEvents) if (m_game_events)
m_KeyboadKeys[event.GetKey()] = true; m_keyboad_keys[event.GetKey()] = true;
if (m_UserInterfaceEvents) if (m_user_interface_events)
{ {
io.KeysDown[event.GetKey()] = true; io.KeysDown[event.GetKey()] = true;
// if (event.GetKey() == Key::BackSpace) // if (event.GetKey() == Key::BackSpace)
@ -135,17 +135,17 @@ void Input::OnEvent(const Event &inputEvent)
{ {
const KeyReleasedEvent &event = (const KeyReleasedEvent &)inputEvent; const KeyReleasedEvent &event = (const KeyReleasedEvent &)inputEvent;
if (m_GameEvents) if (m_game_events)
m_KeyboadKeys[event.GetKey()] = false; m_keyboad_keys[event.GetKey()] = false;
if (m_UserInterfaceEvents) if (m_user_interface_events)
io.KeysDown[event.GetKey()] = false; io.KeysDown[event.GetKey()] = false;
return; return;
} }
case EventType::SetChar: case EventType::SetChar:
{ {
if (m_UserInterfaceEvents) if (m_user_interface_events)
{ {
const SetCharEvent &event = (const SetCharEvent &)inputEvent; const SetCharEvent &event = (const SetCharEvent &)inputEvent;
io.AddInputCharacter(event.GetCharacter()); io.AddInputCharacter(event.GetCharacter());

View file

@ -7,7 +7,7 @@
namespace Light { namespace Light {
Layer::Layer(const std::string &name): m_LayerName(name) Layer::Layer(const std::string &name): m_layer_name(name)
{ {
} }

View file

@ -14,7 +14,7 @@ Scope<LayerStack> LayerStack::Create()
return MakeScope<LayerStack>(new LayerStack()); return MakeScope<LayerStack>(new LayerStack());
} }
LayerStack::LayerStack(): m_Layers {}, m_Begin(), m_End() LayerStack::LayerStack(): m_layers {}, m_begin(), m_end()
{ {
ASSERT(!s_Context, "An instance of 'LayerStack' already exists, do not construct this class!") ASSERT(!s_Context, "An instance of 'LayerStack' already exists, do not construct this class!")
s_Context = this; s_Context = this;
@ -22,16 +22,16 @@ LayerStack::LayerStack(): m_Layers {}, m_Begin(), m_End()
LayerStack::~LayerStack() LayerStack::~LayerStack()
{ {
for (Layer *layer : m_Layers) for (Layer *layer : m_layers)
delete layer; delete layer;
} }
void LayerStack::AttachLayerImpl(Layer *layer) void LayerStack::AttachLayerImpl(Layer *layer)
{ {
// #todo: handle attaching layer inside a for loop // #todo: handle attaching layer inside a for loop
m_Layers.push_back(layer); m_layers.push_back(layer);
m_Begin = m_Layers.begin(); m_begin = m_layers.begin();
m_End = m_Layers.end(); m_end = m_layers.end();
LOG(trace, "Attached [{}]", layer->GetName()); LOG(trace, "Attached [{}]", layer->GetName());
} }
@ -39,9 +39,9 @@ void LayerStack::AttachLayerImpl(Layer *layer)
void LayerStack::DetachLayerImpl(Layer *layer) void LayerStack::DetachLayerImpl(Layer *layer)
{ {
// #todo: handle detaching layer inside a for loop // #todo: handle detaching layer inside a for loop
m_Layers.erase(std::find(m_Layers.begin(), m_Layers.end(), layer)); m_layers.erase(std::find(m_layers.begin(), m_layers.end(), layer));
m_Begin = m_Layers.begin(); m_begin = m_layers.begin();
m_End = m_Layers.end(); m_end = m_layers.end();
LOG(trace, "Detached [{}]", layer->GetName()); LOG(trace, "Detached [{}]", layer->GetName());
} }

View file

@ -4,7 +4,7 @@
namespace Light { namespace Light {
dxBlender::dxBlender(Ref<dxSharedContext> sharedContext) dxBlender::dxBlender(Ref<dxSharedContext> sharedContext)
: m_Context(sharedContext), m_FactorMap { // constants : m_context(sharedContext), m_factor_map { // constants
{ BlendFactor::ZERO, D3D11_BLEND_ZERO }, { BlendFactor::ZERO, D3D11_BLEND_ZERO },
{ BlendFactor::ONE, D3D11_BLEND_ONE }, { BlendFactor::ONE, D3D11_BLEND_ONE },
@ -29,53 +29,53 @@ dxBlender::dxBlender(Ref<dxSharedContext> sharedContext)
{ BlendFactor::SRC1_ALPHA, D3D11_BLEND_SRC1_ALPHA }, { BlendFactor::SRC1_ALPHA, D3D11_BLEND_SRC1_ALPHA },
{ BlendFactor::INVERSE_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA } { BlendFactor::INVERSE_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA }
} }
, m_BlendState(nullptr) , m_blend_state(nullptr)
, m_Desc {} , m_desc {}
{ {
// factor map // factor map
// blender desc // blender desc
m_Desc = {}; m_desc = {};
m_Desc.RenderTarget[0].BlendEnable = true; m_desc.RenderTarget[0].BlendEnable = true;
m_Desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ZERO; m_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ZERO;
m_Desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; m_desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO;
m_Desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; m_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
m_Desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; m_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
m_Desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; m_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
m_Desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; m_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
m_Desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; m_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
// create blend state // create blend state
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_blend_state));
} }
void dxBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) void dxBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor)
{ {
// update desc // update desc
m_Desc.RenderTarget[0].BlendEnable = true; m_desc.RenderTarget[0].BlendEnable = true;
m_Desc.RenderTarget[0].SrcBlend = m_FactorMap.at(srcFactor); m_desc.RenderTarget[0].SrcBlend = m_factor_map.at(srcFactor);
m_Desc.RenderTarget[0].DestBlend = m_FactorMap.at(dstFactor); m_desc.RenderTarget[0].DestBlend = m_factor_map.at(dstFactor);
// re-create blind state // re-create blind state
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_blend_state));
// bind blend state // bind blend state
m_Context->GetDeviceContext()->OMSetBlendState(m_BlendState.Get(), nullptr, 0x0000000f); m_context->GetDeviceContext()->OMSetBlendState(m_blend_state.Get(), nullptr, 0x0000000f);
} }
void dxBlender::Disable() void dxBlender::Disable()
{ {
// update desc // update desc
m_Desc.RenderTarget[0].BlendEnable = false; m_desc.RenderTarget[0].BlendEnable = false;
// re-create blind state // re-create blind state
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_blend_state));
// bind blend state // bind blend state
m_Context->GetDeviceContext()->OMSetBlendState(m_BlendState.Get(), nullptr, 0xffffffff); m_context->GetDeviceContext()->OMSetBlendState(m_blend_state.Get(), nullptr, 0xffffffff);
} }
} // namespace Light } // namespace Light

View file

@ -10,10 +10,10 @@ dxConstantBuffer::dxConstantBuffer(
unsigned int size, unsigned int size,
Ref<dxSharedContext> sharedContext Ref<dxSharedContext> sharedContext
) )
: m_Context(sharedContext) : m_context(sharedContext)
, m_Buffer(nullptr) , m_buffer(nullptr)
, m_Map {} , m_map {}
, m_Index(static_cast<int>(index)) , m_index(static_cast<int>(index))
{ {
D3D11_BUFFER_DESC bDesc = {}; D3D11_BUFFER_DESC bDesc = {};
@ -23,25 +23,25 @@ dxConstantBuffer::dxConstantBuffer(
bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_Buffer)); DXC(m_context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_buffer));
m_Context->GetDeviceContext()->VSSetConstantBuffers(m_Index, 1u, m_Buffer.GetAddressOf()); m_context->GetDeviceContext()->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->GetDeviceContext()->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()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf());
m_Context->GetDeviceContext()->Map(m_Buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_Map); m_context->GetDeviceContext()->Map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map);
return m_Map.pData; return m_map.pData;
} }
void dxConstantBuffer::UnMap() void dxConstantBuffer::UnMap()
{ {
m_Context->GetDeviceContext()->Unmap(m_Buffer.Get(), NULL); m_context->GetDeviceContext()->Unmap(m_buffer.Get(), NULL);
} }
//======================================== CONSTANT_BUFFER //======================================== CONSTANT_BUFFER
//========================================// //========================================//
@ -54,10 +54,10 @@ dxVertexBuffer::dxVertexBuffer(
unsigned int count, unsigned int count,
Ref<dxSharedContext> sharedContext Ref<dxSharedContext> sharedContext
) )
: m_Context(sharedContext) : m_context(sharedContext)
, m_Buffer(nullptr) , m_buffer(nullptr)
, m_Map {} , m_map {}
, m_Stride(stride) , m_stride(stride)
{ {
// buffer desc // buffer desc
D3D11_BUFFER_DESC bDesc = {}; D3D11_BUFFER_DESC bDesc = {};
@ -71,7 +71,7 @@ dxVertexBuffer::dxVertexBuffer(
// create buffer // create buffer
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_Buffer)); DXC(m_context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_buffer));
} }
dxVertexBuffer::~dxVertexBuffer() dxVertexBuffer::~dxVertexBuffer()
@ -81,20 +81,20 @@ dxVertexBuffer::~dxVertexBuffer()
void *dxVertexBuffer::Map() void *dxVertexBuffer::Map()
{ {
m_Context->GetDeviceContext()->Map(m_Buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_Map); m_context->GetDeviceContext()->Map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map);
return m_Map.pData; return m_map.pData;
} }
void dxVertexBuffer::UnMap() void dxVertexBuffer::UnMap()
{ {
m_Context->GetDeviceContext()->Unmap(m_Buffer.Get(), NULL); m_context->GetDeviceContext()->Unmap(m_buffer.Get(), NULL);
} }
void dxVertexBuffer::Bind() void dxVertexBuffer::Bind()
{ {
static const unsigned int offset = 0u; static const unsigned int offset = 0u;
m_Context->GetDeviceContext() m_context->GetDeviceContext()
->IASetVertexBuffers(0u, 1u, m_Buffer.GetAddressOf(), &m_Stride, &offset); ->IASetVertexBuffers(0u, 1u, m_buffer.GetAddressOf(), &m_stride, &offset);
} }
void dxVertexBuffer::UnBind() void dxVertexBuffer::UnBind()
@ -102,7 +102,7 @@ void dxVertexBuffer::UnBind()
static const unsigned int offset = 0u; static const unsigned int offset = 0u;
static ID3D11Buffer *buffer = nullptr; static ID3D11Buffer *buffer = nullptr;
m_Context->GetDeviceContext()->IASetVertexBuffers(0u, 1u, &buffer, &m_Stride, &offset); m_context->GetDeviceContext()->IASetVertexBuffers(0u, 1u, &buffer, &m_stride, &offset);
} }
//================================================== VERTEX_BUFFER //================================================== VERTEX_BUFFER
//==================================================// //==================================================//
@ -113,8 +113,8 @@ dxIndexBuffer::dxIndexBuffer(
unsigned int count, unsigned int count,
Ref<dxSharedContext> sharedContext Ref<dxSharedContext> sharedContext
) )
: m_Context(sharedContext) : m_context(sharedContext)
, m_Buffer(nullptr) , m_buffer(nullptr)
{ {
// generate indices if not provided // generate indices if not provided
bool hasIndices = !!indices; bool hasIndices = !!indices;
@ -159,7 +159,7 @@ dxIndexBuffer::dxIndexBuffer(
// create buffer // create buffer
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateBuffer(&bDesc, &sDesc, &m_Buffer)); DXC(m_context->GetDevice()->CreateBuffer(&bDesc, &sDesc, &m_buffer));
// delete indices // delete indices
if (!hasIndices) if (!hasIndices)
@ -173,7 +173,7 @@ dxIndexBuffer::~dxIndexBuffer()
void dxIndexBuffer::Bind() void dxIndexBuffer::Bind()
{ {
m_Context->GetDeviceContext()->IASetIndexBuffer(m_Buffer.Get(), DXGI_FORMAT_R32_UINT, 0u); m_context->GetDeviceContext()->IASetIndexBuffer(m_buffer.Get(), DXGI_FORMAT_R32_UINT, 0u);
} }
void dxIndexBuffer::UnBind() void dxIndexBuffer::UnBind()
@ -181,7 +181,7 @@ void dxIndexBuffer::UnBind()
static const unsigned int offset = 0u; static const unsigned int offset = 0u;
static ID3D11Buffer *buffer = nullptr; static ID3D11Buffer *buffer = nullptr;
m_Context->GetDeviceContext()->IASetIndexBuffer(buffer, DXGI_FORMAT_R32_UINT, offset); m_context->GetDeviceContext()->IASetIndexBuffer(buffer, DXGI_FORMAT_R32_UINT, offset);
} }
//======================================== INDEX_BUFFER ========================================// //======================================== INDEX_BUFFER ========================================//

View file

@ -7,13 +7,13 @@ dxFramebuffer::dxFramebuffer(
const FramebufferSpecification &specification, const FramebufferSpecification &specification,
Ref<dxSharedContext> sharedContext Ref<dxSharedContext> sharedContext
) )
: m_Context(sharedContext) : m_context(sharedContext)
, m_Specification(specification) , m_specification(specification)
, m_RenderTargetView(nullptr) , m_render_target_view(nullptr)
, m_ColorAttachment(nullptr) , m_color_attachment(nullptr)
, m_DepthStencilAttachment(nullptr) , m_depth_stencil_attachment(nullptr)
, m_ShaderResourceView(nullptr) , m_shader_resource_view(nullptr)
, m_DepthStencilView(nullptr) , m_depth_stencil_view(nullptr)
{ {
HRESULT hr; HRESULT hr;
@ -29,22 +29,22 @@ dxFramebuffer::dxFramebuffer(
t2dDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; t2dDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
t2dDesc.CPUAccessFlags = NULL; t2dDesc.CPUAccessFlags = NULL;
t2dDesc.MiscFlags = NULL; t2dDesc.MiscFlags = NULL;
DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_ColorAttachment)); DXC(m_context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_color_attachment));
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Format = t2dDesc.Format; srvDesc.Format = t2dDesc.Format;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = 1; srvDesc.Texture2D.MipLevels = 1;
srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.MostDetailedMip = 0;
DXC(m_Context->GetDevice() DXC(m_context->GetDevice()
->CreateShaderResourceView(m_ColorAttachment.Get(), &srvDesc, &m_ShaderResourceView)); ->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view));
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {}; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
rtvDesc.Format = t2dDesc.Format; rtvDesc.Format = t2dDesc.Format;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = 0u; rtvDesc.Texture2D.MipSlice = 0u;
DXC(m_Context->GetDevice() DXC(m_context->GetDevice()
->CreateRenderTargetView(m_ColorAttachment.Get(), &rtvDesc, &m_RenderTargetView)); ->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view));
} }
void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor) void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor)
@ -56,23 +56,23 @@ void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor)
clearColor.a, clearColor.a,
}; };
m_Context->GetDeviceContext() m_context->GetDeviceContext()
->OMSetRenderTargets(1u, m_RenderTargetView.GetAddressOf(), nullptr); ->OMSetRenderTargets(1u, m_render_target_view.GetAddressOf(), nullptr);
m_Context->GetDeviceContext()->ClearRenderTargetView(m_RenderTargetView.Get(), color); m_context->GetDeviceContext()->ClearRenderTargetView(m_render_target_view.Get(), color);
D3D11_VIEWPORT viewport; D3D11_VIEWPORT viewport;
viewport.TopLeftX = 0; viewport.TopLeftX = 0;
viewport.TopLeftY = 0; viewport.TopLeftY = 0;
viewport.Width = m_Specification.width; viewport.Width = m_specification.width;
viewport.Height = m_Specification.height; viewport.Height = m_specification.height;
viewport.MinDepth = 0.0f; viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f; viewport.MaxDepth = 1.0f;
// set viewport // set viewport
m_Context->GetDeviceContext()->RSSetViewports(1u, &viewport); m_context->GetDeviceContext()->RSSetViewports(1u, &viewport);
} }
void dxFramebuffer::BindAsResource() void dxFramebuffer::BindAsResource()
@ -82,26 +82,26 @@ void dxFramebuffer::BindAsResource()
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.width = std::clamp(size.x, 1u, 16384u);
m_Specification.height = std::clamp(size.y, 1u, 16384u); m_specification.height = std::clamp(size.y, 1u, 16384u);
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
m_ColorAttachment->GetDesc(&textureDesc); m_color_attachment->GetDesc(&textureDesc);
m_RenderTargetView->GetDesc(&rtvDesc); m_render_target_view->GetDesc(&rtvDesc);
m_ShaderResourceView->GetDesc(&srvDesc); m_shader_resource_view->GetDesc(&srvDesc);
textureDesc.Width = m_Specification.width; textureDesc.Width = m_specification.width;
textureDesc.Height = m_Specification.height; textureDesc.Height = m_specification.height;
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &m_ColorAttachment)); DXC(m_context->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &m_color_attachment));
DXC(m_Context->GetDevice() DXC(m_context->GetDevice()
->CreateRenderTargetView(m_ColorAttachment.Get(), &rtvDesc, &m_RenderTargetView)); ->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view));
DXC(m_Context->GetDevice() DXC(m_context->GetDevice()
->CreateShaderResourceView(m_ColorAttachment.Get(), &srvDesc, &m_ShaderResourceView)); ->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view));
} }
} // namespace Light } // namespace Light

View file

@ -15,13 +15,13 @@
namespace Light { namespace Light {
dxGraphicsContext::dxGraphicsContext(GLFWwindow *windowHandle) dxGraphicsContext::dxGraphicsContext(GLFWwindow *windowHandle)
: m_WindowHandle(windowHandle) : m_window_handle(windowHandle)
, m_DebugInterface(nullptr) , m_debug_interface(nullptr)
{ {
// set 'GraphicsAPI'; // set 'GraphicsAPI';
m_GraphicsAPI = GraphicsAPI::DirectX; m_graphics_api = GraphicsAPI::DirectX;
m_SharedContext = std::make_shared<dxSharedContext>(); m_shared_context = std::make_shared<dxSharedContext>();
// setup stuff // setup stuff
SetupDeviceAndSwapChain(windowHandle); SetupDeviceAndSwapChain(windowHandle);
@ -31,7 +31,7 @@ dxGraphicsContext::dxGraphicsContext(GLFWwindow *windowHandle)
void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle) void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle)
{ {
Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_SharedContext); Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_shared_context);
// swap chain desc // swap chain desc
DXGI_SWAP_CHAIN_DESC sd = { 0 }; DXGI_SWAP_CHAIN_DESC sd = { 0 };
@ -86,7 +86,7 @@ void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle)
void dxGraphicsContext::SetupRenderTargets() void dxGraphicsContext::SetupRenderTargets()
{ {
Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_SharedContext); Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_shared_context);
// set primitive topology // set primitive topology
context->GetDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); context->GetDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
@ -107,7 +107,7 @@ void dxGraphicsContext::SetupRenderTargets()
void dxGraphicsContext::SetupDebugInterface() void dxGraphicsContext::SetupDebugInterface()
{ {
#ifdef LIGHT_DEBUG #ifdef LIGHT_DEBUG
Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_SharedContext); Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_shared_context);
HRESULT hr; HRESULT hr;
Microsoft::WRL::ComPtr<ID3D11Debug> debugInterface = nullptr; Microsoft::WRL::ComPtr<ID3D11Debug> debugInterface = nullptr;
@ -134,7 +134,7 @@ void dxGraphicsContext::SetupDebugInterface()
void dxGraphicsContext::LogDebugData() void dxGraphicsContext::LogDebugData()
{ {
Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_SharedContext); Ref<dxSharedContext> context = std::static_pointer_cast<dxSharedContext>(m_shared_context);
// locals // locals
IDXGIDevice *DXGIDevice; IDXGIDevice *DXGIDevice;

View file

@ -3,7 +3,7 @@
namespace Light { namespace Light {
dxRenderCommand::dxRenderCommand(Ref<dxSharedContext> sharedContext): m_Context(sharedContext) dxRenderCommand::dxRenderCommand(Ref<dxSharedContext> sharedContext): m_context(sharedContext)
{ {
} }
@ -11,42 +11,42 @@ void dxRenderCommand::SwapBuffers()
{ {
#ifdef LIGHT_DEBUG #ifdef LIGHT_DEBUG
HRESULT hr; HRESULT hr;
if (FAILED(hr = m_Context->GetSwapChain()->Present(1u, 0u))) if (FAILED(hr = m_context->GetSwapChain()->Present(1u, 0u)))
{ {
if (hr == DXGI_ERROR_DEVICE_REMOVED) if (hr == DXGI_ERROR_DEVICE_REMOVED)
{ {
LOG(critical, "dxRenderCommand::SwapBuffers: DeviceRemoved:"); LOG(critical, "dxRenderCommand::SwapBuffers: DeviceRemoved:");
LOG(critical, " {}", m_Context->GetDevice()->GetDeviceRemovedReason()); LOG(critical, " {}", m_context->GetDevice()->GetDeviceRemovedReason());
throw dxException(hr, __FILE__, __LINE__); throw dxException(hr, __FILE__, __LINE__);
} }
} }
#else #else
m_Context->GetSwapChain()->Present(0u, 0u); m_context->GetSwapChain()->Present(0u, 0u);
#endif #endif
} }
void dxRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor) void dxRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor)
{ {
m_Context->GetDeviceContext()->ClearRenderTargetView( m_context->GetDeviceContext()->ClearRenderTargetView(
m_Context->GetRenderTargetView().Get(), m_context->GetRenderTargetView().Get(),
&clearColor[0] &clearColor[0]
); );
} }
void dxRenderCommand::Draw(unsigned int count) void dxRenderCommand::Draw(unsigned int count)
{ {
m_Context->GetDeviceContext()->Draw(count, 0u); m_context->GetDeviceContext()->Draw(count, 0u);
} }
void dxRenderCommand::DrawIndexed(unsigned int count) void dxRenderCommand::DrawIndexed(unsigned int count)
{ {
m_Context->GetDeviceContext()->DrawIndexed(count, 0u, 0u); m_context->GetDeviceContext()->DrawIndexed(count, 0u, 0u);
} }
void dxRenderCommand::DefaultTargetFramebuffer() void dxRenderCommand::DefaultTargetFramebuffer()
{ {
m_Context->GetDeviceContext() m_context->GetDeviceContext()
->OMSetRenderTargets(1, m_Context->GetRenderTargetView().GetAddressOf(), nullptr); ->OMSetRenderTargets(1, m_context->GetRenderTargetView().GetAddressOf(), nullptr);
} }
void dxRenderCommand::SetViewport( void dxRenderCommand::SetViewport(
@ -72,7 +72,7 @@ void dxRenderCommand::SetViewport(
viewport.MaxDepth = 1.0f; viewport.MaxDepth = 1.0f;
// set viewport // set viewport
m_Context->GetDeviceContext()->RSSetViewports(1u, &viewport); m_context->GetDeviceContext()->RSSetViewports(1u, &viewport);
} }
void dxRenderCommand::SetResolution(unsigned int width, unsigned int height) void dxRenderCommand::SetResolution(unsigned int width, unsigned int height)
@ -81,25 +81,25 @@ void dxRenderCommand::SetResolution(unsigned int width, unsigned int height)
// remove render target // remove render target
ID3D11RenderTargetView *nullViews[] = { nullptr }; ID3D11RenderTargetView *nullViews[] = { nullptr };
m_Context->GetDeviceContext()->OMSetRenderTargets(1u, nullViews, nullptr); m_context->GetDeviceContext()->OMSetRenderTargets(1u, nullViews, nullptr);
m_Context->GetRenderTargetViewRef().Reset(); m_context->GetRenderTargetViewRef().Reset();
// resize buffer // resize buffer
DXC(m_Context->GetSwapChain() DXC(m_context->GetSwapChain()
->ResizeBuffers(0u, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, NULL)); ->ResizeBuffers(0u, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, NULL));
// create render target // create render target
Microsoft::WRL::ComPtr<ID3D11Resource> backBuffer = nullptr; Microsoft::WRL::ComPtr<ID3D11Resource> backBuffer = nullptr;
DXC(m_Context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); DXC(m_context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer));
DXC(m_Context->GetDevice()->CreateRenderTargetView( DXC(m_context->GetDevice()->CreateRenderTargetView(
backBuffer.Get(), backBuffer.Get(),
nullptr, nullptr,
&m_Context->GetRenderTargetViewRef() &m_context->GetRenderTargetViewRef()
)); ));
// set render target // set render target
m_Context->GetDeviceContext() m_context->GetDeviceContext()
->OMSetRenderTargets(1u, m_Context->GetRenderTargetView().GetAddressOf(), nullptr); ->OMSetRenderTargets(1u, m_context->GetRenderTargetView().GetAddressOf(), nullptr);
} }
} // namespace Light } // namespace Light

View file

@ -9,10 +9,10 @@ dxShader::dxShader(
BasicFileHandle pixelFile, BasicFileHandle pixelFile,
Ref<dxSharedContext> sharedContext Ref<dxSharedContext> sharedContext
) )
: m_Context(sharedContext) : m_context(sharedContext)
, m_VertexShader(nullptr) , m_vertex_shader(nullptr)
, m_PixelShader(nullptr) , m_pixel_shader(nullptr)
, m_VertexBlob(nullptr) , m_vertex_blob(nullptr)
{ {
Microsoft::WRL::ComPtr<ID3DBlob> ps = nullptr, vsErr = nullptr, psErr = nullptr; Microsoft::WRL::ComPtr<ID3DBlob> ps = nullptr, vsErr = nullptr, psErr = nullptr;
@ -28,7 +28,7 @@ dxShader::dxShader(
"vs_4_0", "vs_4_0",
NULL, NULL,
NULL, NULL,
&m_VertexBlob, &m_vertex_blob,
&vsErr &vsErr
); );
D3DCompile( D3DCompile(
@ -51,14 +51,14 @@ dxShader::dxShader(
// create shaders // create shaders
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateVertexShader( DXC(m_context->GetDevice()->CreateVertexShader(
m_VertexBlob->GetBufferPointer(), m_vertex_blob->GetBufferPointer(),
m_VertexBlob->GetBufferSize(), m_vertex_blob->GetBufferSize(),
NULL, NULL,
&m_VertexShader &m_vertex_shader
)); ));
DXC(m_Context->GetDevice() DXC(m_context->GetDevice()
->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_PixelShader)); ->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_pixel_shader));
} }
dxShader::~dxShader() dxShader::~dxShader()
@ -68,14 +68,14 @@ dxShader::~dxShader()
void dxShader::Bind() void dxShader::Bind()
{ {
m_Context->GetDeviceContext()->VSSetShader(m_VertexShader.Get(), nullptr, 0u); m_context->GetDeviceContext()->VSSetShader(m_vertex_shader.Get(), nullptr, 0u);
m_Context->GetDeviceContext()->PSSetShader(m_PixelShader.Get(), nullptr, 0u); m_context->GetDeviceContext()->PSSetShader(m_pixel_shader.Get(), nullptr, 0u);
} }
void dxShader::UnBind() void dxShader::UnBind()
{ {
m_Context->GetDeviceContext()->VSSetShader(nullptr, nullptr, 0u); m_context->GetDeviceContext()->VSSetShader(nullptr, nullptr, 0u);
m_Context->GetDeviceContext()->PSSetShader(nullptr, nullptr, 0u); m_context->GetDeviceContext()->PSSetShader(nullptr, nullptr, 0u);
} }
} // namespace Light } // namespace Light

View file

@ -12,10 +12,10 @@ dxTexture::dxTexture(
const std::string &filePath const std::string &filePath
) )
: Texture(filePath) : Texture(filePath)
, m_Context(sharedContext) , m_context(sharedContext)
, m_Texture2D(nullptr) , m_texture_2d(nullptr)
, m_ShaderResourceView(nullptr) , m_shader_resource_view(nullptr)
, m_SamplerState(nullptr) , m_sampler_state(nullptr)
{ {
// texture2d desc // texture2d desc
D3D11_TEXTURE2D_DESC t2dDesc = {}; D3D11_TEXTURE2D_DESC t2dDesc = {};
@ -38,11 +38,11 @@ dxTexture::dxTexture(
// create texture // create texture
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_Texture2D)); DXC(m_context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_texture_2d));
m_Context->GetDeviceContext() m_context->GetDeviceContext()
->UpdateSubresource(m_Texture2D.Get(), 0u, nullptr, pixels, width * 4u, 0u); ->UpdateSubresource(m_texture_2d.Get(), 0u, nullptr, pixels, width * 4u, 0u);
m_Texture2D->GetDesc(&t2dDesc); m_texture_2d->GetDesc(&t2dDesc);
// shader resource view desc // shader resource view desc
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
@ -52,9 +52,9 @@ dxTexture::dxTexture(
srvDesc.Texture2D.MipLevels = -1; srvDesc.Texture2D.MipLevels = -1;
// create shader resource view // create shader resource view
m_Context->GetDevice() m_context->GetDevice()
->CreateShaderResourceView(m_Texture2D.Get(), &srvDesc, &m_ShaderResourceView); ->CreateShaderResourceView(m_texture_2d.Get(), &srvDesc, &m_shader_resource_view);
m_Context->GetDeviceContext()->GenerateMips(m_ShaderResourceView.Get()); m_context->GetDeviceContext()->GenerateMips(m_shader_resource_view.Get());
// sampler desc // sampler desc
D3D11_SAMPLER_DESC sDesc = {}; D3D11_SAMPLER_DESC sDesc = {};
@ -67,14 +67,14 @@ dxTexture::dxTexture(
sDesc.MaxLOD = D3D11_FLOAT32_MAX; sDesc.MaxLOD = D3D11_FLOAT32_MAX;
// create sampler // create sampler
m_Context->GetDevice()->CreateSamplerState(&sDesc, &m_SamplerState); m_context->GetDevice()->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_SamplerState.GetAddressOf()); m_context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_sampler_state.GetAddressOf());
m_Context->GetDeviceContext() m_context->GetDeviceContext()
->PSSetShaderResources(slot, 1u, m_ShaderResourceView.GetAddressOf()); ->PSSetShaderResources(slot, 1u, m_shader_resource_view.GetAddressOf());
} }
} // namespace Light } // namespace Light

View file

@ -9,8 +9,8 @@ dxVertexLayout::dxVertexLayout(
const std::vector<std::pair<std::string, VertexElementType>> &elements, const std::vector<std::pair<std::string, VertexElementType>> &elements,
Ref<dxSharedContext> sharedContext Ref<dxSharedContext> sharedContext
) )
: m_Context(sharedContext) : m_context(sharedContext)
, m_InputLayout(nullptr) , m_input_layout(nullptr)
{ {
// occupy space for input elements // occupy space for input elements
std::vector<D3D11_INPUT_ELEMENT_DESC> inputElementsDesc; std::vector<D3D11_INPUT_ELEMENT_DESC> inputElementsDesc;
@ -33,12 +33,12 @@ dxVertexLayout::dxVertexLayout(
// create input layout (vertex layout) // create input layout (vertex layout)
HRESULT hr; HRESULT hr;
DXC(m_Context->GetDevice()->CreateInputLayout( DXC(m_context->GetDevice()->CreateInputLayout(
&inputElementsDesc[0], &inputElementsDesc[0],
inputElementsDesc.size(), inputElementsDesc.size(),
dxpShader->GetVertexBlob().Get()->GetBufferPointer(), dxpShader->GetVertexBlob().Get()->GetBufferPointer(),
dxpShader->GetVertexBlob().Get()->GetBufferSize(), dxpShader->GetVertexBlob().Get()->GetBufferSize(),
&m_InputLayout &m_input_layout
)); ));
} }
@ -49,12 +49,12 @@ dxVertexLayout::~dxVertexLayout()
void dxVertexLayout::Bind() void dxVertexLayout::Bind()
{ {
m_Context->GetDeviceContext()->IASetInputLayout(m_InputLayout.Get()); m_context->GetDeviceContext()->IASetInputLayout(m_input_layout.Get());
} }
void dxVertexLayout::UnBind() void dxVertexLayout::UnBind()
{ {
m_Context->GetDeviceContext()->IASetInputLayout(nullptr); m_context->GetDeviceContext()->IASetInputLayout(nullptr);
} }
DXGI_FORMAT dxVertexLayout::GetDxgiFormat(VertexElementType type) DXGI_FORMAT dxVertexLayout::GetDxgiFormat(VertexElementType type)

View file

@ -4,7 +4,7 @@
namespace Light { namespace Light {
glBlender::glBlender() glBlender::glBlender()
: m_FactorMap { // constants : m_factor_map { // constants
{ BlendFactor::ZERO, GL_ZERO }, { BlendFactor::ZERO, GL_ZERO },
{ BlendFactor::ONE, GL_ONE }, { BlendFactor::ONE, GL_ONE },
@ -35,7 +35,7 @@ glBlender::glBlender()
void glBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) void glBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor)
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(m_FactorMap.at(srcFactor), m_FactorMap.at(dstFactor)); glBlendFunc(m_factor_map.at(srcFactor), m_factor_map.at(dstFactor));
} }
void glBlender::Disable() void glBlender::Disable()

View file

@ -5,53 +5,53 @@ namespace Light {
//==================== CONSTANT_BUFFER ====================// //==================== CONSTANT_BUFFER ====================//
glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size) glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size)
: m_BufferID(NULL) : m_buffer_id(NULL)
, m_Index(static_cast<int>(index)) , m_index(static_cast<int>(index))
{ {
glCreateBuffers(1, &m_BufferID); glCreateBuffers(1, &m_buffer_id);
glNamedBufferData(m_BufferID, size, nullptr, GL_DYNAMIC_DRAW); glNamedBufferData(m_buffer_id, size, nullptr, GL_DYNAMIC_DRAW);
Bind(); Bind();
} }
glConstantBuffer::~glConstantBuffer() glConstantBuffer::~glConstantBuffer()
{ {
glDeleteBuffers(1, &m_BufferID); glDeleteBuffers(1, &m_buffer_id);
} }
void glConstantBuffer::Bind() void glConstantBuffer::Bind()
{ {
glBindBufferBase(GL_UNIFORM_BUFFER, m_Index, m_BufferID); glBindBufferBase(GL_UNIFORM_BUFFER, m_index, m_buffer_id);
} }
void *glConstantBuffer::Map() void *glConstantBuffer::Map()
{ {
void *map = glMapNamedBuffer(m_BufferID, GL_WRITE_ONLY); void *map = glMapNamedBuffer(m_buffer_id, GL_WRITE_ONLY);
return map; return map;
} }
void glConstantBuffer::UnMap() void glConstantBuffer::UnMap()
{ {
glUnmapNamedBuffer(m_BufferID); glUnmapNamedBuffer(m_buffer_id);
} }
//==================== CONSTANT_BUFFER ====================// //==================== CONSTANT_BUFFER ====================//
//==================== VERTEX_BUFFER ====================// //==================== VERTEX_BUFFER ====================//
glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count) glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count)
: m_BufferID(NULL) : m_buffer_id(NULL)
{ {
glCreateBuffers(1, &m_BufferID); glCreateBuffers(1, &m_buffer_id);
glNamedBufferData(m_BufferID, stride * count, vertices, GL_DYNAMIC_DRAW); glNamedBufferData(m_buffer_id, stride * count, vertices, GL_DYNAMIC_DRAW);
} }
glVertexBuffer::~glVertexBuffer() glVertexBuffer::~glVertexBuffer()
{ {
glDeleteBuffers(1, &m_BufferID); glDeleteBuffers(1, &m_buffer_id);
} }
void glVertexBuffer::Bind() void glVertexBuffer::Bind()
{ {
glBindBuffer(GL_ARRAY_BUFFER, m_BufferID); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id);
} }
void glVertexBuffer::UnBind() void glVertexBuffer::UnBind()
@ -61,17 +61,17 @@ void glVertexBuffer::UnBind()
void *glVertexBuffer::Map() void *glVertexBuffer::Map()
{ {
return glMapNamedBuffer(m_BufferID, GL_WRITE_ONLY); return glMapNamedBuffer(m_buffer_id, GL_WRITE_ONLY);
} }
void glVertexBuffer::UnMap() void glVertexBuffer::UnMap()
{ {
glUnmapNamedBuffer(m_BufferID); glUnmapNamedBuffer(m_buffer_id);
} }
//==================== VERTEX_BUFFER ====================// //==================== VERTEX_BUFFER ====================//
//==================== INDEX_BUFFER ====================// //==================== INDEX_BUFFER ====================//
glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_BufferID(NULL) glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffer_id(NULL)
{ {
// generate indices if not provided // generate indices if not provided
bool hasIndices = !!indices; bool hasIndices = !!indices;
@ -103,8 +103,8 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_Buffe
} }
// create buffer // create buffer
glCreateBuffers(1, &m_BufferID); glCreateBuffers(1, &m_buffer_id);
glNamedBufferData(m_BufferID, count * sizeof(unsigned int), indices, GL_STATIC_DRAW); glNamedBufferData(m_buffer_id, count * sizeof(unsigned int), indices, GL_STATIC_DRAW);
// delete indices // delete indices
if (!hasIndices) if (!hasIndices)
@ -113,12 +113,12 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_Buffe
glIndexBuffer::~glIndexBuffer() glIndexBuffer::~glIndexBuffer()
{ {
glDeleteBuffers(1, &m_BufferID); glDeleteBuffers(1, &m_buffer_id);
} }
void glIndexBuffer::Bind() void glIndexBuffer::Bind()
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer_id);
} }
void glIndexBuffer::UnBind() void glIndexBuffer::UnBind()

View file

@ -5,26 +5,26 @@
namespace Light { namespace Light {
glFramebuffer::glFramebuffer(const FramebufferSpecification &specification) glFramebuffer::glFramebuffer(const FramebufferSpecification &specification)
: m_Specification(specification) : m_specification(specification)
, m_BufferID(NULL) , m_buffer_id(NULL)
, m_ColorAttachmentID(NULL) , m_color_attachment_id(NULL)
, m_DepthStencilAttachmentID(NULL) , m_depth_stencil_attachment_id(NULL)
{ {
Resize({ specification.width, specification.height }); Resize({ specification.width, specification.height });
} }
glFramebuffer::~glFramebuffer() glFramebuffer::~glFramebuffer()
{ {
glDeleteFramebuffers(1, &m_BufferID); glDeleteFramebuffers(1, &m_buffer_id);
glDeleteTextures(1, &m_ColorAttachmentID); glDeleteTextures(1, &m_color_attachment_id);
// glDeleteTextures(1, &m_DepthStencilAttachmentID); // glDeleteTextures(1, &m_depth_stencil_attachment_id);
} }
void glFramebuffer::BindAsTarget(const glm::vec4 &clearColor) void glFramebuffer::BindAsTarget(const glm::vec4 &clearColor)
{ {
// #todo: use viewport instead of default x=0, y=0 // #todo: use viewport instead of default x=0, y=0
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferID); glBindFramebuffer(GL_FRAMEBUFFER, m_buffer_id);
glViewport(0, 0, m_Specification.width, m_Specification.height); glViewport(0, 0, m_specification.width, m_specification.height);
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
@ -37,53 +37,53 @@ void glFramebuffer::BindAsResource()
void glFramebuffer::Resize(const glm::uvec2 &size) void glFramebuffer::Resize(const glm::uvec2 &size)
{ {
if (m_BufferID) if (m_buffer_id)
{ {
glDeleteFramebuffers(1, &m_BufferID); glDeleteFramebuffers(1, &m_buffer_id);
glDeleteTextures(1, &m_ColorAttachmentID); glDeleteTextures(1, &m_color_attachment_id);
// glDeleteTextures(1, &m_DepthStencilAttachmentID); // glDeleteTextures(1, &m_depth_stencil_attachment_id);
} }
m_Specification.width = std::clamp(size.x, 1u, (unsigned int)GL_MAX_TEXTURE_SIZE); m_specification.width = std::clamp(size.x, 1u, (unsigned int)GL_MAX_TEXTURE_SIZE);
m_Specification.height = std::clamp(size.y, 1u, (unsigned int)GL_MAX_TEXTURE_SIZE); m_specification.height = std::clamp(size.y, 1u, (unsigned int)GL_MAX_TEXTURE_SIZE);
glCreateFramebuffers(1, &m_BufferID); glCreateFramebuffers(1, &m_buffer_id);
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferID); glBindFramebuffer(GL_FRAMEBUFFER, m_buffer_id);
// create color attachment // create color attachment
glCreateTextures(GL_TEXTURE_2D, 1, &m_ColorAttachmentID); glCreateTextures(GL_TEXTURE_2D, 1, &m_color_attachment_id);
glBindTexture(GL_TEXTURE_2D, m_ColorAttachmentID); glBindTexture(GL_TEXTURE_2D, m_color_attachment_id);
glTexImage2D( glTexImage2D(
GL_TEXTURE_2D, GL_TEXTURE_2D,
0, 0,
GL_RGBA8, GL_RGBA8,
m_Specification.width, m_specification.width,
m_Specification.height, m_specification.height,
NULL, NULL,
GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
nullptr nullptr
); );
glTextureParameteri(m_ColorAttachmentID, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTextureParameteri(m_color_attachment_id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTextureParameteri(m_ColorAttachmentID, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTextureParameteri(m_color_attachment_id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D( glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
m_ColorAttachmentID, m_color_attachment_id,
0 0
); );
// glTextureStorage2D(m_ColorAttachmentID, 0, GL_RGBA8, m_Specification.width, // glTextureStorage2D(m_color_attachment_id, 0, GL_RGBA8, m_specification.width,
// m_Specification.height); // m_specification.height);
// glCreateTextures(GL_TEXTURE_2D, 1, &m_DepthStencilAttachmentID); // glCreateTextures(GL_TEXTURE_2D, 1, &m_depth_stencil_attachment_id);
// glBindTexture(GL_TEXTURE_2D, m_DepthStencilAttachmentID); // glBindTexture(GL_TEXTURE_2D, m_depth_stencil_attachment_id);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_Specification.width, // glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_specification.width,
// m_Specification.height, NULL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); // m_specification.height, NULL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
// // glTextureStorage2D(m_DepthStencilAttachmentID, 0, GL_DEPTH24_STENCIL8, // // glTextureStorage2D(m_depth_stencil_attachment_id, 0, GL_DEPTH24_STENCIL8,
// m_Specification.width, m_Specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER, // m_specification.width, m_specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER,
// GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthStencilAttachmentID, 0); // GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depth_stencil_attachment_id, 0);
ASSERT( ASSERT(
(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE), (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE),

View file

@ -14,10 +14,10 @@
namespace Light { namespace Light {
glGraphicsContext::glGraphicsContext(GLFWwindow *windowHandle): m_WindowHandle(windowHandle) glGraphicsContext::glGraphicsContext(GLFWwindow *windowHandle): m_window_handle(windowHandle)
{ {
// set 'GraphicsAPI' // set 'GraphicsAPI'
m_GraphicsAPI = GraphicsAPI::OpenGL; m_graphics_api = GraphicsAPI::OpenGL;
// make context current // make context current
glfwMakeContextCurrent(windowHandle); glfwMakeContextCurrent(windowHandle);

View file

@ -6,13 +6,13 @@
namespace Light { namespace Light {
glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_WindowHandle(windowHandle) glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_window_handle(windowHandle)
{ {
} }
void glRenderCommand::SwapBuffers() void glRenderCommand::SwapBuffers()
{ {
glfwSwapBuffers(m_WindowHandle); glfwSwapBuffers(m_window_handle);
} }
void glRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor) void glRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor)

View file

@ -6,10 +6,10 @@
namespace Light { namespace Light {
glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_ShaderID(0u) glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_shader_id(0u)
{ {
// create // create
m_ShaderID = glCreateProgram(); m_shader_id = glCreateProgram();
std::string vertexSource(vertexFile.GetData(), vertexFile.GetData() + vertexFile.GetSize()); std::string vertexSource(vertexFile.GetData(), vertexFile.GetData() + vertexFile.GetSize());
std::string pixelSource(pixelFile.GetData(), pixelFile.GetData() + pixelFile.GetSize()); std::string pixelSource(pixelFile.GetData(), pixelFile.GetData() + pixelFile.GetSize());
@ -18,11 +18,11 @@ glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_Sha
unsigned int pixelShader = CompileShader(pixelSource, Shader::Stage::PIXEL); unsigned int pixelShader = CompileShader(pixelSource, Shader::Stage::PIXEL);
// attach shaders // attach shaders
glAttachShader(m_ShaderID, vertexShader); glAttachShader(m_shader_id, vertexShader);
glAttachShader(m_ShaderID, pixelShader); glAttachShader(m_shader_id, pixelShader);
// link shader program // link shader program
glLinkProgram(m_ShaderID); glLinkProgram(m_shader_id);
// delete shaders (free memory) // delete shaders (free memory)
glDeleteShader(vertexShader); glDeleteShader(vertexShader);
@ -31,12 +31,12 @@ glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_Sha
glShader::~glShader() glShader::~glShader()
{ {
glDeleteProgram(m_ShaderID); glDeleteProgram(m_shader_id);
} }
void glShader::Bind() void glShader::Bind()
{ {
glUseProgram(m_ShaderID); glUseProgram(m_shader_id);
} }
void glShader::UnBind() void glShader::UnBind()

View file

@ -11,16 +11,16 @@ glTexture::glTexture(
const std::string &filePath const std::string &filePath
) )
: Texture(filePath) : Texture(filePath)
, m_TextureID(NULL) , m_texture_id(NULL)
{ {
// create texture // create texture
glCreateTextures(GL_TEXTURE_2D, 1, &m_TextureID); glCreateTextures(GL_TEXTURE_2D, 1, &m_texture_id);
// set texture parameters // set texture parameters
glTextureParameteri(m_TextureID, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTextureParameteri(m_texture_id, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTextureParameteri(m_TextureID, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTextureParameteri(m_texture_id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTextureParameteri(m_TextureID, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTextureParameteri(m_texture_id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTextureParameteri(m_TextureID, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTextureParameteri(m_texture_id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// determine formats // determine formats
unsigned int format = components == 4u ? GL_RGBA : unsigned int format = components == 4u ? GL_RGBA :
@ -58,18 +58,18 @@ glTexture::glTexture(
glTexture::~glTexture() glTexture::~glTexture()
{ {
glDeleteTextures(1, &m_TextureID); glDeleteTextures(1, &m_texture_id);
} }
void glTexture::Bind(unsigned int slot /* = 0u */) void glTexture::Bind(unsigned int slot /* = 0u */)
{ {
glActiveTexture(GL_TEXTURE0 + slot); glActiveTexture(GL_TEXTURE0 + slot);
glBindTexture(GL_TEXTURE_2D, m_TextureID); glBindTexture(GL_TEXTURE_2D, m_texture_id);
} }
void *glTexture::GetTexture() void *glTexture::GetTexture()
{ {
return (void *)(intptr_t)m_TextureID; return (void *)(intptr_t)m_texture_id;
} }
} // namespace Light } // namespace Light

View file

@ -12,7 +12,7 @@ void glUserInterface::PlatformImplementation(
Ref<SharedContext> sharedContext Ref<SharedContext> sharedContext
) )
{ {
m_WindowHandle = windowHandle; m_window_handle = windowHandle;
ImGui_ImplGlfw_InitForOpenGL(windowHandle, false); ImGui_ImplGlfw_InitForOpenGL(windowHandle, false);
ImGui_ImplOpenGL3_Init(); ImGui_ImplOpenGL3_Init();
@ -45,7 +45,7 @@ void glUserInterface::End()
ImGui::UpdatePlatformWindows(); ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault(); ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(m_WindowHandle); glfwMakeContextCurrent(m_window_handle);
} }
void glUserInterface::LogDebugData() void glUserInterface::LogDebugData()

View file

@ -8,7 +8,7 @@ glVertexLayout::glVertexLayout(
Ref<VertexBuffer> buffer, Ref<VertexBuffer> buffer,
const std::vector<std::pair<std::string, VertexElementType>> &elements const std::vector<std::pair<std::string, VertexElementType>> &elements
) )
: m_ArrayID(NULL) : m_array_id(NULL)
{ {
// check // check
ASSERT( ASSERT(
@ -30,7 +30,7 @@ glVertexLayout::glVertexLayout(
} }
// create vertex array // create vertex array
glCreateVertexArrays(1, &m_ArrayID); glCreateVertexArrays(1, &m_array_id);
// bind buffer and array // bind buffer and array
buffer->Bind(); buffer->Bind();
@ -54,12 +54,12 @@ glVertexLayout::glVertexLayout(
glVertexLayout::~glVertexLayout() glVertexLayout::~glVertexLayout()
{ {
glDeleteVertexArrays(1, &m_ArrayID); glDeleteVertexArrays(1, &m_array_id);
} }
void glVertexLayout::Bind() void glVertexLayout::Bind()
{ {
glBindVertexArray(m_ArrayID); glBindVertexArray(m_array_id);
} }
void glVertexLayout::UnBind() void glVertexLayout::UnBind()

View file

@ -15,8 +15,8 @@ Scope<Window> Window::Create(std::function<void(Event &)> callback)
} }
lWindow::lWindow(std::function<void(Event &)> callback) lWindow::lWindow(std::function<void(Event &)> callback)
: m_Handle(nullptr) : m_handle(nullptr)
, m_EventCallback(callback) , m_event_callback(callback)
{ {
// init glfw // init glfw
ASSERT(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'"); ASSERT(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'");
@ -27,21 +27,21 @@ lWindow::lWindow(std::function<void(Event &)> callback)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
ASSERT(m_Handle, "lWindow::lWindow: failed to create 'GLFWwindow'"); ASSERT(m_handle, "lWindow::lWindow: failed to create 'GLFWwindow'");
// bind event stuff // bind event stuff
glfwSetWindowUserPointer(m_Handle, &m_EventCallback); glfwSetWindowUserPointer(m_handle, &m_event_callback);
BindGlfwEvents(); BindGlfwEvents();
// create graphics context // create graphics context
m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::OpenGL, m_Handle); m_graphics_context = GraphicsContext::Create(GraphicsAPI::OpenGL, m_handle);
ASSERT(m_GraphicsContext, "lWindow::lWindow: failed to create 'GraphicsContext'"); ASSERT(m_graphics_context, "lWindow::lWindow: failed to create 'GraphicsContext'");
} }
lWindow::~lWindow() lWindow::~lWindow()
{ {
glfwDestroyWindow(m_Handle); glfwDestroyWindow(m_handle);
} }
void lWindow::PollEvents() void lWindow::PollEvents()
@ -63,16 +63,16 @@ void lWindow::OnEvent(const Event &event)
void lWindow::OnWindowResize(const WindowResizedEvent &event) void lWindow::OnWindowResize(const WindowResizedEvent &event)
{ {
m_Properties.size = event.GetSize(); m_properties.size = event.GetSize();
} }
void lWindow:: void lWindow::
SetProperties(const WindowProperties &properties, bool overrideVisibility /* = false */) SetProperties(const WindowProperties &properties, bool overrideVisibility /* = false */)
{ {
// save the visibility status and re-assign if 'overrideVisibility' is false // save the visibility status and re-assign if 'overrideVisibility' is false
bool visible = overrideVisibility ? properties.visible : m_Properties.visible; bool visible = overrideVisibility ? properties.visible : m_properties.visible;
m_Properties = properties; m_properties = properties;
m_Properties.visible = visible; m_properties.visible = visible;
// set properties // set properties
SetTitle(properties.title); SetTitle(properties.title);
@ -83,46 +83,46 @@ void lWindow::
void lWindow::SetTitle(const std::string &title) void lWindow::SetTitle(const std::string &title)
{ {
m_Properties.title = title; m_properties.title = title;
glfwSetWindowTitle(m_Handle, title.c_str()); glfwSetWindowTitle(m_handle, title.c_str());
} }
void lWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) void lWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */)
{ {
m_Properties.size.x = size.x == 0u ? m_Properties.size.x : m_properties.size.x = size.x == 0u ? m_properties.size.x :
additive ? m_Properties.size.x + size.x : additive ? m_properties.size.x + size.x :
size.x; size.x;
m_Properties.size.y = size.y == 0u ? m_Properties.size.y : m_properties.size.y = size.y == 0u ? m_properties.size.y :
additive ? m_Properties.size.y + size.y : additive ? m_properties.size.y + size.y :
size.y; size.y;
glfwSetWindowSize(m_Handle, size.x, size.y); glfwSetWindowSize(m_handle, size.x, size.y);
} }
void lWindow::SetVSync(bool vsync, bool toggle /* = false */) void lWindow::SetVSync(bool vsync, bool toggle /* = false */)
{ {
m_Properties.vsync = toggle ? !m_Properties.vsync : vsync; m_properties.vsync = toggle ? !m_properties.vsync : vsync;
glfwSwapInterval(m_Properties.vsync); glfwSwapInterval(m_properties.vsync);
} }
void lWindow::SetVisibility(bool visible, bool toggle) void lWindow::SetVisibility(bool visible, bool toggle)
{ {
m_Properties.visible = toggle ? !m_Properties.visible : visible; m_properties.visible = toggle ? !m_properties.visible : visible;
if (m_Properties.visible) if (m_properties.visible)
glfwShowWindow(m_Handle); glfwShowWindow(m_handle);
else else
glfwHideWindow(m_Handle); glfwHideWindow(m_handle);
} }
void lWindow::BindGlfwEvents() void lWindow::BindGlfwEvents()
{ {
//============================== MOUSE_EVENTS ==============================// //============================== MOUSE_EVENTS ==============================//
/* cursor position */ /* cursor position */
glfwSetCursorPosCallback(m_Handle, [](GLFWwindow *window, double xpos, double ypos) { glfwSetCursorPosCallback(m_handle, [](GLFWwindow *window, double xpos, double ypos) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -131,7 +131,7 @@ void lWindow::BindGlfwEvents()
}); });
/* mouse button */ /* mouse button */
glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow *window, int button, int action, int mods) { glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int mods) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -148,7 +148,7 @@ void lWindow::BindGlfwEvents()
}); });
/* scroll */ /* scroll */
glfwSetScrollCallback(m_Handle, [](GLFWwindow *window, double xoffset, double yoffset) { glfwSetScrollCallback(m_handle, [](GLFWwindow *window, double xoffset, double yoffset) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -160,7 +160,7 @@ void lWindow::BindGlfwEvents()
//============================== KEYBOARD_EVENTS ==============================// //============================== KEYBOARD_EVENTS ==============================//
/* key */ /* key */
glfwSetKeyCallback( glfwSetKeyCallback(
m_Handle, m_handle,
[](GLFWwindow *window, int key, int scancode, int action, int mods) { [](GLFWwindow *window, int key, int scancode, int action, int mods) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -178,7 +178,7 @@ void lWindow::BindGlfwEvents()
} }
); );
/* char */ /* char */
glfwSetCharCallback(m_Handle, [](GLFWwindow *window, unsigned int character) { glfwSetCharCallback(m_handle, [](GLFWwindow *window, unsigned int character) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -190,7 +190,7 @@ void lWindow::BindGlfwEvents()
//============================== WINDOW_EVENTS ==============================// //============================== WINDOW_EVENTS ==============================//
/* window position */ /* window position */
glfwSetWindowPosCallback(m_Handle, [](GLFWwindow *window, int xpos, int ypos) { glfwSetWindowPosCallback(m_handle, [](GLFWwindow *window, int xpos, int ypos) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowMovedEvent event(xpos, ypos); WindowMovedEvent event(xpos, ypos);
@ -199,7 +199,7 @@ void lWindow::BindGlfwEvents()
}); });
/* window size */ /* window size */
glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow *window, int width, int height) { glfwSetWindowSizeCallback(m_handle, [](GLFWwindow *window, int width, int height) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowResizedEvent event(width, height); WindowResizedEvent event(width, height);
@ -208,7 +208,7 @@ void lWindow::BindGlfwEvents()
}); });
/* window close */ /* window close */
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow *window) { glfwSetWindowCloseCallback(m_handle, [](GLFWwindow *window) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowClosedEvent event; WindowClosedEvent event;
@ -217,7 +217,7 @@ void lWindow::BindGlfwEvents()
}); });
/* window focus */ /* window focus */
glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow *window, int focus) { glfwSetWindowFocusCallback(m_handle, [](GLFWwindow *window, int focus) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);

View file

@ -22,8 +22,8 @@ Scope<Window> Window::Create(std::function<void(Event &)> callback)
} }
wWindow::wWindow(std::function<void(Event &)> callback) wWindow::wWindow(std::function<void(Event &)> callback)
: m_Handle(nullptr) : m_handle(nullptr)
, m_EventCallback(callback) , m_event_callback(callback)
{ {
// init glfw // init glfw
ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'");
@ -34,21 +34,21 @@ wWindow::wWindow(std::function<void(Event &)> callback)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
ASSERT(m_Handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); ASSERT(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'");
// bind event stuff // bind event stuff
glfwSetWindowUserPointer(m_Handle, &m_EventCallback); glfwSetWindowUserPointer(m_handle, &m_event_callback);
BindGlfwEvents(); BindGlfwEvents();
// create graphics context // create graphics context
m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle); m_graphics_context = GraphicsContext::Create(GraphicsAPI::DirectX, m_handle);
ASSERT(m_GraphicsContext, "wWindow::wWindow: failed to create 'GraphicsContext'"); ASSERT(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'");
} }
wWindow::~wWindow() wWindow::~wWindow()
{ {
glfwDestroyWindow(m_Handle); glfwDestroyWindow(m_handle);
} }
void wWindow::PollEvents() void wWindow::PollEvents()
@ -70,16 +70,16 @@ void wWindow::OnEvent(const Event &event)
void wWindow::OnWindowResize(const WindowResizedEvent &event) void wWindow::OnWindowResize(const WindowResizedEvent &event)
{ {
m_Properties.size = event.GetSize(); m_properties.size = event.GetSize();
} }
void wWindow:: void wWindow::
SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */) SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */)
{ {
// save the visibility status and re-assign if 'overrideVisibility' is false // save the visibility status and re-assign if 'overrideVisibility' is false
bool visible = overrideVisiblity ? properties.visible : m_Properties.visible; bool visible = overrideVisiblity ? properties.visible : m_properties.visible;
m_Properties = properties; m_properties = properties;
m_Properties.visible = visible; m_properties.visible = visible;
// set properties // set properties
SetTitle(properties.title); SetTitle(properties.title);
@ -90,46 +90,46 @@ void wWindow::
void wWindow::SetTitle(const std::string &title) void wWindow::SetTitle(const std::string &title)
{ {
m_Properties.title = title; m_properties.title = title;
glfwSetWindowTitle(m_Handle, m_Properties.title.c_str()); glfwSetWindowTitle(m_handle, m_properties.title.c_str());
} }
void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */) void wWindow::SetSize(const glm::uvec2 &size, bool additive /* = false */)
{ {
m_Properties.size.x = size.x == 0u ? m_Properties.size.x : m_properties.size.x = size.x == 0u ? m_properties.size.x :
additive ? m_Properties.size.x + size.x : additive ? m_properties.size.x + size.x :
size.x; size.x;
m_Properties.size.y = size.y == 0u ? m_Properties.size.y : m_properties.size.y = size.y == 0u ? m_properties.size.y :
additive ? m_Properties.size.y + size.y : additive ? m_properties.size.y + size.y :
size.y; size.y;
glfwSetWindowSize(m_Handle, size.x, size.y); glfwSetWindowSize(m_handle, size.x, size.y);
} }
void wWindow::SetVSync(bool vsync, bool toggle /* = false */) void wWindow::SetVSync(bool vsync, bool toggle /* = false */)
{ {
m_Properties.vsync = toggle ? !m_Properties.vsync : vsync; m_properties.vsync = toggle ? !m_properties.vsync : vsync;
glfwSwapInterval(m_Properties.vsync); glfwSwapInterval(m_properties.vsync);
} }
void wWindow::SetVisibility(bool visible, bool toggle) void wWindow::SetVisibility(bool visible, bool toggle)
{ {
m_Properties.visible = toggle ? !m_Properties.visible : visible; m_properties.visible = toggle ? !m_properties.visible : visible;
if (m_Properties.visible) if (m_properties.visible)
glfwShowWindow(m_Handle); glfwShowWindow(m_handle);
else else
glfwHideWindow(m_Handle); glfwHideWindow(m_handle);
} }
void wWindow::BindGlfwEvents() void wWindow::BindGlfwEvents()
{ {
//============================== MOUSE_EVENTS ==============================// //============================== MOUSE_EVENTS ==============================//
/* cursor position */ /* cursor position */
glfwSetCursorPosCallback(m_Handle, [](GLFWwindow *window, double xpos, double ypos) { glfwSetCursorPosCallback(m_handle, [](GLFWwindow *window, double xpos, double ypos) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -138,7 +138,7 @@ void wWindow::BindGlfwEvents()
}); });
/* mouse button */ /* mouse button */
glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow *window, int button, int action, int mods) { glfwSetMouseButtonCallback(m_handle, [](GLFWwindow *window, int button, int action, int mods) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -155,7 +155,7 @@ void wWindow::BindGlfwEvents()
}); });
/* scroll */ /* scroll */
glfwSetScrollCallback(m_Handle, [](GLFWwindow *window, double xoffset, double yoffset) { glfwSetScrollCallback(m_handle, [](GLFWwindow *window, double xoffset, double yoffset) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -167,7 +167,7 @@ void wWindow::BindGlfwEvents()
//============================== KEYBOARD_EVENTS ==============================// //============================== KEYBOARD_EVENTS ==============================//
/* key */ /* key */
glfwSetKeyCallback( glfwSetKeyCallback(
m_Handle, m_handle,
[](GLFWwindow *window, int key, int scancode, int action, int mods) { [](GLFWwindow *window, int key, int scancode, int action, int mods) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -185,7 +185,7 @@ void wWindow::BindGlfwEvents()
} }
); );
/* char */ /* char */
glfwSetCharCallback(m_Handle, [](GLFWwindow *window, unsigned int character) { glfwSetCharCallback(m_handle, [](GLFWwindow *window, unsigned int character) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
@ -197,7 +197,7 @@ void wWindow::BindGlfwEvents()
//============================== WINDOW_EVENTS ==============================// //============================== WINDOW_EVENTS ==============================//
/* window position */ /* window position */
glfwSetWindowPosCallback(m_Handle, [](GLFWwindow *window, int xpos, int ypos) { glfwSetWindowPosCallback(m_handle, [](GLFWwindow *window, int xpos, int ypos) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowMovedEvent event(xpos, ypos); WindowMovedEvent event(xpos, ypos);
@ -206,7 +206,7 @@ void wWindow::BindGlfwEvents()
}); });
/* window size */ /* window size */
glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow *window, int width, int height) { glfwSetWindowSizeCallback(m_handle, [](GLFWwindow *window, int width, int height) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowResizedEvent event(width, height); WindowResizedEvent event(width, height);
@ -215,7 +215,7 @@ void wWindow::BindGlfwEvents()
}); });
/* window close */ /* window close */
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow *window) { glfwSetWindowCloseCallback(m_handle, [](GLFWwindow *window) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);
WindowClosedEvent event; WindowClosedEvent event;
@ -224,7 +224,7 @@ void wWindow::BindGlfwEvents()
}); });
/* window focus */ /* window focus */
glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow *window, int focus) { glfwSetWindowFocusCallback(m_handle, [](GLFWwindow *window, int focus) {
std::function<void(Event &)> callback = *(std::function<void(Event &)> *) std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
glfwGetWindowUserPointer(window); glfwGetWindowUserPointer(window);

View file

@ -3,7 +3,7 @@
namespace Light { namespace Light {
Entity::Entity(entt::entity handle, Scene *scene): m_Handle(handle), m_Scene(scene) Entity::Entity(entt::entity handle, Scene *scene): m_handle(handle), m_scene(scene)
{ {
} }

View file

@ -6,7 +6,7 @@
namespace Light { namespace Light {
Scene::Scene(): m_Registry() Scene::Scene(): m_registry()
{ {
} }
@ -18,7 +18,7 @@ void Scene::OnCreate()
{ {
/* native scripts */ /* native scripts */
{ {
m_Registry.view<NativeScriptComponent>().each([](NativeScriptComponent &nsc) { m_registry.view<NativeScriptComponent>().each([](NativeScriptComponent &nsc) {
if (nsc.instance == nullptr) if (nsc.instance == nullptr)
{ {
nsc.instance = nsc.CreateInstance(); nsc.instance = nsc.CreateInstance();
@ -32,7 +32,7 @@ void Scene::OnUpdate(float deltaTime)
{ {
/* native scripts */ /* native scripts */
{ {
m_Registry.view<NativeScriptComponent>().each([=](NativeScriptComponent &nsc) { m_registry.view<NativeScriptComponent>().each([=](NativeScriptComponent &nsc) {
nsc.instance->OnUpdate(deltaTime); nsc.instance->OnUpdate(deltaTime);
}); });
} }
@ -45,7 +45,7 @@ void Scene::OnRender(const Ref<Framebuffer> &targetFrameBuffer /* = nullptr */)
/* scene camera */ /* scene camera */
{ {
m_Registry.group(entt::get<TransformComponent, CameraComponent>) m_registry.group(entt::get<TransformComponent, CameraComponent>)
.each([&](TransformComponent &transformComp, CameraComponent &cameraComp) { .each([&](TransformComponent &transformComp, CameraComponent &cameraComp) {
if (cameraComp.isPrimary) if (cameraComp.isPrimary)
{ {
@ -61,7 +61,7 @@ void Scene::OnRender(const Ref<Framebuffer> &targetFrameBuffer /* = nullptr */)
{ {
Renderer::BeginScene(sceneCamera, *sceneCameraTransform, targetFrameBuffer); Renderer::BeginScene(sceneCamera, *sceneCameraTransform, targetFrameBuffer);
m_Registry.group(entt::get<TransformComponent, SpriteRendererComponent>) m_registry.group(entt::get<TransformComponent, SpriteRendererComponent>)
.each([](TransformComponent &transformComp, .each([](TransformComponent &transformComp,
SpriteRendererComponent &spriteRendererComp) { SpriteRendererComponent &spriteRendererComp) {
Renderer::DrawQuad( Renderer::DrawQuad(
@ -84,12 +84,12 @@ Entity Scene::CreateEntity(const std::string &name, const TransformComponent &tr
Entity Scene::GetEntityByTag(const std::string &tag) Entity Scene::GetEntityByTag(const std::string &tag)
{ {
// TagComponent tagComp(tag); // TagComponent tagComp(tag);
// entt::entity entity = entt::to_entity(m_Registry, tagComp); // entt::entity entity = entt::to_entity(m_registry, tagComp);
Entity entity; Entity entity;
m_Registry.view<TagComponent>().each([&](TagComponent &tagComp) { m_registry.view<TagComponent>().each([&](TagComponent &tagComp) {
// if (tagComp.tag == tag) // if (tagComp.tag == tag)
// entity = Entity(entt::to_entity(m_Registry, tagComp), this); // entity = Entity(entt::to_entity(m_registry, tagComp), this);
}); });
if (entity.IsValid()) if (entity.IsValid())
@ -107,7 +107,7 @@ Entity Scene::CreateEntityWithUUID(
const TransformComponent &transform const TransformComponent &transform
) )
{ {
Entity entity { m_Registry.create(), this }; Entity entity { m_registry.create(), this };
entity.AddComponent<TagComponent>(name); entity.AddComponent<TagComponent>(name);
entity.AddComponent<TransformComponent>(transform); entity.AddComponent<TransformComponent>(transform);
entity.AddComponent<UUIDComponent>(uuid); entity.AddComponent<UUIDComponent>(uuid);

View file

@ -2,19 +2,19 @@
namespace Light { namespace Light {
Timer::Timer(): m_Start(std::chrono::steady_clock::now()) Timer::Timer(): m_start(std::chrono::steady_clock::now())
{ {
} }
DeltaTimer::DeltaTimer(): m_PreviousFrame(NULL), m_DeltaTime(60.0f / 1000.0f) DeltaTimer::DeltaTimer(): m_previous_frame(NULL), m_delta_time(60.0f / 1000.0f)
{ {
} }
void DeltaTimer::Update() void DeltaTimer::Update()
{ {
float currentFrame = timer.GetElapsedTime(); float currentFrame = timer.GetElapsedTime();
m_DeltaTime = currentFrame - m_PreviousFrame; m_delta_time = currentFrame - m_previous_frame;
m_PreviousFrame = currentFrame; m_previous_frame = currentFrame;
} }
} // namespace Light } // namespace Light

View file

@ -45,7 +45,7 @@ Scope<UserInterface> UserInterface::Create(
} }
UserInterface::UserInterface() UserInterface::UserInterface()
: m_DockspaceFlags( : m_dockspace_flags(
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar
| ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus
@ -129,7 +129,7 @@ void UserInterface::DockspaceBegin()
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("Dockspace", (bool *)0, s_Context->m_DockspaceFlags); ImGui::Begin("Dockspace", (bool *)0, s_Context->m_dockspace_flags);
ImGui::PopStyleVar(3); ImGui::PopStyleVar(3);
ImGuiStyle &style = ImGui::GetStyle(); ImGuiStyle &style = ImGui::GetStyle();

View file

@ -11,19 +11,19 @@ BasicFileHandle::BasicFileHandle(
const std::string &name, const std::string &name,
const std::string &extension const std::string &extension
) )
: m_Data(data) : m_data(data)
, m_Size(size) , m_size(size)
, m_Path(path) , m_path(path)
, m_Name(name) , m_name(name)
, m_Extension(extension) , m_extension(extension)
{ {
} }
void BasicFileHandle::Release() void BasicFileHandle::Release()
{ {
delete m_Data; delete m_data;
m_Data = nullptr; m_data = nullptr;
m_Size = 0ull; m_size = 0ull;
} }
@ -101,9 +101,9 @@ ImageFileHandle FileManager::ReadImageFile(const std::string &path, int32_t desi
void ImageFileHandle::Release() void ImageFileHandle::Release()
{ {
stbi_image_free(reinterpret_cast<void *>(m_Data)); stbi_image_free(reinterpret_cast<void *>(m_data));
m_Data = nullptr; m_data = nullptr;
m_Size = 0ull; m_size = 0ull;
} }

View file

@ -13,7 +13,7 @@ Scope<ResourceManager> ResourceManager::Create()
return MakeScope(new ResourceManager()); return MakeScope(new ResourceManager());
} }
ResourceManager::ResourceManager(): m_Shaders {}, m_Textures {} ResourceManager::ResourceManager(): m_shaders {}, m_textures {}
{ {
ASSERT(!s_Context, "Repeated singleton construction"); ASSERT(!s_Context, "Repeated singleton construction");
s_Context = this; s_Context = this;
@ -39,7 +39,7 @@ void ResourceManager::LoadShaderImpl(
ASSERT(pixelFile.IsValid(), "Failed to read vertex file: {}", pixelPath); ASSERT(pixelFile.IsValid(), "Failed to read vertex file: {}", pixelPath);
// create shader // create shader
m_Shaders[name] = Ref<Shader>( m_shaders[name] = Ref<Shader>(
Shader::Create(vertexFile, pixelFile, GraphicsContext::GetSharedContext()) Shader::Create(vertexFile, pixelFile, GraphicsContext::GetSharedContext())
); );
@ -60,7 +60,7 @@ void ResourceManager::LoadTextureImpl(
ImageFileHandle imgFile = FileManager::ReadImageFile(path, desiredComponents); ImageFileHandle imgFile = FileManager::ReadImageFile(path, desiredComponents);
// create texture // create texture
m_Textures[name] = Ref<Texture>(Texture::Create( m_textures[name] = Ref<Texture>(Texture::Create(
imgFile.GetWidth(), imgFile.GetWidth(),
imgFile.GetHeight(), imgFile.GetHeight(),
imgFile.GetComponents(), imgFile.GetComponents(),
@ -75,13 +75,13 @@ void ResourceManager::LoadTextureImpl(
void ResourceManager::ReleaseTextureImpl(const std::string &name) void ResourceManager::ReleaseTextureImpl(const std::string &name)
{ {
if (!m_Textures[name]) if (!m_textures[name])
{ {
LOG(warn, "Failed to find texture named: {}", name); LOG(warn, "Failed to find texture named: {}", name);
return; return;
} }
m_Textures[name] = nullptr; m_textures[name] = nullptr;
} }
} // namespace Light } // namespace Light

View file

@ -72,7 +72,7 @@ static YAML::Emitter &operator<<(YAML::Emitter &out, const glm::vec4 &v)
return out; return out;
} }
SceneSerializer::SceneSerializer(const Ref<Scene> &scene): m_Scene(scene) SceneSerializer::SceneSerializer(const Ref<Scene> &scene): m_scene(scene)
{ {
} }
@ -83,9 +83,9 @@ void SceneSerializer::Serialize(const std::string &filePath)
out << YAML::Key << "Scene" << YAML::Value << "Untitled"; out << YAML::Key << "Scene" << YAML::Value << "Untitled";
out << YAML::Key << "Entities" << YAML::Value << YAML::BeginSeq; out << YAML::Key << "Entities" << YAML::Value << YAML::BeginSeq;
for (auto [entityID, storage] : m_Scene->m_Registry.storage()) for (auto [entityID, storage] : m_scene->m_registry.storage())
{ {
Entity entity = { static_cast<entt::entity>(entityID), m_Scene.get() }; Entity entity = { static_cast<entt::entity>(entityID), m_scene.get() };
if (!entity.IsValid()) if (!entity.IsValid())
return; return;
@ -134,7 +134,7 @@ bool SceneSerializer::Deserialize(const std::string &filePath)
LOG(trace, "Deserialized entity '{}' : '{}'", uuid, name); LOG(trace, "Deserialized entity '{}' : '{}'", uuid, name);
Entity deserializedEntity = m_Scene->CreateEntityWithUUID(name, uuid); Entity deserializedEntity = m_scene->CreateEntityWithUUID(name, uuid);
TagComponent gg = deserializedEntity.GetComponent<TagComponent>(); TagComponent gg = deserializedEntity.GetComponent<TagComponent>();
LOG(trace, gg.tag); LOG(trace, gg.tag);

View file

@ -11,23 +11,23 @@ namespace Light {
class EditorLayer: public Layer class EditorLayer: public Layer
{ {
private: private:
std::string m_SceneDir; std::string m_scene_dir;
// #todo: add camera controller class to the engine // #todo: add camera controller class to the engine
glm::vec2 m_Direction; glm::vec2 m_direction;
float m_Speed = 1000.0f; float m_speed = 1000.0f;
Ref<Scene> m_Scene; Ref<Scene> m_scene;
Ref<SceneHierarchyPanel> m_SceneHierarchyPanel; Ref<SceneHierarchyPanel> m_sceneHierarchyPanel;
Ref<PropertiesPanel> m_PropertiesPanel; Ref<PropertiesPanel> m_properties_panel;
Ref<AssetBrowserPanel> m_ContentBrowserPanel; Ref<AssetBrowserPanel> m_content_browser_panel;
Ref<Framebuffer> m_Framebuffer; Ref<Framebuffer> m_framebuffer;
Entity m_CameraEntity; Entity m_camera_entity;
ImVec2 m_AvailableContentRegionPrev; ImVec2 m_available_content_region_prev;
public: public:
EditorLayer(const std::string &name); EditorLayer(const std::string &name);

View file

@ -24,19 +24,19 @@ public:
void OnUserInterfaceUpdate(); void OnUserInterfaceUpdate();
private: private:
std::filesystem::path m_CurrentDirectory; std::filesystem::path m_current_directory;
const std::filesystem::path m_AssetsPath; const std::filesystem::path m_assets_path;
// TODO: Save configuration // TODO: Save configuration
uint32_t m_FileSize = 128u; uint32_t m_file_size = 128u;
uint32_t m_FilePadding = 8u; uint32_t m_file_padding = 8u;
Ref<Scene> m_ActiveScene; Ref<Scene> m_active_scene;
Ref<Texture> m_DirectoryTexture; Ref<Texture> m_directory_texture;
Ref<Texture> m_SceneTexture; Ref<Texture> m_scene_texture;
Ref<Texture> m_ImageTexture; Ref<Texture> m_image_texture;
Ref<Texture> m_TextTexture; Ref<Texture> m_text_texture;
}; };
} // namespace Light } // namespace Light

View file

@ -8,7 +8,7 @@ namespace Light {
class PropertiesPanel: public Panel class PropertiesPanel: public Panel
{ {
private: private:
Entity m_EntityContext; Entity m_entity_context;
public: public:
PropertiesPanel() = default; PropertiesPanel() = default;

View file

@ -12,9 +12,9 @@ class PropertiesPanel;
class SceneHierarchyPanel: public Panel class SceneHierarchyPanel: public Panel
{ {
private: private:
Ref<Scene> m_Context; Ref<Scene> m_context;
Ref<PropertiesPanel> m_PropertiesPanelContext; Ref<PropertiesPanel> m_properties_panel_context;
Entity m_SelectionContext; Entity m_selection_context;
public: public:
SceneHierarchyPanel(); SceneHierarchyPanel();

View file

@ -3,23 +3,23 @@
namespace Light { namespace Light {
EditorLayer::EditorLayer(const std::string &name): Layer(name), m_SceneDir("") EditorLayer::EditorLayer(const std::string &name): Layer(name), m_scene_dir("")
{ {
m_Scene = CreateRef<Scene>(); m_scene = CreateRef<Scene>();
m_PropertiesPanel = CreateRef<PropertiesPanel>(); m_properties_panel = CreateRef<PropertiesPanel>();
m_SceneHierarchyPanel = CreateRef<SceneHierarchyPanel>(m_Scene, m_PropertiesPanel); m_sceneHierarchyPanel = CreateRef<SceneHierarchyPanel>(m_scene, m_properties_panel);
m_ContentBrowserPanel = CreateRef<AssetBrowserPanel>(m_Scene); m_content_browser_panel = CreateRef<AssetBrowserPanel>(m_scene);
m_Framebuffer = Framebuffer::Create({ 1, 1, 1 }, GraphicsContext::GetSharedContext()); m_framebuffer = Framebuffer::Create({ 1, 1, 1 }, GraphicsContext::GetSharedContext());
if (m_SceneDir.empty()) if (m_scene_dir.empty())
{ {
m_CameraEntity = m_Scene->CreateEntity("Camera"); m_camera_entity = m_scene->CreateEntity("Camera");
m_CameraEntity.AddComponent<CameraComponent>(SceneCamera(), true); m_camera_entity.AddComponent<CameraComponent>(SceneCamera(), true);
ResourceManager::LoadTexture("Awesomeface", "Assets/Textures/awesomeface.png"); ResourceManager::LoadTexture("Awesomeface", "Assets/Textures/awesomeface.png");
Entity entity = m_Scene->CreateEntity("Awesomeface", {}); Entity entity = m_scene->CreateEntity("Awesomeface", {});
entity.AddComponent<SpriteRendererComponent>( entity.AddComponent<SpriteRendererComponent>(
ResourceManager::GetTexture("Awesomeface"), ResourceManager::GetTexture("Awesomeface"),
glm::vec4 { 0.0f, 1.0f, 1.0f, 1.0f } glm::vec4 { 0.0f, 1.0f, 1.0f, 1.0f }
@ -27,36 +27,36 @@ EditorLayer::EditorLayer(const std::string &name): Layer(name), m_SceneDir("")
} }
else else
{ {
SceneSerializer serializer(m_Scene); SceneSerializer serializer(m_scene);
ASSERT(serializer.Deserialize(m_SceneDir), "Failed to de-serialize: {}", m_SceneDir); ASSERT(serializer.Deserialize(m_scene_dir), "Failed to de-serialize: {}", m_scene_dir);
// m_CameraEntity = m_Scene->GetEntityByTag("Game Camera"); // m_camera_entity = m_scene->GetEntityByTag("Game Camera");
} }
} }
EditorLayer::~EditorLayer() EditorLayer::~EditorLayer()
{ {
if (!m_SceneDir.empty()) if (!m_scene_dir.empty())
{ {
SceneSerializer serializer(m_Scene); SceneSerializer serializer(m_scene);
serializer.Serialize(m_SceneDir); serializer.Serialize(m_scene_dir);
} }
} }
void EditorLayer::OnUpdate(float deltaTime) void EditorLayer::OnUpdate(float deltaTime)
{ {
m_Scene->OnUpdate(deltaTime); m_scene->OnUpdate(deltaTime);
m_Direction.x = Input::GetKeyboardKey(Key::A) ? -1.0f : m_direction.x = Input::GetKeyboardKey(Key::A) ? -1.0f :
Input::GetKeyboardKey(Key::D) ? 1.0f : Input::GetKeyboardKey(Key::D) ? 1.0f :
0.0f; 0.0f;
m_Direction.y = Input::GetKeyboardKey(Key::S) ? -1.0f : m_direction.y = Input::GetKeyboardKey(Key::S) ? -1.0f :
Input::GetKeyboardKey(Key::W) ? 1.0f : Input::GetKeyboardKey(Key::W) ? 1.0f :
0.0f; 0.0f;
auto &cameraTranslation = m_CameraEntity.GetComponent<TransformComponent>().translation; auto &cameraTranslation = m_camera_entity.GetComponent<TransformComponent>().translation;
cameraTranslation += glm::vec3(m_Direction * m_Speed * deltaTime, 0.0f); cameraTranslation += glm::vec3(m_direction * m_speed * deltaTime, 0.0f);
if (Input::GetKeyboardKey(Key::Escape)) if (Input::GetKeyboardKey(Key::Escape))
Application::Quit(); Application::Quit();
@ -64,7 +64,7 @@ void EditorLayer::OnUpdate(float deltaTime)
void EditorLayer::OnRender() void EditorLayer::OnRender()
{ {
m_Scene->OnRender(m_Framebuffer); m_scene->OnRender(m_framebuffer);
} }
void EditorLayer::OnUserInterfaceUpdate() void EditorLayer::OnUserInterfaceUpdate()
@ -77,20 +77,20 @@ void EditorLayer::OnUserInterfaceUpdate()
Input::ReceiveGameEvents(ImGui::IsWindowFocused()); Input::ReceiveGameEvents(ImGui::IsWindowFocused());
ImVec2 regionAvail = ImGui::GetContentRegionAvail(); ImVec2 regionAvail = ImGui::GetContentRegionAvail();
if (m_AvailableContentRegionPrev != regionAvail) if (m_available_content_region_prev != regionAvail)
{ {
m_Framebuffer->Resize({ regionAvail.x, regionAvail.y }); m_framebuffer->Resize({ regionAvail.x, regionAvail.y });
auto &camera = m_CameraEntity.GetComponent<CameraComponent>().camera; auto &camera = m_camera_entity.GetComponent<CameraComponent>().camera;
camera.SetViewportSize(regionAvail.x, regionAvail.y); camera.SetViewportSize(regionAvail.x, regionAvail.y);
m_AvailableContentRegionPrev = regionAvail; m_available_content_region_prev = regionAvail;
} }
if (GraphicsContext::GetGraphicsAPI() == GraphicsAPI::DirectX) if (GraphicsContext::GetGraphicsAPI() == GraphicsAPI::DirectX)
ImGui::Image(m_Framebuffer->GetColorAttachment(), regionAvail); ImGui::Image(m_framebuffer->GetColorAttachment(), regionAvail);
else else
ImGui::Image( ImGui::Image(
m_Framebuffer->GetColorAttachment(), m_framebuffer->GetColorAttachment(),
regionAvail, regionAvail,
ImVec2(0, 1), ImVec2(0, 1),
ImVec2(1, 0) ImVec2(1, 0)
@ -99,9 +99,9 @@ void EditorLayer::OnUserInterfaceUpdate()
ImGui::End(); ImGui::End();
// Panels // Panels
m_SceneHierarchyPanel->OnUserInterfaceUpdate(); m_sceneHierarchyPanel->OnUserInterfaceUpdate();
m_PropertiesPanel->OnUserInterfaceUpdate(); m_properties_panel->OnUserInterfaceUpdate();
m_ContentBrowserPanel->OnUserInterfaceUpdate(); m_content_browser_panel->OnUserInterfaceUpdate();
UserInterface::DockspaceEnd(); UserInterface::DockspaceEnd();
} }

View file

@ -19,7 +19,7 @@ public:
properties.size = glm::uvec2(1280u, 720u); properties.size = glm::uvec2(1280u, 720u);
properties.vsync = true; properties.vsync = true;
m_Window->SetProperties(properties); m_window->SetProperties(properties);
// Attach the sandbox layer // Attach the sandbox layer
LayerStack::EmplaceLayer<EditorLayer>(("MirrorLayer")); LayerStack::EmplaceLayer<EditorLayer>(("MirrorLayer"));

View file

@ -6,19 +6,19 @@
namespace Light { namespace Light {
AssetBrowserPanel::AssetBrowserPanel(Ref<Scene> activeScene) AssetBrowserPanel::AssetBrowserPanel(Ref<Scene> activeScene)
: m_CurrentDirectory("Assets") : m_current_directory("Assets")
, m_AssetsPath("Assets") , m_assets_path("Assets")
, m_ActiveScene(activeScene) , m_active_scene(activeScene)
{ {
ResourceManager::LoadTexture("_Assets_Directory", "EngineResources/Icons/Asset_Directory.png"); ResourceManager::LoadTexture("_Assets_Directory", "EngineResources/Icons/Asset_Directory.png");
ResourceManager::LoadTexture("_Assets_Scene", "EngineResources/Icons/Asset_Scene.png"); ResourceManager::LoadTexture("_Assets_Scene", "EngineResources/Icons/Asset_Scene.png");
ResourceManager::LoadTexture("_Assets_Image", "EngineResources/Icons/Asset_Image.png"); ResourceManager::LoadTexture("_Assets_Image", "EngineResources/Icons/Asset_Image.png");
ResourceManager::LoadTexture("_Assets_Text", "EngineResources/Icons/Asset_Text.png"); ResourceManager::LoadTexture("_Assets_Text", "EngineResources/Icons/Asset_Text.png");
m_DirectoryTexture = ResourceManager::GetTexture("_Assets_Directory"); m_directory_texture = ResourceManager::GetTexture("_Assets_Directory");
m_SceneTexture = ResourceManager::GetTexture("_Assets_Scene"); m_scene_texture = ResourceManager::GetTexture("_Assets_Scene");
m_ImageTexture = ResourceManager::GetTexture("_Assets_Image"); m_image_texture = ResourceManager::GetTexture("_Assets_Image");
m_TextTexture = ResourceManager::GetTexture("_Assets_Text"); m_text_texture = ResourceManager::GetTexture("_Assets_Text");
} }
void AssetBrowserPanel::OnUserInterfaceUpdate() void AssetBrowserPanel::OnUserInterfaceUpdate()
@ -26,16 +26,16 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
ImGui::Begin("Content Browser"); ImGui::Begin("Content Browser");
// Parent directory button // Parent directory button
if (m_CurrentDirectory != std::filesystem::path("Assets")) if (m_current_directory != std::filesystem::path("Assets"))
{ {
if (ImGui::Button(" <-- ")) if (ImGui::Button(" <-- "))
{ {
m_CurrentDirectory = m_CurrentDirectory.parent_path(); m_current_directory = m_current_directory.parent_path();
} }
} }
ImVec2 regionAvail = ImGui::GetContentRegionAvail(); ImVec2 regionAvail = ImGui::GetContentRegionAvail();
uint32_t cellSize = m_FileSize + m_FilePadding; uint32_t cellSize = m_file_size + m_file_padding;
uint32_t columnCount = std::clamp( uint32_t columnCount = std::clamp(
static_cast<uint32_t>(std::floor(regionAvail.x / cellSize)), static_cast<uint32_t>(std::floor(regionAvail.x / cellSize)),
1u, 1u,
@ -44,8 +44,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
if (ImGui::BeginTable("ContentBrowser", columnCount)) if (ImGui::BeginTable("ContentBrowser", columnCount))
{ {
m_DirectoryTexture->Bind(0u); m_directory_texture->Bind(0u);
for (auto &dirEntry : std::filesystem::directory_iterator(m_CurrentDirectory)) for (auto &dirEntry : std::filesystem::directory_iterator(m_current_directory))
{ {
const auto &path = dirEntry.path(); const auto &path = dirEntry.path();
std::string extension = dirEntry.path().extension().string(); std::string extension = dirEntry.path().extension().string();
@ -77,8 +77,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
// Directory // Directory
case AssetType::Directory: case AssetType::Directory:
if (ImGui::ImageButton( if (ImGui::ImageButton(
m_DirectoryTexture->GetTexture(), m_directory_texture->GetTexture(),
ImVec2(m_FileSize, m_FileSize), ImVec2(m_file_size, m_file_size),
ImVec2 { 0.0f, 0.0f }, ImVec2 { 0.0f, 0.0f },
ImVec2 { 1.0f, 1.0f }, ImVec2 { 1.0f, 1.0f },
0, 0,
@ -86,15 +86,15 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
ImVec4 { 1.0f, 1.0f, 1.0f, 1.0f } ImVec4 { 1.0f, 1.0f, 1.0f, 1.0f }
)) ))
{ {
m_CurrentDirectory /= path.filename(); m_current_directory /= path.filename();
} }
break; break;
// Scene // Scene
case AssetType::Scene: case AssetType::Scene:
if (ImGui::ImageButton( if (ImGui::ImageButton(
m_SceneTexture->GetTexture(), m_scene_texture->GetTexture(),
ImVec2(m_FileSize, m_FileSize), ImVec2(m_file_size, m_file_size),
ImVec2 { 0.0f, 0.0f }, ImVec2 { 0.0f, 0.0f },
ImVec2 { 1.0f, 1.0f }, ImVec2 { 1.0f, 1.0f },
0, 0,
@ -102,7 +102,7 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
ImVec4 { 1.0f, 1.0f, 1.0f, 1.0f } ImVec4 { 1.0f, 1.0f, 1.0f, 1.0f }
)) ))
{ {
SceneSerializer serializer(m_ActiveScene); SceneSerializer serializer(m_active_scene);
LOG(info, "Attempting to deserialize: {}", path.string()); LOG(info, "Attempting to deserialize: {}", path.string());
serializer.Deserialize(path.string()); serializer.Deserialize(path.string());
} }
@ -111,8 +111,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
// Image // Image
case AssetType::Image: case AssetType::Image:
if (ImGui::ImageButton( if (ImGui::ImageButton(
m_ImageTexture->GetTexture(), m_image_texture->GetTexture(),
ImVec2(m_FileSize, m_FileSize), ImVec2(m_file_size, m_file_size),
ImVec2 { 0.0f, 0.0f }, ImVec2 { 0.0f, 0.0f },
ImVec2 { 1.0f, 1.0f }, ImVec2 { 1.0f, 1.0f },
0, 0,
@ -126,8 +126,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
// Text // Text
case AssetType::Text: case AssetType::Text:
if (ImGui::ImageButton( if (ImGui::ImageButton(
m_TextTexture->GetTexture(), m_text_texture->GetTexture(),
ImVec2(m_FileSize, m_FileSize), ImVec2(m_file_size, m_file_size),
ImVec2 { 0.0f, 0.0f }, ImVec2 { 0.0f, 0.0f },
ImVec2 { 1.0f, 1.0f }, ImVec2 { 1.0f, 1.0f },
0, 0,

View file

@ -12,11 +12,11 @@ void PropertiesPanel::OnUserInterfaceUpdate()
{ {
ImGui::Begin("Properties"); ImGui::Begin("Properties");
if (m_EntityContext.IsValid()) if (m_entity_context.IsValid())
{ {
if (m_EntityContext.HasComponent<TagComponent>()) if (m_entity_context.HasComponent<TagComponent>())
{ {
auto &tagComponent = m_EntityContext.GetComponent<TagComponent>(); auto &tagComponent = m_entity_context.GetComponent<TagComponent>();
char buffer[256]; char buffer[256];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
@ -37,22 +37,22 @@ void PropertiesPanel::OnUserInterfaceUpdate()
if (ImGui::Selectable( if (ImGui::Selectable(
"SpriteRenderer", "SpriteRenderer",
false, false,
m_EntityContext.HasComponent<SpriteRendererComponent>() ? m_entity_context.HasComponent<SpriteRendererComponent>() ?
ImGuiSelectableFlags_Disabled : ImGuiSelectableFlags_Disabled :
NULL NULL
)) ))
m_EntityContext.AddComponent<SpriteRendererComponent>( m_entity_context.AddComponent<SpriteRendererComponent>(
Light::ResourceManager::GetTexture("awesomeface") Light::ResourceManager::GetTexture("awesomeface")
); );
if (ImGui::Selectable( if (ImGui::Selectable(
"Camera", "Camera",
false, false,
m_EntityContext.HasComponent<CameraComponent>() ? m_entity_context.HasComponent<CameraComponent>() ?
ImGuiSelectableFlags_Disabled : ImGuiSelectableFlags_Disabled :
NULL NULL
)) ))
m_EntityContext.AddComponent<CameraComponent>(); m_entity_context.AddComponent<CameraComponent>();
ImGui::EndPopup(); ImGui::EndPopup();
} }
@ -60,7 +60,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
DrawComponent<TransformComponent>( DrawComponent<TransformComponent>(
"Transform Component", "Transform Component",
m_EntityContext, m_entity_context,
[&](auto &transformComponent) { [&](auto &transformComponent) {
DrawVec3Control("Translation", transformComponent.translation); DrawVec3Control("Translation", transformComponent.translation);
} }
@ -68,7 +68,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
DrawComponent<SpriteRendererComponent>( DrawComponent<SpriteRendererComponent>(
"SpriteRenderer Component", "SpriteRenderer Component",
m_EntityContext, m_entity_context,
[&](auto &spriteRendererComponent) { [&](auto &spriteRendererComponent) {
ImGui::ColorEdit4("Color", &spriteRendererComponent.tint[0]); ImGui::ColorEdit4("Color", &spriteRendererComponent.tint[0]);
} }
@ -76,7 +76,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
DrawComponent<CameraComponent>( DrawComponent<CameraComponent>(
"Camera Component", "Camera Component",
m_EntityContext, m_entity_context,
[&](auto &cameraComponent) { [&](auto &cameraComponent) {
auto &camera = cameraComponent.camera; auto &camera = cameraComponent.camera;
@ -147,7 +147,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
void PropertiesPanel::SetEntityContext(Entity entity) void PropertiesPanel::SetEntityContext(Entity entity)
{ {
m_EntityContext = entity; m_entity_context = entity;
} }
void PropertiesPanel::DrawVec3Control( void PropertiesPanel::DrawVec3Control(

View file

@ -7,28 +7,28 @@
namespace Light { namespace Light {
SceneHierarchyPanel::SceneHierarchyPanel() SceneHierarchyPanel::SceneHierarchyPanel()
: m_Context(nullptr) : m_context(nullptr)
, m_PropertiesPanelContext(nullptr) , m_properties_panel_context(nullptr)
, m_SelectionContext() , m_selection_context()
{ {
} }
SceneHierarchyPanel:: SceneHierarchyPanel::
SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel /* = nullptr */) SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel /* = nullptr */)
: m_Context(context) : m_context(context)
, m_PropertiesPanelContext(propertiesPanel) , m_properties_panel_context(propertiesPanel)
{ {
} }
void SceneHierarchyPanel::OnUserInterfaceUpdate() void SceneHierarchyPanel::OnUserInterfaceUpdate()
{ {
if (m_Context) if (m_context)
{ {
ImGui::Begin("Hierarchy"); ImGui::Begin("Hierarchy");
for (auto entityID : m_Context->m_Registry.view<TagComponent>()) for (auto entityID : m_context->m_registry.view<TagComponent>())
{ {
Entity entity(static_cast<entt::entity>(entityID), m_Context.get()); Entity entity(static_cast<entt::entity>(entityID), m_context.get());
const std::string &tag = entity.GetComponent<TagComponent>(); const std::string &tag = entity.GetComponent<TagComponent>();
DrawNode(entity, tag); DrawNode(entity, tag);
@ -42,22 +42,22 @@ void SceneHierarchyPanel::
SetContext(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel /* = nullptr */) SetContext(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel /* = nullptr */)
{ {
if (propertiesPanel) if (propertiesPanel)
m_PropertiesPanelContext = propertiesPanel; m_properties_panel_context = propertiesPanel;
m_Context = context; m_context = context;
} }
void SceneHierarchyPanel::DrawNode(Entity entity, const std::string &label) void SceneHierarchyPanel::DrawNode(Entity entity, const std::string &label)
{ {
ImGuiTreeNodeFlags flags = (m_SelectionContext == entity ? ImGuiTreeNodeFlags_Selected : NULL) ImGuiTreeNodeFlags flags = (m_selection_context == entity ? ImGuiTreeNodeFlags_Selected : NULL)
| ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth; | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth;
bool expanded = ImGui::TreeNodeEx((void *)(uint64_t)(uint32_t)(entity), flags, label.c_str()); bool expanded = ImGui::TreeNodeEx((void *)(uint64_t)(uint32_t)(entity), flags, label.c_str());
if (ImGui::IsItemClicked()) if (ImGui::IsItemClicked())
{ {
m_SelectionContext = entity; m_selection_context = entity;
m_PropertiesPanelContext->SetEntityContext(entity); m_properties_panel_context->SetEntityContext(entity);
} }
if (expanded) if (expanded)