style: PascalCase member variables to snake_case
This commit is contained in:
parent
0cedb2b0ba
commit
586571fcb0
100 changed files with 1035 additions and 1035 deletions
|
@ -8,27 +8,27 @@ namespace Light {
|
|||
class Camera
|
||||
{
|
||||
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:
|
||||
glm::mat4 m_Projection;
|
||||
glm::mat4 m_projection;
|
||||
|
||||
public:
|
||||
Camera() = default;
|
||||
|
||||
inline const glm::mat4 &GetProjection() const
|
||||
{
|
||||
return m_Projection;
|
||||
return m_projection;
|
||||
}
|
||||
|
||||
inline const glm::vec4 &GetBackgroundColor() const
|
||||
{
|
||||
return m_BackgroundColor;
|
||||
return m_background_color;
|
||||
}
|
||||
|
||||
inline void SetBackgroundColor(const glm::vec4 &color)
|
||||
{
|
||||
m_BackgroundColor = color;
|
||||
m_background_color = color;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -8,16 +8,16 @@ namespace Light {
|
|||
class OrthographicCamera
|
||||
{
|
||||
private:
|
||||
glm::vec2 m_Position;
|
||||
float m_AspectRatio;
|
||||
float m_ZoomLevel;
|
||||
glm::vec2 m_position;
|
||||
float m_aspect_ratio;
|
||||
float m_zoom_level;
|
||||
|
||||
const glm::vec3 m_Up;
|
||||
const glm::vec3 m_up;
|
||||
|
||||
glm::mat4 m_Projection;
|
||||
glm::mat4 m_View;
|
||||
glm::mat4 m_projection;
|
||||
glm::mat4 m_view;
|
||||
|
||||
glm::vec4 m_ClearColor;
|
||||
glm::vec4 m_clear_color;
|
||||
|
||||
public:
|
||||
OrthographicCamera(
|
||||
|
@ -35,16 +35,16 @@ public:
|
|||
|
||||
inline const glm::mat4 &GetView() const
|
||||
{
|
||||
return m_View;
|
||||
return m_view;
|
||||
}
|
||||
inline const glm::mat4 &GetProjection() const
|
||||
{
|
||||
return m_Projection;
|
||||
return m_projection;
|
||||
}
|
||||
|
||||
inline const glm::vec4 &GetClearColor() const
|
||||
{
|
||||
return m_ClearColor;
|
||||
return m_clear_color;
|
||||
}
|
||||
|
||||
// CAMERA_CONTROLLER //
|
||||
|
|
|
@ -27,11 +27,11 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
OrthographicSpecification m_OrthographicSpecification;
|
||||
PerspectiveSpecification m_PerspectiveSpecification;
|
||||
float m_AspectRatio;
|
||||
OrthographicSpecification m_orthographic_specification;
|
||||
PerspectiveSpecification m_perspective_specification;
|
||||
float m_aspect_ratio;
|
||||
|
||||
ProjectionType m_ProjectionType;
|
||||
ProjectionType m_projection_type;
|
||||
|
||||
public:
|
||||
SceneCamera();
|
||||
|
@ -50,33 +50,33 @@ public:
|
|||
|
||||
inline float GetOrthographicSize() const
|
||||
{
|
||||
return m_OrthographicSpecification.size;
|
||||
return m_orthographic_specification.size;
|
||||
}
|
||||
inline float GetOrthographicFarPlane() const
|
||||
{
|
||||
return m_OrthographicSpecification.farPlane;
|
||||
return m_orthographic_specification.farPlane;
|
||||
}
|
||||
inline float GetOrthographicNearPlane() const
|
||||
{
|
||||
return m_OrthographicSpecification.nearPlane;
|
||||
return m_orthographic_specification.nearPlane;
|
||||
}
|
||||
|
||||
inline float GetPerspectiveVerticalFOV() const
|
||||
{
|
||||
return m_PerspectiveSpecification.verticalFOV;
|
||||
return m_perspective_specification.verticalFOV;
|
||||
}
|
||||
inline float GetPerspectiveFarPlane() const
|
||||
{
|
||||
return m_PerspectiveSpecification.farPlane;
|
||||
return m_perspective_specification.farPlane;
|
||||
}
|
||||
inline float GetPerspectiveNearPlane() const
|
||||
{
|
||||
return m_PerspectiveSpecification.nearPlane;
|
||||
return m_perspective_specification.nearPlane;
|
||||
}
|
||||
|
||||
inline ProjectionType GetProjectionType() const
|
||||
{
|
||||
return m_ProjectionType;
|
||||
return m_projection_type;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -19,14 +19,14 @@ private:
|
|||
static Application *s_Context;
|
||||
|
||||
private:
|
||||
Scope<Logger> m_Logger;
|
||||
Scope<Instrumentor> m_Instrumentor;
|
||||
Scope<LayerStack> m_LayerStack;
|
||||
Scope<Input> m_Input;
|
||||
Scope<ResourceManager> m_ResourceManager;
|
||||
Scope<Logger> m_logger;
|
||||
Scope<Instrumentor> m_instrumentor;
|
||||
Scope<LayerStack> m_layer_stack;
|
||||
Scope<Input> m_input;
|
||||
Scope<ResourceManager> m_resource_manager;
|
||||
|
||||
protected:
|
||||
Scope<Window> m_Window;
|
||||
Scope<Window> m_window;
|
||||
|
||||
public:
|
||||
Application(const Application &) = delete;
|
||||
|
|
|
@ -11,14 +11,14 @@ private:
|
|||
static std::uniform_int_distribution<uint64_t> s_UniformDistribution;
|
||||
|
||||
private:
|
||||
uint64_t m_UUID;
|
||||
uint64_t m_uuid;
|
||||
|
||||
public:
|
||||
UUID(uint64_t uuid = -1);
|
||||
|
||||
operator uint64_t() const
|
||||
{
|
||||
return m_UUID;
|
||||
return m_uuid;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ struct WindowProperties
|
|||
class Window
|
||||
{
|
||||
protected:
|
||||
Scope<GraphicsContext> m_GraphicsContext;
|
||||
WindowProperties m_Properties;
|
||||
Scope<GraphicsContext> m_graphics_context;
|
||||
WindowProperties m_properties;
|
||||
bool b_Closed;
|
||||
|
||||
public:
|
||||
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 ==============================//
|
||||
inline GraphicsContext *GetGfxContext() const
|
||||
{
|
||||
return m_GraphicsContext.get();
|
||||
return m_graphics_context.get();
|
||||
}
|
||||
|
||||
inline const WindowProperties &GetProperties() const
|
||||
{
|
||||
return m_Properties;
|
||||
return m_properties;
|
||||
}
|
||||
|
||||
inline const std::string &GetTitle() const
|
||||
{
|
||||
return m_Properties.title;
|
||||
return m_properties.title;
|
||||
}
|
||||
|
||||
inline const glm::uvec2 &GetSize() const
|
||||
{
|
||||
return m_Properties.size;
|
||||
return m_properties.size;
|
||||
}
|
||||
|
||||
inline bool IsClosed() const
|
||||
|
@ -85,11 +85,11 @@ public:
|
|||
}
|
||||
inline bool IsVSync() const
|
||||
{
|
||||
return m_Properties.vsync;
|
||||
return m_properties.vsync;
|
||||
}
|
||||
inline bool IsVisible() const
|
||||
{
|
||||
return m_Properties.visible;
|
||||
return m_properties.visible;
|
||||
}
|
||||
//============================== GETTERS ==============================//
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ private:
|
|||
static Instrumentor *s_Context;
|
||||
|
||||
private:
|
||||
std::ofstream m_OutputFileStream;
|
||||
std::ofstream m_output_file_stream;
|
||||
|
||||
unsigned int m_CurrentSessionCount;
|
||||
unsigned int m_current_session_count;
|
||||
|
||||
public:
|
||||
static Scope<Instrumentor> Create();
|
||||
|
@ -54,8 +54,8 @@ private:
|
|||
class InstrumentorTimer
|
||||
{
|
||||
private:
|
||||
ScopeProfileResult m_Result;
|
||||
std::chrono::time_point<std::chrono::steady_clock> m_Start;
|
||||
ScopeProfileResult m_result;
|
||||
std::chrono::time_point<std::chrono::steady_clock> m_start;
|
||||
|
||||
public:
|
||||
InstrumentorTimer(const std::string &scopeName);
|
||||
|
|
|
@ -32,19 +32,19 @@ private:
|
|||
static Logger *s_Context;
|
||||
|
||||
private:
|
||||
Ref<spdlog::logger> m_EngineLogger, m_FileLogger;
|
||||
std::string m_LogFilePath;
|
||||
Ref<spdlog::logger> m_engine_logger, m_file_logger;
|
||||
std::string m_log_file_path;
|
||||
|
||||
public:
|
||||
static Scope<Logger> Create();
|
||||
|
||||
static inline Ref<spdlog::logger> GetEngineLogger()
|
||||
{
|
||||
return s_Context->m_EngineLogger;
|
||||
return s_Context->m_engine_logger;
|
||||
}
|
||||
static inline Ref<spdlog::logger> GetFileLogger()
|
||||
{
|
||||
return s_Context->m_FileLogger;
|
||||
return s_Context->m_file_logger;
|
||||
}
|
||||
|
||||
void LogDebugData();
|
||||
|
|
|
@ -9,22 +9,22 @@ namespace Light {
|
|||
class SetCharEvent: public Event
|
||||
{
|
||||
private:
|
||||
const unsigned int m_Character;
|
||||
const unsigned int m_character;
|
||||
|
||||
public:
|
||||
SetCharEvent(unsigned int character): m_Character(character)
|
||||
SetCharEvent(unsigned int character): m_character(character)
|
||||
{
|
||||
}
|
||||
|
||||
inline int GetCharacter() const
|
||||
{
|
||||
return m_Character;
|
||||
return m_character;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "CharSet: " << m_Character;
|
||||
ss << "CharSet: " << m_character;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(SetChar)
|
||||
|
|
|
@ -9,22 +9,22 @@ namespace Light {
|
|||
class KeyPressedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const int m_Key;
|
||||
const int m_key;
|
||||
|
||||
public:
|
||||
KeyPressedEvent(int key): m_Key(key)
|
||||
KeyPressedEvent(int key): m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
inline int GetKey() const
|
||||
{
|
||||
return m_Key;
|
||||
return m_key;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "KeyPressed: " << m_Key;
|
||||
ss << "KeyPressed: " << m_key;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(KeyPressed)
|
||||
|
@ -34,22 +34,22 @@ public:
|
|||
class KeyRepeatEvent: public Event
|
||||
{
|
||||
private:
|
||||
const int m_Key;
|
||||
const int m_key;
|
||||
|
||||
public:
|
||||
KeyRepeatEvent(int key): m_Key(key)
|
||||
KeyRepeatEvent(int key): m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
inline int GetKey() const
|
||||
{
|
||||
return m_Key;
|
||||
return m_key;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "KeyRepeated: " << m_Key;
|
||||
ss << "KeyRepeated: " << m_key;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(KeyRepeated)
|
||||
|
@ -59,22 +59,22 @@ public:
|
|||
class KeyReleasedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const int m_Key;
|
||||
const int m_key;
|
||||
|
||||
public:
|
||||
KeyReleasedEvent(int key): m_Key(key)
|
||||
KeyReleasedEvent(int key): m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
inline int GetKey() const
|
||||
{
|
||||
return m_Key;
|
||||
return m_key;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "KeyReleased: " << m_Key;
|
||||
ss << "KeyReleased: " << m_key;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(KeyReleased)
|
||||
|
|
|
@ -10,31 +10,31 @@ namespace Light {
|
|||
class MouseMovedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const glm::vec2 m_Position;
|
||||
const glm::vec2 m_position;
|
||||
|
||||
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
|
||||
{
|
||||
return m_Position;
|
||||
return m_position;
|
||||
}
|
||||
|
||||
inline float GetX() const
|
||||
{
|
||||
return m_Position.x;
|
||||
return m_position.x;
|
||||
}
|
||||
inline float GetY() const
|
||||
{
|
||||
return m_Position.y;
|
||||
return m_position.y;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MouseMoved: " << m_Position.x << ", " << m_Position.y;
|
||||
ss << "MouseMoved: " << m_position.x << ", " << m_position.y;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(MouseMoved)
|
||||
|
@ -44,22 +44,22 @@ public:
|
|||
class WheelScrolledEvent: public Event
|
||||
{
|
||||
private:
|
||||
const float m_Offset;
|
||||
const float m_offset;
|
||||
|
||||
public:
|
||||
WheelScrolledEvent(float offset): m_Offset(offset)
|
||||
WheelScrolledEvent(float offset): m_offset(offset)
|
||||
{
|
||||
}
|
||||
|
||||
inline float GetOffset() const
|
||||
{
|
||||
return m_Offset;
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "WheelScrolled: " << m_Offset;
|
||||
ss << "WheelScrolled: " << m_offset;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(WheelScrolled)
|
||||
|
@ -69,22 +69,22 @@ public:
|
|||
class ButtonPressedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const int m_Button;
|
||||
const int m_button;
|
||||
|
||||
public:
|
||||
ButtonPressedEvent(int button): m_Button(button)
|
||||
ButtonPressedEvent(int button): m_button(button)
|
||||
{
|
||||
}
|
||||
|
||||
inline int GetButton() const
|
||||
{
|
||||
return m_Button;
|
||||
return m_button;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "ButtonPressed: " << m_Button;
|
||||
ss << "ButtonPressed: " << m_button;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(ButtonPressed)
|
||||
|
@ -94,22 +94,22 @@ public:
|
|||
class ButtonReleasedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const int m_Button;
|
||||
const int m_button;
|
||||
|
||||
public:
|
||||
ButtonReleasedEvent(int button): m_Button(button)
|
||||
ButtonReleasedEvent(int button): m_button(button)
|
||||
{
|
||||
}
|
||||
|
||||
inline int GetButton() const
|
||||
{
|
||||
return m_Button;
|
||||
return m_button;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "ButtonReleased: " << m_Button;
|
||||
ss << "ButtonReleased: " << m_button;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(ButtonReleased)
|
||||
|
|
|
@ -21,22 +21,22 @@ public:
|
|||
class WindowMovedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const glm::ivec2 m_Position;
|
||||
const glm::ivec2 m_position;
|
||||
|
||||
public:
|
||||
WindowMovedEvent(int x, int y): m_Position(x, y)
|
||||
WindowMovedEvent(int x, int y): m_position(x, y)
|
||||
{
|
||||
}
|
||||
|
||||
const glm::ivec2 &GetPosition() const
|
||||
{
|
||||
return m_Position;
|
||||
return m_position;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "WindwoMoved: " << m_Position.x << ", " << m_Position.y;
|
||||
ss << "WindwoMoved: " << m_position.x << ", " << m_position.y;
|
||||
return ss.str();
|
||||
;
|
||||
}
|
||||
|
@ -47,22 +47,22 @@ public:
|
|||
class WindowResizedEvent: public Event
|
||||
{
|
||||
private:
|
||||
const glm::uvec2 m_Size;
|
||||
const glm::uvec2 m_size;
|
||||
|
||||
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
|
||||
{
|
||||
return m_Size;
|
||||
return m_size;
|
||||
}
|
||||
|
||||
virtual std::string GetInfoLog() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "WindowResized: " << m_Size.x << ", " << m_Size.y;
|
||||
ss << "WindowResized: " << m_size.x << ", " << m_size.y;
|
||||
return ss.str();
|
||||
}
|
||||
EVENT_TYPE(WindowResized)
|
||||
|
|
|
@ -29,12 +29,12 @@ private:
|
|||
static GraphicsContext* s_Context;
|
||||
|
||||
private:
|
||||
Scope<UserInterface> m_UserInterface;
|
||||
Scope<Renderer> m_Renderer;
|
||||
Scope<UserInterface> m_user_interface;
|
||||
Scope<Renderer> m_renderer;
|
||||
|
||||
protected:
|
||||
GraphicsAPI m_GraphicsAPI;
|
||||
Ref<SharedContext> m_SharedContext = nullptr;
|
||||
GraphicsAPI m_graphics_api;
|
||||
Ref<SharedContext> m_shared_context = nullptr;
|
||||
|
||||
public:
|
||||
static Scope<GraphicsContext> Create(GraphicsAPI api, GLFWwindow* windowHandle);
|
||||
|
@ -46,11 +46,11 @@ public:
|
|||
|
||||
virtual void LogDebugData() = 0;
|
||||
|
||||
static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; }
|
||||
static inline Ref<SharedContext> GetSharedContext() { return s_Context->m_SharedContext; }
|
||||
static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_graphics_api; }
|
||||
static inline Ref<SharedContext> GetSharedContext() { return s_Context->m_shared_context; }
|
||||
|
||||
inline Renderer* GetRenderer() { return m_Renderer.get(); }
|
||||
inline UserInterface* GetUserInterface() { return m_UserInterface.get(); }
|
||||
inline Renderer* GetRenderer() { return m_renderer.get(); }
|
||||
inline UserInterface* GetUserInterface() { return m_user_interface.get(); }
|
||||
|
||||
protected:
|
||||
GraphicsContext() = default;
|
||||
|
|
|
@ -31,20 +31,20 @@ private:
|
|||
static Renderer *s_Context;
|
||||
|
||||
// renderer programs
|
||||
QuadRendererProgram m_QuadRenderer;
|
||||
TextureRendererProgram m_TextureRenderer;
|
||||
TintedTextureRendererProgram m_TintedTextureRenderer;
|
||||
QuadRendererProgram m_quad_renderer;
|
||||
TextureRendererProgram m_texture_renderer;
|
||||
TintedTextureRendererProgram m_tinted_texture_renderer;
|
||||
|
||||
// constant buffers
|
||||
Scope<ConstantBuffer> m_ViewProjectionBuffer;
|
||||
Scope<ConstantBuffer> m_view_projection_buffer;
|
||||
|
||||
Scope<RenderCommand> m_RenderCommand;
|
||||
Scope<Blender> m_Blender;
|
||||
Scope<RenderCommand> m_render_command;
|
||||
Scope<Blender> m_blender;
|
||||
|
||||
Camera *m_DefaultFramebufferCamera;
|
||||
Ref<Framebuffer> m_TargetFramebuffer;
|
||||
Camera *m_default_framebuffer_camera;
|
||||
Ref<Framebuffer> m_target_framebuffer;
|
||||
|
||||
bool m_ShouldClearBackbuffer;
|
||||
bool m_should_clear_backbuffer;
|
||||
|
||||
public:
|
||||
static Scope<Renderer> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
|
||||
|
|
|
@ -25,16 +25,16 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
Ref<Shader> m_Shader;
|
||||
Ref<VertexBuffer> m_VertexBuffer;
|
||||
Ref<IndexBuffer> m_IndexBuffer;
|
||||
Ref<VertexLayout> m_VertexLayout;
|
||||
Ref<Shader> m_shader;
|
||||
Ref<VertexBuffer> m_vertex_buffer;
|
||||
Ref<IndexBuffer> m_index_buffer;
|
||||
Ref<VertexLayout> m_vertex_layout;
|
||||
|
||||
QuadVertexData *m_MapCurrent = nullptr;
|
||||
QuadVertexData *m_MapEnd = nullptr;
|
||||
QuadVertexData *m_map_current = nullptr;
|
||||
QuadVertexData *m_map_end = nullptr;
|
||||
|
||||
unsigned int m_QuadCount = 0u;
|
||||
unsigned int m_MaxVertices = 0u;
|
||||
unsigned int m_quad_count = 0u;
|
||||
unsigned int m_max_vertices = 0u;
|
||||
|
||||
public:
|
||||
QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
|
||||
|
@ -48,11 +48,11 @@ public:
|
|||
|
||||
inline QuadVertexData *GetMapCurrent()
|
||||
{
|
||||
return m_MapCurrent;
|
||||
return m_map_current;
|
||||
}
|
||||
inline unsigned int GetQuadCount() const
|
||||
{
|
||||
return m_QuadCount;
|
||||
return m_quad_count;
|
||||
}
|
||||
inline constexpr unsigned int GetVertexSize() const
|
||||
{
|
||||
|
|
|
@ -25,16 +25,16 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
Ref<Shader> m_Shader;
|
||||
Ref<VertexBuffer> m_VertexBuffer;
|
||||
Ref<IndexBuffer> m_IndexBuffer;
|
||||
Ref<VertexLayout> m_VertexLayout;
|
||||
Ref<Shader> m_shader;
|
||||
Ref<VertexBuffer> m_vertex_buffer;
|
||||
Ref<IndexBuffer> m_index_buffer;
|
||||
Ref<VertexLayout> m_vertex_layout;
|
||||
|
||||
TextureVertexData *m_MapCurrent = nullptr;
|
||||
TextureVertexData *m_MapEnd = nullptr;
|
||||
TextureVertexData *m_map_current = nullptr;
|
||||
TextureVertexData *m_map_end = nullptr;
|
||||
|
||||
unsigned int m_QuadCount;
|
||||
unsigned int m_MaxVertices;
|
||||
unsigned int m_quad_count;
|
||||
unsigned int m_max_vertices;
|
||||
|
||||
public:
|
||||
TextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
|
||||
|
@ -48,12 +48,12 @@ public:
|
|||
|
||||
inline TextureVertexData *GetMapCurrent()
|
||||
{
|
||||
return m_MapCurrent;
|
||||
return m_map_current;
|
||||
}
|
||||
|
||||
inline unsigned int GetQuadCount() const
|
||||
{
|
||||
return m_QuadCount;
|
||||
return m_quad_count;
|
||||
}
|
||||
|
||||
inline constexpr unsigned int GetVertexSize() const
|
||||
|
|
|
@ -26,16 +26,16 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
Ref<Shader> m_Shader;
|
||||
Ref<VertexBuffer> m_VertexBuffer;
|
||||
Ref<IndexBuffer> m_IndexBuffer;
|
||||
Ref<VertexLayout> m_VertexLayout;
|
||||
Ref<Shader> m_shader;
|
||||
Ref<VertexBuffer> m_vertex_buffer;
|
||||
Ref<IndexBuffer> m_index_buffer;
|
||||
Ref<VertexLayout> m_vertex_layout;
|
||||
|
||||
TintedTextureVertexData *m_MapCurrent = nullptr;
|
||||
TintedTextureVertexData *m_MapEnd = nullptr;
|
||||
TintedTextureVertexData *m_map_current = nullptr;
|
||||
TintedTextureVertexData *m_map_end = nullptr;
|
||||
|
||||
unsigned int m_QuadCount;
|
||||
unsigned int m_MaxVertices;
|
||||
unsigned int m_quad_count;
|
||||
unsigned int m_max_vertices;
|
||||
|
||||
public:
|
||||
TintedTextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext);
|
||||
|
@ -49,12 +49,12 @@ public:
|
|||
|
||||
inline TintedTextureVertexData *GetMapCurrent()
|
||||
{
|
||||
return m_MapCurrent;
|
||||
return m_map_current;
|
||||
}
|
||||
|
||||
inline unsigned int GetQuadCount() const
|
||||
{
|
||||
return m_QuadCount;
|
||||
return m_quad_count;
|
||||
}
|
||||
|
||||
inline constexpr unsigned int GetVertexSize() const
|
||||
|
|
|
@ -21,13 +21,13 @@ public:
|
|||
|
||||
virtual void* GetTexture() = 0;
|
||||
|
||||
inline const std::string& GetFilePath() const { return m_FilePath; }
|
||||
inline const std::string& GetFilePath() const { return m_file_path; }
|
||||
|
||||
protected:
|
||||
Texture(const std::string& filePath);
|
||||
|
||||
protected:
|
||||
std::string m_FilePath;
|
||||
std::string m_file_path;
|
||||
};
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -14,15 +14,15 @@ private:
|
|||
static Input *s_Context;
|
||||
|
||||
private:
|
||||
std::array<bool, 348> m_KeyboadKeys;
|
||||
std::array<bool, 8> m_MouseButtons;
|
||||
std::array<bool, 348> m_keyboad_keys;
|
||||
std::array<bool, 8> m_mouse_buttons;
|
||||
|
||||
glm::vec2 m_MousePosition;
|
||||
glm::vec2 m_MouseDelta;
|
||||
float m_MouseWheelDelta;
|
||||
glm::vec2 m_mouse_position;
|
||||
glm::vec2 m_mouse_delta;
|
||||
float m_mouse_wheel_delta;
|
||||
|
||||
bool m_UserInterfaceEvents;
|
||||
bool m_GameEvents;
|
||||
bool m_user_interface_events;
|
||||
bool m_game_events;
|
||||
|
||||
public:
|
||||
static Scope<Input> Create();
|
||||
|
@ -38,27 +38,27 @@ public:
|
|||
|
||||
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)
|
||||
{
|
||||
return s_Context->m_MouseButtons[code];
|
||||
return s_Context->m_mouse_buttons[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);
|
||||
|
||||
inline bool IsReceivingInputEvents() const
|
||||
{
|
||||
return m_UserInterfaceEvents;
|
||||
return m_user_interface_events;
|
||||
}
|
||||
inline bool IsReceivingGameEvents() const
|
||||
{
|
||||
return m_GameEvents;
|
||||
return m_game_events;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,7 +30,7 @@ class WindowGainFocusEvent;
|
|||
class Layer
|
||||
{
|
||||
protected:
|
||||
std::string m_LayerName;
|
||||
std::string m_layer_name;
|
||||
|
||||
public:
|
||||
Layer(const std::string &name);
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
inline const std::string &GetName() const
|
||||
{
|
||||
return m_LayerName;
|
||||
return m_layer_name;
|
||||
}
|
||||
|
||||
/* update */
|
||||
|
|
|
@ -14,10 +14,10 @@ private:
|
|||
static LayerStack *s_Context;
|
||||
|
||||
private:
|
||||
std::vector<Layer *> m_Layers;
|
||||
std::vector<Layer *> m_layers;
|
||||
|
||||
std::vector<Layer *>::iterator m_Begin;
|
||||
std::vector<Layer *>::iterator m_End;
|
||||
std::vector<Layer *>::iterator m_begin;
|
||||
std::vector<Layer *>::iterator m_end;
|
||||
|
||||
public:
|
||||
static Scope<LayerStack> Create();
|
||||
|
@ -42,24 +42,24 @@ public:
|
|||
|
||||
inline bool IsEmpty()
|
||||
{
|
||||
return m_Layers.empty();
|
||||
return m_layers.empty();
|
||||
}
|
||||
|
||||
std::vector<Layer *>::iterator begin()
|
||||
{
|
||||
return m_Layers.begin();
|
||||
return m_layers.begin();
|
||||
}
|
||||
std::vector<Layer *>::iterator end()
|
||||
{
|
||||
return m_Layers.end();
|
||||
return m_layers.end();
|
||||
}
|
||||
std::vector<Layer *>::reverse_iterator rbegin()
|
||||
{
|
||||
return m_Layers.rbegin();
|
||||
return m_layers.rbegin();
|
||||
}
|
||||
std::vector<Layer *>::reverse_iterator rend()
|
||||
{
|
||||
return m_Layers.rend();
|
||||
return m_layers.rend();
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -12,13 +12,13 @@ class dxSharedContext;
|
|||
class dxBlender: public Blender
|
||||
{
|
||||
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:
|
||||
dxBlender(Ref<dxSharedContext> sharedContext);
|
||||
|
|
|
@ -13,12 +13,12 @@ class dxSharedContext;
|
|||
class dxConstantBuffer: public ConstantBuffer
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_Buffer;
|
||||
D3D11_MAPPED_SUBRESOURCE m_Map;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
|
||||
D3D11_MAPPED_SUBRESOURCE m_map;
|
||||
|
||||
unsigned int m_Index;
|
||||
unsigned int m_index;
|
||||
|
||||
public:
|
||||
dxConstantBuffer(
|
||||
|
@ -37,12 +37,12 @@ public:
|
|||
class dxVertexBuffer: public VertexBuffer
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_Buffer;
|
||||
D3D11_MAPPED_SUBRESOURCE m_Map;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
|
||||
D3D11_MAPPED_SUBRESOURCE m_map;
|
||||
|
||||
unsigned int m_Stride;
|
||||
unsigned int m_stride;
|
||||
|
||||
public:
|
||||
dxVertexBuffer(
|
||||
|
@ -64,9 +64,9 @@ public:
|
|||
class dxIndexBuffer: public IndexBuffer
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_Buffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
|
||||
|
||||
public:
|
||||
dxIndexBuffer(unsigned int *indices, unsigned int count, Ref<dxSharedContext> sharedContext);
|
||||
|
|
|
@ -12,15 +12,15 @@ class dxSharedContext;
|
|||
class dxFramebuffer: public Framebuffer
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
FramebufferSpecification m_Specification;
|
||||
FramebufferSpecification m_specification;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_ColorAttachment;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_DepthStencilAttachment;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_ShaderResourceView;
|
||||
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_DepthStencilView;
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_render_target_view;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_color_attachment;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_depth_stencil_attachment;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_shader_resource_view;
|
||||
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depth_stencil_view;
|
||||
|
||||
public:
|
||||
dxFramebuffer(
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
inline void *GetColorAttachment() override
|
||||
{
|
||||
return (void *)m_ShaderResourceView.Get();
|
||||
return (void *)m_shader_resource_view.Get();
|
||||
}
|
||||
|
||||
void BindAsTarget(const glm::vec4 &clearColor) override;
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Light {
|
|||
class dxGraphicsContext: public GraphicsContext
|
||||
{
|
||||
private:
|
||||
GLFWwindow *m_WindowHandle;
|
||||
GLFWwindow *m_window_handle;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11Debug> m_DebugInterface;
|
||||
Microsoft::WRL::ComPtr<ID3D11Debug> m_debug_interface;
|
||||
|
||||
public:
|
||||
dxGraphicsContext(GLFWwindow *windowHandle);
|
||||
|
|
|
@ -12,7 +12,7 @@ class dxSharedContext;
|
|||
class dxRenderCommand: public RenderCommand
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
public:
|
||||
dxRenderCommand(Ref<dxSharedContext> sharedContext);
|
||||
|
|
|
@ -13,12 +13,12 @@ class dxSharedContext;
|
|||
class dxShader: public Shader
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_VertexShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_PixelShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertex_shader;
|
||||
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixel_shader;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3DBlob> m_VertexBlob;
|
||||
Microsoft::WRL::ComPtr<ID3DBlob> m_vertex_blob;
|
||||
|
||||
public:
|
||||
dxShader(
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
inline Microsoft::WRL::ComPtr<ID3DBlob> GetVertexBlob()
|
||||
{
|
||||
return m_VertexBlob;
|
||||
return m_vertex_blob;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,44 +10,44 @@ namespace Light {
|
|||
class dxSharedContext: public SharedContext
|
||||
{
|
||||
private:
|
||||
Microsoft::WRL::ComPtr<ID3D11Device> m_Device = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_DeviceContext = nullptr;
|
||||
Microsoft::WRL::ComPtr<IDXGISwapChain> m_SwapChain = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D11Device> m_device = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_deviceContext = nullptr;
|
||||
Microsoft::WRL::ComPtr<IDXGISwapChain> m_swap_chain = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_render_target_view = nullptr;
|
||||
|
||||
public:
|
||||
inline Microsoft::WRL::ComPtr<ID3D11Device> GetDevice()
|
||||
{
|
||||
return m_Device;
|
||||
return m_device;
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> GetDeviceContext()
|
||||
{
|
||||
return m_DeviceContext;
|
||||
return m_deviceContext;
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<IDXGISwapChain> GetSwapChain()
|
||||
{
|
||||
return m_SwapChain;
|
||||
return m_swap_chain;
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> GetRenderTargetView()
|
||||
{
|
||||
return m_RenderTargetView;
|
||||
return m_render_target_view;
|
||||
}
|
||||
|
||||
inline Microsoft::WRL::ComPtr<ID3D11Device> &GetDeviceRef()
|
||||
{
|
||||
return m_Device;
|
||||
return m_device;
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> &GetDeviceContextRef()
|
||||
{
|
||||
return m_DeviceContext;
|
||||
return m_deviceContext;
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<IDXGISwapChain> &GetSwapChainRef()
|
||||
{
|
||||
return m_SwapChain;
|
||||
return m_swap_chain;
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> &GetRenderTargetViewRef()
|
||||
{
|
||||
return m_RenderTargetView;
|
||||
return m_render_target_view;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ class dxSharedContext;
|
|||
class dxTexture: public Texture
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_Texture2D;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_ShaderResourceView;
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_SamplerState;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_texture_2d;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_shader_resource_view;
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_sampler_state;
|
||||
|
||||
public:
|
||||
dxTexture(
|
||||
|
|
|
@ -14,9 +14,9 @@ class dxSharedContext;
|
|||
class dxVertexLayout: public VertexLayout
|
||||
{
|
||||
private:
|
||||
Ref<dxSharedContext> m_Context;
|
||||
Ref<dxSharedContext> m_context;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_InputLayout;
|
||||
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_input_layout;
|
||||
|
||||
public:
|
||||
dxVertexLayout(
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Light {
|
|||
class glBlender: public Blender
|
||||
{
|
||||
private:
|
||||
std::unordered_map<BlendFactor, unsigned int> m_FactorMap;
|
||||
std::unordered_map<BlendFactor, unsigned int> m_factor_map;
|
||||
|
||||
public:
|
||||
glBlender();
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace Light {
|
|||
class glConstantBuffer: public ConstantBuffer
|
||||
{
|
||||
private:
|
||||
unsigned int m_BufferID;
|
||||
unsigned int m_Index;
|
||||
unsigned int m_buffer_id;
|
||||
unsigned int m_index;
|
||||
|
||||
public:
|
||||
glConstantBuffer(ConstantBufferIndex index, unsigned int size);
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
class glVertexBuffer: public VertexBuffer
|
||||
{
|
||||
private:
|
||||
unsigned int m_BufferID;
|
||||
unsigned int m_buffer_id;
|
||||
|
||||
public:
|
||||
glVertexBuffer(float *vertices, unsigned int stride, unsigned int count);
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
class glIndexBuffer: public IndexBuffer
|
||||
{
|
||||
private:
|
||||
unsigned int m_BufferID;
|
||||
unsigned int m_buffer_id;
|
||||
|
||||
public:
|
||||
glIndexBuffer(unsigned int *indices, unsigned int count);
|
||||
|
|
|
@ -8,10 +8,10 @@ namespace Light {
|
|||
class glFramebuffer: public Framebuffer
|
||||
{
|
||||
private:
|
||||
FramebufferSpecification m_Specification;
|
||||
FramebufferSpecification m_specification;
|
||||
|
||||
unsigned int m_BufferID;
|
||||
unsigned int m_ColorAttachmentID, m_DepthStencilAttachmentID;
|
||||
unsigned int m_buffer_id;
|
||||
unsigned int m_color_attachment_id, m_depth_stencil_attachment_id;
|
||||
|
||||
public:
|
||||
glFramebuffer(const FramebufferSpecification &specification);
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
inline void *GetColorAttachment() override
|
||||
{
|
||||
return (void *)m_ColorAttachmentID;
|
||||
return (void *)m_color_attachment_id;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Light {
|
|||
class glGraphicsContext: public GraphicsContext
|
||||
{
|
||||
private:
|
||||
GLFWwindow *m_WindowHandle;
|
||||
GLFWwindow *m_window_handle;
|
||||
|
||||
public:
|
||||
glGraphicsContext(GLFWwindow *windowHandle);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Light {
|
|||
class glRenderCommand: public RenderCommand
|
||||
{
|
||||
private:
|
||||
GLFWwindow *m_WindowHandle;
|
||||
GLFWwindow *m_window_handle;
|
||||
|
||||
public:
|
||||
glRenderCommand(GLFWwindow *windowHandle);
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Light {
|
|||
class glShader: public Shader
|
||||
{
|
||||
private:
|
||||
unsigned int m_ShaderID;
|
||||
unsigned int m_shader_id;
|
||||
|
||||
public:
|
||||
glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile);
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Light {
|
|||
class glTexture: public Texture
|
||||
{
|
||||
private:
|
||||
unsigned int m_TextureID;
|
||||
unsigned int m_texture_id;
|
||||
|
||||
public:
|
||||
glTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, const std::string& filePath);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Light {
|
|||
class glUserInterface: public UserInterface
|
||||
{
|
||||
private:
|
||||
GLFWwindow *m_WindowHandle;
|
||||
GLFWwindow *m_window_handle;
|
||||
|
||||
public:
|
||||
glUserInterface() = default;
|
||||
|
|
|
@ -18,7 +18,7 @@ struct glVertexElementDesc
|
|||
class glVertexLayout: public VertexLayout
|
||||
{
|
||||
private:
|
||||
unsigned int m_ArrayID;
|
||||
unsigned int m_array_id;
|
||||
|
||||
public:
|
||||
glVertexLayout(
|
||||
|
|
|
@ -13,9 +13,9 @@ class WindowResizedEvent;
|
|||
class lWindow: public Window
|
||||
{
|
||||
private:
|
||||
GLFWwindow *m_Handle;
|
||||
GLFWwindow *m_handle;
|
||||
|
||||
std::function<void(Event &)> m_EventCallback;
|
||||
std::function<void(Event &)> m_event_callback;
|
||||
|
||||
public:
|
||||
lWindow(std::function<void(Event &)> callback);
|
||||
|
|
|
@ -22,8 +22,8 @@ Scope<Window> Window::Create(std::function<void(Event &)> callback)
|
|||
}
|
||||
|
||||
wWindow::wWindow(std::function<void(Event &)> callback)
|
||||
: m_Handle(nullptr)
|
||||
, m_EventCallback(callback)
|
||||
: m_handle(nullptr)
|
||||
, m_event_callback(callback)
|
||||
{
|
||||
// init 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_VISIBLE, GLFW_FALSE);
|
||||
|
||||
m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
|
||||
ASSERT(m_Handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'");
|
||||
m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
|
||||
ASSERT(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'");
|
||||
|
||||
// bind event stuff
|
||||
glfwSetWindowUserPointer(m_Handle, &m_EventCallback);
|
||||
glfwSetWindowUserPointer(m_handle, &m_event_callback);
|
||||
BindGlfwEvents();
|
||||
|
||||
// create graphics context
|
||||
m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle);
|
||||
ASSERT(m_GraphicsContext, "wWindow::wWindow: failed to create 'GraphicsContext'");
|
||||
m_graphics_context = GraphicsContext::Create(GraphicsAPI::DirectX, m_handle);
|
||||
ASSERT(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'");
|
||||
}
|
||||
|
||||
wWindow::~wWindow()
|
||||
{
|
||||
glfwDestroyWindow(m_Handle);
|
||||
glfwDestroyWindow(m_handle);
|
||||
}
|
||||
|
||||
void wWindow::PollEvents()
|
||||
|
@ -70,16 +70,16 @@ void wWindow::OnEvent(const Event &event)
|
|||
|
||||
void wWindow::OnWindowResize(const WindowResizedEvent &event)
|
||||
{
|
||||
m_Properties.size = event.GetSize();
|
||||
m_properties.size = event.GetSize();
|
||||
}
|
||||
|
||||
void wWindow::
|
||||
SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */)
|
||||
{
|
||||
// save the visibility status and re-assign if 'overrideVisibility' is false
|
||||
bool visible = overrideVisiblity ? properties.visible : m_Properties.visible;
|
||||
m_Properties = properties;
|
||||
m_Properties.visible = visible;
|
||||
bool visible = overrideVisiblity ? properties.visible : m_properties.visible;
|
||||
m_properties = properties;
|
||||
m_properties.visible = visible;
|
||||
|
||||
// set properties
|
||||
SetTitle(properties.title);
|
||||
|
@ -90,46 +90,46 @@ void wWindow::
|
|||
|
||||
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 */)
|
||||
{
|
||||
m_Properties.size.x = size.x == 0u ? m_Properties.size.x :
|
||||
additive ? m_Properties.size.x + size.x :
|
||||
m_properties.size.x = size.x == 0u ? m_properties.size.x :
|
||||
additive ? m_properties.size.x + size.x :
|
||||
size.x;
|
||||
m_Properties.size.y = size.y == 0u ? m_Properties.size.y :
|
||||
additive ? m_Properties.size.y + size.y :
|
||||
m_properties.size.y = size.y == 0u ? m_properties.size.y :
|
||||
additive ? m_properties.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 */)
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_Properties.visible = toggle ? !m_Properties.visible : visible;
|
||||
m_properties.visible = toggle ? !m_properties.visible : visible;
|
||||
|
||||
if (m_Properties.visible)
|
||||
glfwShowWindow(m_Handle);
|
||||
if (m_properties.visible)
|
||||
glfwShowWindow(m_handle);
|
||||
else
|
||||
glfwHideWindow(m_Handle);
|
||||
glfwHideWindow(m_handle);
|
||||
}
|
||||
|
||||
void wWindow::BindGlfwEvents()
|
||||
{
|
||||
//============================== MOUSE_EVENTS ==============================//
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -138,7 +138,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -155,7 +155,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -167,7 +167,7 @@ void wWindow::BindGlfwEvents()
|
|||
//============================== KEYBOARD_EVENTS ==============================//
|
||||
/* key */
|
||||
glfwSetKeyCallback(
|
||||
m_Handle,
|
||||
m_handle,
|
||||
[](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
@ -185,7 +185,7 @@ void wWindow::BindGlfwEvents()
|
|||
}
|
||||
);
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -197,7 +197,7 @@ void wWindow::BindGlfwEvents()
|
|||
|
||||
//============================== WINDOW_EVENTS ==============================//
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowMovedEvent event(xpos, ypos);
|
||||
|
@ -206,7 +206,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowResizedEvent event(width, height);
|
||||
|
@ -215,7 +215,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* window close */
|
||||
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow *window) {
|
||||
glfwSetWindowCloseCallback(m_handle, [](GLFWwindow *window) {
|
||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowClosedEvent event;
|
||||
|
@ -224,7 +224,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ class WindowResizedEvent;
|
|||
class wWindow: public Window
|
||||
{
|
||||
private:
|
||||
GLFWwindow *m_Handle;
|
||||
GLFWwindow *m_handle;
|
||||
|
||||
std::function<void(Event &)> m_EventCallback;
|
||||
std::function<void(Event &)> m_event_callback;
|
||||
|
||||
public:
|
||||
wWindow(std::function<void(Event &)> callback);
|
||||
|
|
|
@ -10,8 +10,8 @@ class NativeScript
|
|||
friend class Scene;
|
||||
|
||||
private:
|
||||
Entity m_Entity;
|
||||
unsigned int m_UniqueIdentifier = 0; // :#todo
|
||||
Entity m_entity;
|
||||
unsigned int m_unique_identifier = 0; // :#todo
|
||||
|
||||
public:
|
||||
NativeScript() = default;
|
||||
|
@ -19,13 +19,13 @@ public:
|
|||
|
||||
inline unsigned int GetUID() const
|
||||
{
|
||||
return m_UniqueIdentifier;
|
||||
return m_unique_identifier;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &GetComponent()
|
||||
{
|
||||
return m_Entity.GetComponent<T>();
|
||||
return m_entity.GetComponent<T>();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -10,8 +10,8 @@ namespace Light {
|
|||
class Entity
|
||||
{
|
||||
private:
|
||||
entt::entity m_Handle;
|
||||
Scene *m_Scene;
|
||||
entt::entity m_handle;
|
||||
Scene *m_scene;
|
||||
|
||||
public:
|
||||
Entity(entt::entity handle = entt::null, Scene *registry = nullptr);
|
||||
|
@ -20,25 +20,25 @@ public:
|
|||
template<typename T, typename... Args>
|
||||
inline T &AddComponent(Args &&...args)
|
||||
{
|
||||
return m_Scene->m_Registry.emplace<T>(m_Handle, std::forward<Args>(args)...);
|
||||
return m_scene->m_registry.emplace<T>(m_handle, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T &GetComponent()
|
||||
{
|
||||
return m_Scene->m_Registry.get<T>(m_Handle);
|
||||
return m_scene->m_registry.get<T>(m_handle);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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>
|
||||
inline void RemoveComponent()
|
||||
{
|
||||
m_Scene->m_Registry.remove<T>(m_Handle);
|
||||
m_scene->m_registry.remove<T>(m_handle);
|
||||
}
|
||||
|
||||
inline uint64_t GetUUID()
|
||||
|
@ -48,12 +48,12 @@ public:
|
|||
|
||||
inline bool IsValid() const
|
||||
{
|
||||
return m_Handle != entt::null && m_Scene != nullptr;
|
||||
return m_handle != entt::null && m_scene != nullptr;
|
||||
}
|
||||
|
||||
operator uint32_t()
|
||||
{
|
||||
return (uint32_t)m_Handle;
|
||||
return (uint32_t)m_handle;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ private:
|
|||
friend class SceneHierarchyPanel;
|
||||
|
||||
private:
|
||||
entt::registry m_Registry;
|
||||
entt::registry m_registry;
|
||||
|
||||
public:
|
||||
Scene();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Light {
|
|||
class Timer
|
||||
{
|
||||
private:
|
||||
std::chrono::time_point<std::chrono::steady_clock> m_Start;
|
||||
std::chrono::time_point<std::chrono::steady_clock> m_start;
|
||||
|
||||
public:
|
||||
Timer();
|
||||
|
@ -16,7 +16,7 @@ public:
|
|||
inline float GetElapsedTime() const
|
||||
{
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - m_Start
|
||||
std::chrono::steady_clock::now() - m_start
|
||||
)
|
||||
.count())
|
||||
/ 1000.;
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
inline void Reset()
|
||||
{
|
||||
m_Start = std::chrono::steady_clock::now();
|
||||
m_start = std::chrono::steady_clock::now();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -33,8 +33,8 @@ class DeltaTimer
|
|||
private:
|
||||
Timer timer;
|
||||
|
||||
float m_PreviousFrame;
|
||||
float m_DeltaTime;
|
||||
float m_previous_frame;
|
||||
float m_delta_time;
|
||||
|
||||
public:
|
||||
DeltaTimer();
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
inline float GetDeltaTime() const
|
||||
{
|
||||
return m_DeltaTime;
|
||||
return m_delta_time;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ private:
|
|||
static UserInterface *s_Context;
|
||||
|
||||
private:
|
||||
ImGuiWindowFlags m_DockspaceFlags;
|
||||
ImGuiWindowFlags m_dockspace_flags;
|
||||
|
||||
public:
|
||||
static Scope<UserInterface> Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext);
|
||||
|
|
|
@ -20,34 +20,34 @@ public:
|
|||
// getters
|
||||
inline uint8_t *GetData()
|
||||
{
|
||||
return m_Data;
|
||||
return m_data;
|
||||
}
|
||||
inline uint32_t GetSize()
|
||||
{
|
||||
return m_Size;
|
||||
return m_size;
|
||||
}
|
||||
|
||||
inline const std::string &GetPath()
|
||||
{
|
||||
return m_Path;
|
||||
return m_path;
|
||||
}
|
||||
inline const std::string &GetName()
|
||||
{
|
||||
return m_Name;
|
||||
return m_name;
|
||||
}
|
||||
inline const std::string &GetExtension()
|
||||
{
|
||||
return m_Extension;
|
||||
return m_extension;
|
||||
}
|
||||
|
||||
inline const std::string &GetNameWithExtension()
|
||||
{
|
||||
return m_Name + '.' + m_Extension;
|
||||
return m_name + '.' + m_extension;
|
||||
}
|
||||
|
||||
inline bool IsValid() const
|
||||
{
|
||||
return !!m_Data;
|
||||
return !!m_data;
|
||||
}
|
||||
|
||||
// operators
|
||||
|
@ -58,11 +58,11 @@ public:
|
|||
|
||||
protected:
|
||||
// made protected for custom Free():
|
||||
uint8_t *m_Data;
|
||||
uint32_t m_Size;
|
||||
uint8_t *m_data;
|
||||
uint32_t m_size;
|
||||
|
||||
private:
|
||||
const std::string m_Path, m_Name, m_Extension;
|
||||
const std::string m_path, m_name, m_extension;
|
||||
};
|
||||
|
||||
class ImageFileHandle: public BasicFileHandle
|
||||
|
@ -80,10 +80,10 @@ public:
|
|||
uint32_t desiredComponents
|
||||
)
|
||||
: BasicFileHandle(data, size, path, name, extension)
|
||||
, m_Width(width)
|
||||
, m_Height(height)
|
||||
, m_Components(components)
|
||||
, m_DesiredComponents(desiredComponents)
|
||||
, m_width(width)
|
||||
, m_height(height)
|
||||
, m_components(components)
|
||||
, m_desired_components(desiredComponents)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -92,23 +92,23 @@ public:
|
|||
// getters
|
||||
inline uint32_t GetWidth() const
|
||||
{
|
||||
return m_Width;
|
||||
return m_width;
|
||||
}
|
||||
inline uint32_t GetHeight() const
|
||||
{
|
||||
return m_Height;
|
||||
return m_height;
|
||||
}
|
||||
inline uint32_t GetComponents() const
|
||||
{
|
||||
return m_Components;
|
||||
return m_components;
|
||||
}
|
||||
inline uint32_t GetDesiredComponents() const
|
||||
{
|
||||
return m_DesiredComponents;
|
||||
return m_desired_components;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t m_Width, m_Height, m_Components, m_DesiredComponents;
|
||||
uint32_t m_width, m_height, m_components, m_desired_components;
|
||||
};
|
||||
|
||||
class FileManager
|
||||
|
|
|
@ -15,8 +15,8 @@ private:
|
|||
static ResourceManager *s_Context;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, Ref<Shader>> m_Shaders;
|
||||
std::unordered_map<std::string, Ref<Texture>> m_Textures;
|
||||
std::unordered_map<std::string, Ref<Shader>> m_shaders;
|
||||
std::unordered_map<std::string, Ref<Texture>> m_textures;
|
||||
|
||||
public:
|
||||
static Scope<ResourceManager> Create();
|
||||
|
@ -47,11 +47,11 @@ public:
|
|||
|
||||
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)
|
||||
{
|
||||
return s_Context->m_Textures[name];
|
||||
return s_Context->m_textures[name];
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,7 +22,7 @@ private:
|
|||
void SerializeEntity(YAML::Emitter &out, Entity entity);
|
||||
|
||||
private:
|
||||
Ref<Scene> m_Scene;
|
||||
Ref<Scene> m_scene;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -10,26 +10,26 @@ OrthographicCamera::OrthographicCamera(
|
|||
float zoomLevel,
|
||||
const glm::vec4 &clearColor /* = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f) */
|
||||
)
|
||||
: m_Up(0.0f, 1.0f, 0.0f)
|
||||
, m_Position(position)
|
||||
, m_AspectRatio(aspectRatio)
|
||||
, m_ZoomLevel(zoomLevel)
|
||||
, m_ClearColor(clearColor)
|
||||
: m_up(0.0f, 1.0f, 0.0f)
|
||||
, m_position(position)
|
||||
, m_aspect_ratio(aspectRatio)
|
||||
, m_zoom_level(zoomLevel)
|
||||
, m_clear_color(clearColor)
|
||||
{
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
m_Projection = glm::ortho(
|
||||
-m_ZoomLevel * m_AspectRatio,
|
||||
+m_ZoomLevel * m_AspectRatio,
|
||||
-m_ZoomLevel,
|
||||
+m_ZoomLevel,
|
||||
m_projection = glm::ortho(
|
||||
-m_zoom_level * m_aspect_ratio,
|
||||
+m_zoom_level * m_aspect_ratio,
|
||||
-m_zoom_level,
|
||||
+m_zoom_level,
|
||||
FLT_MAX,
|
||||
FLT_MIN
|
||||
);
|
||||
|
@ -37,13 +37,13 @@ void OrthographicCamera::CalculateProjection()
|
|||
|
||||
void OrthographicCamera::OnResize(const glm::vec2 &size)
|
||||
{
|
||||
m_AspectRatio = size.x / size.y;
|
||||
m_aspect_ratio = size.x / size.y;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void OrthographicCamera::Move(const glm::vec2 &position)
|
||||
{
|
||||
m_Position += position;
|
||||
m_position += position;
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -4,82 +4,82 @@
|
|||
namespace Light {
|
||||
|
||||
SceneCamera::SceneCamera()
|
||||
: m_OrthographicSpecification { 1000.0f, -1.0f, 10000.0f }
|
||||
, m_PerspectiveSpecification { glm::radians(45.0f), 0.01f, 10000.0f }
|
||||
, m_AspectRatio(16.0f / 9.0f)
|
||||
, m_ProjectionType(ProjectionType::Orthographic)
|
||||
: m_orthographic_specification { 1000.0f, -1.0f, 10000.0f }
|
||||
, m_perspective_specification { glm::radians(45.0f), 0.01f, 10000.0f }
|
||||
, m_aspect_ratio(16.0f / 9.0f)
|
||||
, m_projection_type(ProjectionType::Orthographic)
|
||||
{
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetViewportSize(unsigned int width, unsigned int height)
|
||||
{
|
||||
m_AspectRatio = width / (float)height;
|
||||
m_aspect_ratio = width / (float)height;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetProjectionType(ProjectionType projectionType)
|
||||
{
|
||||
m_ProjectionType = projectionType;
|
||||
m_projection_type = projectionType;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetOrthographicSize(float size)
|
||||
{
|
||||
m_OrthographicSpecification.size = size;
|
||||
m_orthographic_specification.size = size;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetOrthographicFarPlane(float farPlane)
|
||||
{
|
||||
m_OrthographicSpecification.farPlane = farPlane;
|
||||
m_orthographic_specification.farPlane = farPlane;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetOrthographicNearPlane(float nearPlane)
|
||||
{
|
||||
m_OrthographicSpecification.nearPlane = nearPlane;
|
||||
m_orthographic_specification.nearPlane = nearPlane;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetPerspectiveVerticalFOV(float verticalFOV)
|
||||
{
|
||||
m_PerspectiveSpecification.verticalFOV = verticalFOV;
|
||||
m_perspective_specification.verticalFOV = verticalFOV;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetPerspectiveFarPlane(float farPlane)
|
||||
{
|
||||
m_PerspectiveSpecification.farPlane = farPlane;
|
||||
m_perspective_specification.farPlane = farPlane;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::SetPerspectiveNearPlane(float nearPlane)
|
||||
{
|
||||
m_PerspectiveSpecification.nearPlane = nearPlane;
|
||||
m_perspective_specification.nearPlane = nearPlane;
|
||||
CalculateProjection();
|
||||
}
|
||||
|
||||
void SceneCamera::CalculateProjection()
|
||||
{
|
||||
if (m_ProjectionType == ProjectionType::Orthographic)
|
||||
if (m_projection_type == ProjectionType::Orthographic)
|
||||
{
|
||||
m_Projection = glm::ortho(
|
||||
-m_OrthographicSpecification.size * 0.5f * m_AspectRatio,
|
||||
m_OrthographicSpecification.size * 0.5f * m_AspectRatio,
|
||||
-m_OrthographicSpecification.size * 0.5f,
|
||||
m_OrthographicSpecification.size * 0.5f,
|
||||
m_OrthographicSpecification.farPlane,
|
||||
m_OrthographicSpecification.nearPlane
|
||||
m_projection = glm::ortho(
|
||||
-m_orthographic_specification.size * 0.5f * m_aspect_ratio,
|
||||
m_orthographic_specification.size * 0.5f * m_aspect_ratio,
|
||||
-m_orthographic_specification.size * 0.5f,
|
||||
m_orthographic_specification.size * 0.5f,
|
||||
m_orthographic_specification.farPlane,
|
||||
m_orthographic_specification.nearPlane
|
||||
);
|
||||
}
|
||||
else // perspective
|
||||
{
|
||||
m_Projection = glm::perspective(
|
||||
m_PerspectiveSpecification.verticalFOV,
|
||||
m_AspectRatio,
|
||||
m_PerspectiveSpecification.nearPlane,
|
||||
m_PerspectiveSpecification.farPlane
|
||||
m_projection = glm::perspective(
|
||||
m_perspective_specification.verticalFOV,
|
||||
m_aspect_ratio,
|
||||
m_perspective_specification.nearPlane,
|
||||
m_perspective_specification.farPlane
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,101 +14,101 @@ namespace Light {
|
|||
Application *Application::s_Context = nullptr;
|
||||
|
||||
Application::Application()
|
||||
: m_Instrumentor(nullptr)
|
||||
, m_LayerStack(nullptr)
|
||||
, m_Input(nullptr)
|
||||
, m_Window(nullptr)
|
||||
: m_instrumentor(nullptr)
|
||||
, m_layer_stack(nullptr)
|
||||
, m_input(nullptr)
|
||||
, m_window(nullptr)
|
||||
{
|
||||
ASSERT(!s_Context, "Repeated singleton construction");
|
||||
s_Context = this;
|
||||
|
||||
m_Logger = Logger::Create();
|
||||
m_logger = Logger::Create();
|
||||
LogDebugData();
|
||||
|
||||
m_Instrumentor = Instrumentor::Create();
|
||||
m_Instrumentor->BeginSession("Logs/ProfileResults_Startup.json");
|
||||
m_instrumentor = Instrumentor::Create();
|
||||
m_instrumentor->BeginSession("Logs/ProfileResults_Startup.json");
|
||||
|
||||
m_LayerStack = LayerStack::Create();
|
||||
m_Input = Input::Create();
|
||||
m_layer_stack = LayerStack::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()
|
||||
{
|
||||
LOG(trace, "Application::~Application()");
|
||||
m_Instrumentor->EndSession(); // ProfileResults_Termination //
|
||||
m_instrumentor->EndSession(); // ProfileResults_Termination //
|
||||
}
|
||||
|
||||
void Application::GameLoop()
|
||||
{
|
||||
// check
|
||||
ASSERT(!m_LayerStack->IsEmpty(), "LayerStack is empty");
|
||||
ASSERT(!m_layer_stack->IsEmpty(), "LayerStack is empty");
|
||||
|
||||
// log debug data
|
||||
m_Logger->LogDebugData();
|
||||
m_Window->GetGfxContext()->LogDebugData();
|
||||
m_Window->GetGfxContext()->GetUserInterface()->LogDebugData();
|
||||
m_logger->LogDebugData();
|
||||
m_window->GetGfxContext()->LogDebugData();
|
||||
m_window->GetGfxContext()->GetUserInterface()->LogDebugData();
|
||||
|
||||
// reveal window
|
||||
m_Window->SetVisibility(true);
|
||||
m_window->SetVisibility(true);
|
||||
|
||||
m_Instrumentor->EndSession(); // ProfileResults_GameLoop //
|
||||
m_Instrumentor->BeginSession("Logs/ProfileResults_GameLoop.json");
|
||||
m_instrumentor->EndSession(); // ProfileResults_GameLoop //
|
||||
m_instrumentor->BeginSession("Logs/ProfileResults_GameLoop.json");
|
||||
|
||||
/* game loop */
|
||||
DeltaTimer deltaTimer;
|
||||
while (!m_Window->IsClosed())
|
||||
while (!m_window->IsClosed())
|
||||
{
|
||||
{
|
||||
// update layers
|
||||
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());
|
||||
}
|
||||
|
||||
{
|
||||
// render layers
|
||||
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();
|
||||
|
||||
m_Window->GetGfxContext()->GetRenderer()->EndFrame();
|
||||
m_window->GetGfxContext()->GetRenderer()->EndFrame();
|
||||
}
|
||||
|
||||
{
|
||||
// render user interface
|
||||
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();
|
||||
|
||||
m_Window->GetGfxContext()->GetUserInterface()->End();
|
||||
m_window->GetGfxContext()->GetUserInterface()->End();
|
||||
}
|
||||
|
||||
{
|
||||
// poll events
|
||||
LT_PROFILE_SCOPE("GameLoop::Events");
|
||||
m_Window->PollEvents();
|
||||
m_window->PollEvents();
|
||||
}
|
||||
|
||||
/// update delta time
|
||||
deltaTimer.Update();
|
||||
}
|
||||
|
||||
m_Instrumentor->EndSession(); // ProfileResults_GameLoop //
|
||||
m_Instrumentor->BeginSession("Logs/ProfileResults_Termination.json");
|
||||
m_instrumentor->EndSession(); // ProfileResults_GameLoop //
|
||||
m_instrumentor->BeginSession("Logs/ProfileResults_Termination.json");
|
||||
}
|
||||
|
||||
void Application::Quit()
|
||||
{
|
||||
s_Context->m_Window->Close();
|
||||
s_Context->m_window->Close();
|
||||
}
|
||||
|
||||
void Application::OnEvent(const Event &event)
|
||||
|
@ -116,10 +116,10 @@ void Application::OnEvent(const Event &event)
|
|||
// window
|
||||
if (event.HasCategory(WindowEventCategory))
|
||||
{
|
||||
m_Window->OnEvent(event);
|
||||
m_window->OnEvent(event);
|
||||
|
||||
if (event.GetEventType() == EventType::WindowResized)
|
||||
m_Window->GetGfxContext()->GetRenderer()->OnWindowResize(
|
||||
m_window->GetGfxContext()->GetRenderer()->OnWindowResize(
|
||||
(const WindowResizedEvent &)event
|
||||
);
|
||||
}
|
||||
|
@ -127,15 +127,15 @@ void Application::OnEvent(const Event &event)
|
|||
// input
|
||||
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
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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))
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Light {
|
|||
std::mt19937_64 UUID::s_Engine = std::mt19937_64(std::random_device()());
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Scope<Instrumentor> Instrumentor::Create()
|
|||
return MakeScope<Instrumentor>(new Instrumentor);
|
||||
}
|
||||
|
||||
Instrumentor::Instrumentor(): m_CurrentSessionCount(0u)
|
||||
Instrumentor::Instrumentor(): m_current_session_count(0u)
|
||||
{
|
||||
// #todo: maintenance
|
||||
ASSERT(
|
||||
|
@ -23,42 +23,42 @@ void Instrumentor::BeginSessionImpl(const std::string &outputPath)
|
|||
{
|
||||
std::filesystem::create_directory(outputPath.substr(0, outputPath.find_last_of('/') + 1));
|
||||
|
||||
m_OutputFileStream.open(outputPath);
|
||||
m_OutputFileStream << "{\"traceEvents\":[";
|
||||
m_output_file_stream.open(outputPath);
|
||||
m_output_file_stream << "{\"traceEvents\":[";
|
||||
}
|
||||
|
||||
void Instrumentor::EndSessionImpl()
|
||||
{
|
||||
if (m_CurrentSessionCount == 0u)
|
||||
if (m_current_session_count == 0u)
|
||||
LOG(warn, "0 profiling for the ended session");
|
||||
|
||||
m_CurrentSessionCount = 0u;
|
||||
m_current_session_count = 0u;
|
||||
|
||||
m_OutputFileStream << "]}";
|
||||
m_OutputFileStream.flush();
|
||||
m_OutputFileStream.close();
|
||||
m_output_file_stream << "]}";
|
||||
m_output_file_stream.flush();
|
||||
m_output_file_stream.close();
|
||||
}
|
||||
|
||||
void Instrumentor::SubmitScopeProfileImpl(const ScopeProfileResult &profileResult)
|
||||
{
|
||||
if (m_CurrentSessionCount++ == 0u)
|
||||
m_OutputFileStream << "{";
|
||||
if (m_current_session_count++ == 0u)
|
||||
m_output_file_stream << "{";
|
||||
else
|
||||
m_OutputFileStream << ",{";
|
||||
m_output_file_stream << ",{";
|
||||
|
||||
m_OutputFileStream << "\"name\":\"" << profileResult.name << "\",";
|
||||
m_OutputFileStream << "\"cat\": \"scope\",";
|
||||
m_OutputFileStream << "\"ph\": \"X\",";
|
||||
m_OutputFileStream << "\"ts\":" << profileResult.start << ",";
|
||||
m_OutputFileStream << "\"dur\":" << profileResult.duration << ",";
|
||||
m_OutputFileStream << "\"pid\":0,";
|
||||
m_OutputFileStream << "\"tid\":" << profileResult.threadID << "";
|
||||
m_OutputFileStream << "}";
|
||||
m_output_file_stream << "\"name\":\"" << profileResult.name << "\",";
|
||||
m_output_file_stream << "\"cat\": \"scope\",";
|
||||
m_output_file_stream << "\"ph\": \"X\",";
|
||||
m_output_file_stream << "\"ts\":" << profileResult.start << ",";
|
||||
m_output_file_stream << "\"dur\":" << profileResult.duration << ",";
|
||||
m_output_file_stream << "\"pid\":0,";
|
||||
m_output_file_stream << "\"tid\":" << profileResult.threadID << "";
|
||||
m_output_file_stream << "}";
|
||||
}
|
||||
|
||||
InstrumentorTimer::InstrumentorTimer(const std::string &scopeName)
|
||||
: m_Result({ scopeName, 0, 0, 0 })
|
||||
, m_Start(std::chrono::steady_clock::now())
|
||||
: m_result({ scopeName, 0, 0, 0 })
|
||||
, m_start(std::chrono::steady_clock::now())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -66,15 +66,15 @@ InstrumentorTimer::~InstrumentorTimer()
|
|||
{
|
||||
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()
|
||||
.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()
|
||||
.count()
|
||||
- m_Result.start;
|
||||
- m_result.start;
|
||||
|
||||
Instrumentor::SubmitScopeProfile(m_Result);
|
||||
Instrumentor::SubmitScopeProfile(m_result);
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -12,9 +12,9 @@ Scope<Logger> Logger::Create()
|
|||
}
|
||||
|
||||
Logger::Logger()
|
||||
: m_EngineLogger(nullptr)
|
||||
, m_FileLogger(nullptr)
|
||||
, m_LogFilePath(LT_LOG_FILE_LOCATION)
|
||||
: m_engine_logger(nullptr)
|
||||
, m_file_logger(nullptr)
|
||||
, m_log_file_path(LT_LOG_FILE_LOCATION)
|
||||
{
|
||||
ASSERT(!s_Context, "An instance of 'Logger' already exists, do not construct this class!");
|
||||
s_Context = this;
|
||||
|
@ -24,16 +24,16 @@ Logger::Logger()
|
|||
spdlog::set_pattern("%^[%H:%M:%S]%g@%! ==> %v%$");
|
||||
#ifndef LIGHT_DIST
|
||||
spdlog::set_pattern("%^[%H:%M:%S]%! ==> %v%$");
|
||||
m_EngineLogger = spdlog::stdout_color_mt("Engine");
|
||||
m_engine_logger = spdlog::stdout_color_mt("Engine");
|
||||
#endif
|
||||
|
||||
m_FileLogger = spdlog::basic_logger_mt("File", m_LogFilePath);
|
||||
m_FileLogger->set_pattern("%^[%M:%S:%e] <%l>: %v%$");
|
||||
m_file_logger = spdlog::basic_logger_mt("File", m_log_file_path);
|
||||
m_file_logger->set_pattern("%^[%M:%S:%e] <%l>: %v%$");
|
||||
|
||||
// set level
|
||||
#if defined(LIGHT_DEBUG)
|
||||
m_EngineLogger->set_level(spdlog::level::trace);
|
||||
m_ClientLogger->set_level(spdlog::level::trace);
|
||||
m_engine_logger->set_level(spdlog::level::trace);
|
||||
m_client_logger->set_level(spdlog::level::trace);
|
||||
#elif defined(LIGHT_RELEASE)
|
||||
s_EngineLogger->set_level(spdlog::level::info);
|
||||
s_ClientLogger->set_level(spdlog::level::info);
|
||||
|
@ -45,8 +45,8 @@ void Logger::LogDebugData()
|
|||
// #todo: improve
|
||||
LOG(info, "________________________________________");
|
||||
LOG(info, "Logger::");
|
||||
LOG(info, " EngineLevel : {}", Stringifier::spdlogLevel(m_EngineLogger->level()));
|
||||
LOG(info, " FileLevel : {}", Stringifier::spdlogLevel(m_FileLogger->level()));
|
||||
LOG(info, " EngineLevel : {}", Stringifier::spdlogLevel(m_engine_logger->level()));
|
||||
LOG(info, " FileLevel : {}", Stringifier::spdlogLevel(m_file_logger->level()));
|
||||
LOG(info, " DefaultLevel: {}", Stringifier::spdlogLevel(spdlog::get_level()));
|
||||
LOG(info, "________________________________________");
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow *wind
|
|||
// terminate 'GraphicsContext' dependent classes
|
||||
if (s_Context)
|
||||
{
|
||||
s_Context->m_Renderer.reset();
|
||||
s_Context->m_UserInterface.reset();
|
||||
s_Context->m_renderer.reset();
|
||||
s_Context->m_user_interface.reset();
|
||||
|
||||
delete s_Context;
|
||||
}
|
||||
|
@ -68,12 +68,12 @@ Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow *wind
|
|||
}
|
||||
|
||||
// create 'GraphicsContext' dependent classes
|
||||
s_Context->m_UserInterface = UserInterface::Create(windowHandle, s_Context->m_SharedContext);
|
||||
s_Context->m_Renderer = Renderer::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_shared_context);
|
||||
|
||||
// check
|
||||
ASSERT(s_Context->m_UserInterface, "Failed to create UserInterface");
|
||||
ASSERT(s_Context->m_Renderer, "Failed to create Renderer");
|
||||
ASSERT(s_Context->m_user_interface, "Failed to create UserInterface");
|
||||
ASSERT(s_Context->m_renderer, "Failed to create Renderer");
|
||||
|
||||
return std::move(scopeGfx);
|
||||
}
|
||||
|
|
|
@ -15,28 +15,28 @@ namespace Light {
|
|||
Renderer *Renderer::s_Context = nullptr;
|
||||
|
||||
Renderer::Renderer(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||
: m_QuadRenderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext)
|
||||
, m_TextureRenderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext)
|
||||
, m_TintedTextureRenderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext)
|
||||
, m_ViewProjectionBuffer(nullptr)
|
||||
, m_RenderCommand(nullptr)
|
||||
, m_Blender(nullptr)
|
||||
, m_DefaultFramebufferCamera(nullptr)
|
||||
, m_TargetFramebuffer(nullptr)
|
||||
, m_ShouldClearBackbuffer(false)
|
||||
: m_quad_renderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext)
|
||||
, m_texture_renderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext)
|
||||
, m_tinted_texture_renderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext)
|
||||
, m_view_projection_buffer(nullptr)
|
||||
, m_render_command(nullptr)
|
||||
, m_blender(nullptr)
|
||||
, m_default_framebuffer_camera(nullptr)
|
||||
, m_target_framebuffer(nullptr)
|
||||
, m_should_clear_backbuffer(false)
|
||||
{
|
||||
ASSERT(!s_Context, "An instance of 'Renderer' already exists, do not construct this class!");
|
||||
s_Context = this;
|
||||
|
||||
m_ViewProjectionBuffer = ConstantBuffer::Create(
|
||||
m_view_projection_buffer = ConstantBuffer::Create(
|
||||
ConstantBufferIndex::ViewProjection,
|
||||
sizeof(glm::mat4),
|
||||
sharedContext
|
||||
);
|
||||
|
||||
m_RenderCommand = RenderCommand::Create(windowHandle, sharedContext);
|
||||
m_Blender = Blender::Create(sharedContext);
|
||||
m_Blender->Enable(BlendFactor::SRC_ALPHA, BlendFactor::INVERSE_SRC_ALPHA);
|
||||
m_render_command = RenderCommand::Create(windowHandle, sharedContext);
|
||||
m_blender = Blender::Create(sharedContext);
|
||||
m_blender->Enable(BlendFactor::SRC_ALPHA, BlendFactor::INVERSE_SRC_ALPHA);
|
||||
}
|
||||
|
||||
Scope<Renderer> Renderer::Create(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext)
|
||||
|
@ -46,7 +46,7 @@ Scope<Renderer> Renderer::Create(GLFWwindow *windowHandle, Ref<SharedContext> sh
|
|||
|
||||
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 ========================================//
|
||||
|
@ -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)
|
||||
{
|
||||
// locals
|
||||
QuadRendererProgram::QuadVertexData *bufferMap = m_QuadRenderer.GetMapCurrent();
|
||||
QuadRendererProgram::QuadVertexData *bufferMap = m_quad_renderer.GetMapCurrent();
|
||||
|
||||
// top left
|
||||
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;
|
||||
|
||||
// advance
|
||||
if (!m_QuadRenderer.Advance())
|
||||
if (!m_quad_renderer.Advance())
|
||||
{
|
||||
LOG(warn, "Exceeded LT_MAX_QUAD_RENDERER_VERTICES: {}", LT_MAX_QUAD_RENDERER_VERTICES);
|
||||
FlushScene();
|
||||
|
@ -126,7 +126,7 @@ void Renderer::DrawQuadImpl(const glm::mat4 &transform, Ref<Texture> texture)
|
|||
texture->Bind();
|
||||
|
||||
// locals
|
||||
TextureRendererProgram::TextureVertexData *bufferMap = m_TextureRenderer.GetMapCurrent();
|
||||
TextureRendererProgram::TextureVertexData *bufferMap = m_texture_renderer.GetMapCurrent();
|
||||
|
||||
// top left
|
||||
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 };
|
||||
|
||||
// advance
|
||||
if (!m_TextureRenderer.Advance())
|
||||
if (!m_texture_renderer.Advance())
|
||||
{
|
||||
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();
|
||||
|
||||
// locals
|
||||
TintedTextureRendererProgram::TintedTextureVertexData *bufferMap = m_TintedTextureRenderer
|
||||
TintedTextureRendererProgram::TintedTextureVertexData *bufferMap = m_tinted_texture_renderer
|
||||
.GetMapCurrent();
|
||||
|
||||
// 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 };
|
||||
|
||||
// advance
|
||||
if (!m_TintedTextureRenderer.Advance())
|
||||
if (!m_tinted_texture_renderer.Advance())
|
||||
{
|
||||
LOG(warn, "Exceeded LT_MAX_TEXTURE_RENDERER_VERTICES: {}", LT_MAX_TEXTURE_RENDERER_VERTICES
|
||||
);
|
||||
|
@ -200,13 +200,13 @@ void Renderer::BeginFrame()
|
|||
|
||||
void Renderer::EndFrame()
|
||||
{
|
||||
m_RenderCommand->SwapBuffers();
|
||||
m_RenderCommand->ClearBackBuffer(
|
||||
m_DefaultFramebufferCamera ? m_DefaultFramebufferCamera->GetBackgroundColor() :
|
||||
m_render_command->SwapBuffers();
|
||||
m_render_command->ClearBackBuffer(
|
||||
m_default_framebuffer_camera ? m_default_framebuffer_camera->GetBackgroundColor() :
|
||||
glm::vec4(0.0f)
|
||||
);
|
||||
|
||||
m_DefaultFramebufferCamera = nullptr;
|
||||
m_default_framebuffer_camera = nullptr;
|
||||
}
|
||||
|
||||
void Renderer::BeginSceneImpl(
|
||||
|
@ -216,89 +216,89 @@ void Renderer::BeginSceneImpl(
|
|||
)
|
||||
{
|
||||
// determine the target frame buffer
|
||||
m_TargetFramebuffer = targetFrameBuffer;
|
||||
m_target_framebuffer = targetFrameBuffer;
|
||||
|
||||
if (targetFrameBuffer)
|
||||
targetFrameBuffer->BindAsTarget(camera->GetBackgroundColor());
|
||||
else
|
||||
{
|
||||
m_DefaultFramebufferCamera = camera;
|
||||
m_RenderCommand->DefaultTargetFramebuffer();
|
||||
m_default_framebuffer_camera = camera;
|
||||
m_render_command->DefaultTargetFramebuffer();
|
||||
}
|
||||
|
||||
// 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);
|
||||
m_ViewProjectionBuffer->UnMap();
|
||||
m_view_projection_buffer->UnMap();
|
||||
|
||||
// map renderers
|
||||
m_QuadRenderer.Map();
|
||||
m_TextureRenderer.Map();
|
||||
m_TintedTextureRenderer.Map();
|
||||
m_quad_renderer.Map();
|
||||
m_texture_renderer.Map();
|
||||
m_tinted_texture_renderer.Map();
|
||||
}
|
||||
|
||||
void Renderer::FlushScene()
|
||||
{
|
||||
/* tinted texture renderer */
|
||||
m_TintedTextureRenderer.UnMap();
|
||||
if (m_TintedTextureRenderer.GetQuadCount())
|
||||
m_tinted_texture_renderer.UnMap();
|
||||
if (m_tinted_texture_renderer.GetQuadCount())
|
||||
{
|
||||
m_TintedTextureRenderer.Bind();
|
||||
m_RenderCommand->DrawIndexed(m_TintedTextureRenderer.GetQuadCount() * 6u);
|
||||
m_tinted_texture_renderer.Bind();
|
||||
m_render_command->DrawIndexed(m_tinted_texture_renderer.GetQuadCount() * 6u);
|
||||
}
|
||||
|
||||
/* quad renderer */
|
||||
m_QuadRenderer.UnMap();
|
||||
if (m_QuadRenderer.GetQuadCount())
|
||||
m_quad_renderer.UnMap();
|
||||
if (m_quad_renderer.GetQuadCount())
|
||||
{
|
||||
m_QuadRenderer.Bind();
|
||||
m_RenderCommand->DrawIndexed(m_QuadRenderer.GetQuadCount() * 6u);
|
||||
m_quad_renderer.Bind();
|
||||
m_render_command->DrawIndexed(m_quad_renderer.GetQuadCount() * 6u);
|
||||
}
|
||||
|
||||
/* texture renderer */
|
||||
m_TextureRenderer.UnMap();
|
||||
if (m_TextureRenderer.GetQuadCount())
|
||||
m_texture_renderer.UnMap();
|
||||
if (m_texture_renderer.GetQuadCount())
|
||||
{
|
||||
m_TextureRenderer.Bind();
|
||||
m_RenderCommand->DrawIndexed(m_TextureRenderer.GetQuadCount() * 6u);
|
||||
m_texture_renderer.Bind();
|
||||
m_render_command->DrawIndexed(m_texture_renderer.GetQuadCount() * 6u);
|
||||
}
|
||||
|
||||
m_QuadRenderer.Map();
|
||||
m_TextureRenderer.Map();
|
||||
m_TintedTextureRenderer.Map();
|
||||
m_quad_renderer.Map();
|
||||
m_texture_renderer.Map();
|
||||
m_tinted_texture_renderer.Map();
|
||||
}
|
||||
|
||||
void Renderer::EndSceneImpl()
|
||||
{
|
||||
/* tinted texture renderer */
|
||||
m_TintedTextureRenderer.UnMap();
|
||||
if (m_TintedTextureRenderer.GetQuadCount())
|
||||
m_tinted_texture_renderer.UnMap();
|
||||
if (m_tinted_texture_renderer.GetQuadCount())
|
||||
{
|
||||
m_TintedTextureRenderer.Bind();
|
||||
m_RenderCommand->DrawIndexed(m_TintedTextureRenderer.GetQuadCount() * 6u);
|
||||
m_tinted_texture_renderer.Bind();
|
||||
m_render_command->DrawIndexed(m_tinted_texture_renderer.GetQuadCount() * 6u);
|
||||
}
|
||||
|
||||
/* quad renderer */
|
||||
m_QuadRenderer.UnMap();
|
||||
if (m_QuadRenderer.GetQuadCount())
|
||||
m_quad_renderer.UnMap();
|
||||
if (m_quad_renderer.GetQuadCount())
|
||||
{
|
||||
m_QuadRenderer.Bind();
|
||||
m_RenderCommand->DrawIndexed(m_QuadRenderer.GetQuadCount() * 6u);
|
||||
m_quad_renderer.Bind();
|
||||
m_render_command->DrawIndexed(m_quad_renderer.GetQuadCount() * 6u);
|
||||
}
|
||||
|
||||
/* texture renderer */
|
||||
m_TextureRenderer.UnMap();
|
||||
if (m_TextureRenderer.GetQuadCount())
|
||||
m_texture_renderer.UnMap();
|
||||
if (m_texture_renderer.GetQuadCount())
|
||||
{
|
||||
m_TextureRenderer.Bind();
|
||||
m_RenderCommand->DrawIndexed(m_TextureRenderer.GetQuadCount() * 6u);
|
||||
m_texture_renderer.Bind();
|
||||
m_render_command->DrawIndexed(m_texture_renderer.GetQuadCount() * 6u);
|
||||
}
|
||||
|
||||
// reset frame buffer
|
||||
if (m_TargetFramebuffer)
|
||||
if (m_target_framebuffer)
|
||||
{
|
||||
m_TargetFramebuffer = nullptr;
|
||||
m_RenderCommand->DefaultTargetFramebuffer();
|
||||
m_target_framebuffer = nullptr;
|
||||
m_render_command->DefaultTargetFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
namespace Light {
|
||||
|
||||
QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext)
|
||||
: m_Shader(nullptr)
|
||||
, m_IndexBuffer(nullptr)
|
||||
, m_VertexLayout(nullptr)
|
||||
, m_MapCurrent(nullptr)
|
||||
, m_MapEnd(nullptr)
|
||||
, m_QuadCount(0u)
|
||||
, m_MaxVertices(maxVertices)
|
||||
: m_shader(nullptr)
|
||||
, m_index_buffer(nullptr)
|
||||
, m_vertex_layout(nullptr)
|
||||
, m_map_current(nullptr)
|
||||
, m_map_end(nullptr)
|
||||
, m_quad_count(0u)
|
||||
, m_max_vertices(maxVertices)
|
||||
{
|
||||
// #todo: don't use relative path
|
||||
ResourceManager::LoadShader(
|
||||
|
@ -23,16 +23,16 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedCon
|
|||
"Assets/Shaders/Quad/Quad_PS.glsl"
|
||||
);
|
||||
|
||||
m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER");
|
||||
m_VertexBuffer = Ref<VertexBuffer>(
|
||||
m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER");
|
||||
m_vertex_buffer = Ref<VertexBuffer>(
|
||||
VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)
|
||||
);
|
||||
m_IndexBuffer = Ref<IndexBuffer>(
|
||||
m_index_buffer = Ref<IndexBuffer>(
|
||||
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
|
||||
);
|
||||
m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create(
|
||||
m_VertexBuffer,
|
||||
m_Shader,
|
||||
m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
|
||||
m_vertex_buffer,
|
||||
m_shader,
|
||||
{ { "POSITION", VertexElementType::Float4 }, { "COLOR", VertexElementType::Float4 } },
|
||||
sharedContext
|
||||
));
|
||||
|
@ -40,37 +40,37 @@ QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedCon
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
m_QuadCount++;
|
||||
m_quad_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QuadRendererProgram::Map()
|
||||
{
|
||||
m_QuadCount = 0u;
|
||||
m_quad_count = 0u;
|
||||
|
||||
m_MapCurrent = (QuadRendererProgram::QuadVertexData *)m_VertexBuffer->Map();
|
||||
m_MapEnd = m_MapCurrent + m_MaxVertices;
|
||||
m_map_current = (QuadRendererProgram::QuadVertexData *)m_vertex_buffer->Map();
|
||||
m_map_end = m_map_current + m_max_vertices;
|
||||
}
|
||||
|
||||
void QuadRendererProgram::UnMap()
|
||||
{
|
||||
m_VertexBuffer->UnMap();
|
||||
m_vertex_buffer->UnMap();
|
||||
}
|
||||
|
||||
void QuadRendererProgram::Bind()
|
||||
{
|
||||
m_Shader->Bind();
|
||||
m_VertexLayout->Bind();
|
||||
m_VertexBuffer->Bind();
|
||||
m_IndexBuffer->Bind();
|
||||
m_shader->Bind();
|
||||
m_vertex_layout->Bind();
|
||||
m_vertex_buffer->Bind();
|
||||
m_index_buffer->Bind();
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -11,13 +11,13 @@ TextureRendererProgram::TextureRendererProgram(
|
|||
unsigned int maxVertices,
|
||||
Ref<SharedContext> sharedContext
|
||||
)
|
||||
: m_Shader(nullptr)
|
||||
, m_IndexBuffer(nullptr)
|
||||
, m_VertexLayout(nullptr)
|
||||
, m_MapCurrent(nullptr)
|
||||
, m_MapEnd(nullptr)
|
||||
, m_QuadCount(0u)
|
||||
, m_MaxVertices(maxVertices)
|
||||
: m_shader(nullptr)
|
||||
, m_index_buffer(nullptr)
|
||||
, m_vertex_layout(nullptr)
|
||||
, m_map_current(nullptr)
|
||||
, m_map_end(nullptr)
|
||||
, m_quad_count(0u)
|
||||
, m_max_vertices(maxVertices)
|
||||
{
|
||||
// #todo: don't use relative path
|
||||
ResourceManager::LoadShader(
|
||||
|
@ -26,16 +26,16 @@ TextureRendererProgram::TextureRendererProgram(
|
|||
"Assets/Shaders/Texture/Texture_PS.glsl"
|
||||
);
|
||||
|
||||
m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER");
|
||||
m_VertexBuffer = Ref<VertexBuffer>(
|
||||
m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER");
|
||||
m_vertex_buffer = Ref<VertexBuffer>(
|
||||
VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)
|
||||
);
|
||||
m_IndexBuffer = Ref<IndexBuffer>(
|
||||
m_index_buffer = Ref<IndexBuffer>(
|
||||
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
|
||||
);
|
||||
m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create(
|
||||
m_VertexBuffer,
|
||||
m_Shader,
|
||||
m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
|
||||
m_vertex_buffer,
|
||||
m_shader,
|
||||
{ { "POSITION", VertexElementType::Float4 }, { "TEXCOORD", VertexElementType::Float2 } },
|
||||
sharedContext
|
||||
));
|
||||
|
@ -43,36 +43,36 @@ TextureRendererProgram::TextureRendererProgram(
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
m_MapCurrent += 4;
|
||||
m_QuadCount++;
|
||||
m_map_current += 4;
|
||||
m_quad_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextureRendererProgram::Map()
|
||||
{
|
||||
m_QuadCount = 0u;
|
||||
m_quad_count = 0u;
|
||||
|
||||
m_MapCurrent = (TextureRendererProgram::TextureVertexData *)m_VertexBuffer->Map();
|
||||
m_MapEnd = m_MapCurrent + m_MaxVertices;
|
||||
m_map_current = (TextureRendererProgram::TextureVertexData *)m_vertex_buffer->Map();
|
||||
m_map_end = m_map_current + m_max_vertices;
|
||||
}
|
||||
|
||||
void TextureRendererProgram::UnMap()
|
||||
{
|
||||
m_VertexBuffer->UnMap();
|
||||
m_vertex_buffer->UnMap();
|
||||
}
|
||||
|
||||
void TextureRendererProgram::Bind()
|
||||
{
|
||||
m_Shader->Bind();
|
||||
m_VertexLayout->Bind();
|
||||
m_VertexBuffer->Bind();
|
||||
m_IndexBuffer->Bind();
|
||||
m_shader->Bind();
|
||||
m_vertex_layout->Bind();
|
||||
m_vertex_buffer->Bind();
|
||||
m_index_buffer->Bind();
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -11,13 +11,13 @@ TintedTextureRendererProgram::TintedTextureRendererProgram(
|
|||
unsigned int maxVertices,
|
||||
Ref<SharedContext> sharedContext
|
||||
)
|
||||
: m_Shader(nullptr)
|
||||
, m_IndexBuffer(nullptr)
|
||||
, m_VertexLayout(nullptr)
|
||||
, m_MapCurrent(nullptr)
|
||||
, m_MapEnd(nullptr)
|
||||
, m_QuadCount(0u)
|
||||
, m_MaxVertices(maxVertices)
|
||||
: m_shader(nullptr)
|
||||
, m_index_buffer(nullptr)
|
||||
, m_vertex_layout(nullptr)
|
||||
, m_map_current(nullptr)
|
||||
, m_map_end(nullptr)
|
||||
, m_quad_count(0u)
|
||||
, m_max_vertices(maxVertices)
|
||||
{
|
||||
// #todo: don't use relative path
|
||||
ResourceManager::LoadShader(
|
||||
|
@ -26,16 +26,16 @@ TintedTextureRendererProgram::TintedTextureRendererProgram(
|
|||
"Assets/Shaders/TintedTexture/TintedTexture_PS.glsl"
|
||||
);
|
||||
|
||||
m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER");
|
||||
m_VertexBuffer = Ref<VertexBuffer>(
|
||||
m_shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER");
|
||||
m_vertex_buffer = Ref<VertexBuffer>(
|
||||
VertexBuffer::Create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext)
|
||||
);
|
||||
m_IndexBuffer = Ref<IndexBuffer>(
|
||||
m_index_buffer = Ref<IndexBuffer>(
|
||||
IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)
|
||||
);
|
||||
m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create(
|
||||
m_VertexBuffer,
|
||||
m_Shader,
|
||||
m_vertex_layout = Ref<VertexLayout>(VertexLayout::Create(
|
||||
m_vertex_buffer,
|
||||
m_shader,
|
||||
{ { "POSITION", VertexElementType::Float4 },
|
||||
{ "TINT", VertexElementType::Float4 },
|
||||
{ "TEXCOORD", VertexElementType::Float2 } },
|
||||
|
@ -45,37 +45,37 @@ TintedTextureRendererProgram::TintedTextureRendererProgram(
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
m_QuadCount++;
|
||||
m_quad_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TintedTextureRendererProgram::Map()
|
||||
{
|
||||
m_QuadCount = 0u;
|
||||
m_quad_count = 0u;
|
||||
|
||||
m_MapCurrent = (TintedTextureRendererProgram::TintedTextureVertexData *)m_VertexBuffer->Map();
|
||||
m_MapEnd = m_MapCurrent + m_MaxVertices;
|
||||
m_map_current = (TintedTextureRendererProgram::TintedTextureVertexData *)m_vertex_buffer->Map();
|
||||
m_map_end = m_map_current + m_max_vertices;
|
||||
}
|
||||
|
||||
void TintedTextureRendererProgram::UnMap()
|
||||
{
|
||||
m_VertexBuffer->UnMap();
|
||||
m_vertex_buffer->UnMap();
|
||||
}
|
||||
|
||||
void TintedTextureRendererProgram::Bind()
|
||||
{
|
||||
m_Shader->Bind();
|
||||
m_VertexLayout->Bind();
|
||||
m_VertexBuffer->Bind();
|
||||
m_IndexBuffer->Bind();
|
||||
m_shader->Bind();
|
||||
m_vertex_layout->Bind();
|
||||
m_vertex_buffer->Bind();
|
||||
m_index_buffer->Bind();
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ Scope<Input> Input::Create()
|
|||
}
|
||||
|
||||
Input::Input()
|
||||
: m_KeyboadKeys {}
|
||||
, m_MouseButtons {}
|
||||
, m_MousePosition {}
|
||||
, m_MouseDelta {}
|
||||
, m_MouseWheelDelta {}
|
||||
, m_UserInterfaceEvents(true)
|
||||
, m_GameEvents(true)
|
||||
: m_keyboad_keys {}
|
||||
, m_mouse_buttons {}
|
||||
, m_mouse_position {}
|
||||
, m_mouse_delta {}
|
||||
, m_mouse_wheel_delta {}
|
||||
, m_user_interface_events(true)
|
||||
, m_game_events(true)
|
||||
{
|
||||
ASSERT(
|
||||
!s_Context,
|
||||
|
@ -35,26 +35,26 @@ Input::Input()
|
|||
|
||||
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*/)
|
||||
{
|
||||
bool prev = m_GameEvents;
|
||||
m_GameEvents = toggle ? !m_UserInterfaceEvents : receive;
|
||||
bool prev = m_game_events;
|
||||
m_game_events = toggle ? !m_user_interface_events : receive;
|
||||
|
||||
if (m_GameEvents != prev)
|
||||
if (m_game_events != prev)
|
||||
RestartInputState();
|
||||
}
|
||||
|
||||
void Input::RestartInputState()
|
||||
{
|
||||
m_KeyboadKeys.fill(false);
|
||||
m_MouseButtons.fill(false);
|
||||
m_keyboad_keys.fill(false);
|
||||
m_mouse_buttons.fill(false);
|
||||
|
||||
m_MousePosition = glm::vec2(0.0f);
|
||||
m_MouseDelta = glm::vec2(0.0f);
|
||||
m_MouseWheelDelta = 0.0f;
|
||||
m_mouse_position = glm::vec2(0.0f);
|
||||
m_mouse_delta = glm::vec2(0.0f);
|
||||
m_mouse_wheel_delta = 0.0f;
|
||||
}
|
||||
|
||||
void Input::OnEvent(const Event &inputEvent)
|
||||
|
@ -67,13 +67,13 @@ void Input::OnEvent(const Event &inputEvent)
|
|||
{
|
||||
const MouseMovedEvent &event = (const MouseMovedEvent &)inputEvent;
|
||||
|
||||
if (m_GameEvents)
|
||||
if (m_game_events)
|
||||
{
|
||||
m_MouseDelta = event.GetPosition() - m_MousePosition;
|
||||
m_MousePosition = event.GetPosition();
|
||||
m_mouse_delta = event.GetPosition() - m_mouse_position;
|
||||
m_mouse_position = event.GetPosition();
|
||||
}
|
||||
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
io.MousePos = ImVec2(event.GetX(), event.GetY());
|
||||
|
||||
return;
|
||||
|
@ -82,10 +82,10 @@ void Input::OnEvent(const Event &inputEvent)
|
|||
{
|
||||
const ButtonPressedEvent &event = (const ButtonPressedEvent &)inputEvent;
|
||||
|
||||
if (m_GameEvents)
|
||||
m_MouseButtons[event.GetButton()] = true;
|
||||
if (m_game_events)
|
||||
m_mouse_buttons[event.GetButton()] = true;
|
||||
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
io.MouseDown[event.GetButton()] = true;
|
||||
|
||||
return;
|
||||
|
@ -94,10 +94,10 @@ void Input::OnEvent(const Event &inputEvent)
|
|||
{
|
||||
const ButtonReleasedEvent &event = (const ButtonReleasedEvent &)inputEvent;
|
||||
|
||||
if (m_GameEvents)
|
||||
m_MouseButtons[event.GetButton()] = false;
|
||||
if (m_game_events)
|
||||
m_mouse_buttons[event.GetButton()] = false;
|
||||
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
io.MouseDown[event.GetButton()] = false;
|
||||
|
||||
return;
|
||||
|
@ -106,10 +106,10 @@ void Input::OnEvent(const Event &inputEvent)
|
|||
{
|
||||
const WheelScrolledEvent &event = (const WheelScrolledEvent &)inputEvent;
|
||||
|
||||
if (m_GameEvents)
|
||||
m_MouseWheelDelta = event.GetOffset();
|
||||
if (m_game_events)
|
||||
m_mouse_wheel_delta = event.GetOffset();
|
||||
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
io.MouseWheel = event.GetOffset();
|
||||
|
||||
return;
|
||||
|
@ -119,10 +119,10 @@ void Input::OnEvent(const Event &inputEvent)
|
|||
{
|
||||
const KeyPressedEvent &event = (const KeyPressedEvent &)inputEvent;
|
||||
|
||||
if (m_GameEvents)
|
||||
m_KeyboadKeys[event.GetKey()] = true;
|
||||
if (m_game_events)
|
||||
m_keyboad_keys[event.GetKey()] = true;
|
||||
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
{
|
||||
io.KeysDown[event.GetKey()] = true;
|
||||
// if (event.GetKey() == Key::BackSpace)
|
||||
|
@ -135,17 +135,17 @@ void Input::OnEvent(const Event &inputEvent)
|
|||
{
|
||||
const KeyReleasedEvent &event = (const KeyReleasedEvent &)inputEvent;
|
||||
|
||||
if (m_GameEvents)
|
||||
m_KeyboadKeys[event.GetKey()] = false;
|
||||
if (m_game_events)
|
||||
m_keyboad_keys[event.GetKey()] = false;
|
||||
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
io.KeysDown[event.GetKey()] = false;
|
||||
|
||||
return;
|
||||
}
|
||||
case EventType::SetChar:
|
||||
{
|
||||
if (m_UserInterfaceEvents)
|
||||
if (m_user_interface_events)
|
||||
{
|
||||
const SetCharEvent &event = (const SetCharEvent &)inputEvent;
|
||||
io.AddInputCharacter(event.GetCharacter());
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
Layer::Layer(const std::string &name): m_LayerName(name)
|
||||
Layer::Layer(const std::string &name): m_layer_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ Scope<LayerStack> LayerStack::Create()
|
|||
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!")
|
||||
s_Context = this;
|
||||
|
@ -22,16 +22,16 @@ LayerStack::LayerStack(): m_Layers {}, m_Begin(), m_End()
|
|||
|
||||
LayerStack::~LayerStack()
|
||||
{
|
||||
for (Layer *layer : m_Layers)
|
||||
for (Layer *layer : m_layers)
|
||||
delete layer;
|
||||
}
|
||||
|
||||
void LayerStack::AttachLayerImpl(Layer *layer)
|
||||
{
|
||||
// #todo: handle attaching layer inside a for loop
|
||||
m_Layers.push_back(layer);
|
||||
m_Begin = m_Layers.begin();
|
||||
m_End = m_Layers.end();
|
||||
m_layers.push_back(layer);
|
||||
m_begin = m_layers.begin();
|
||||
m_end = m_layers.end();
|
||||
|
||||
LOG(trace, "Attached [{}]", layer->GetName());
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ void LayerStack::AttachLayerImpl(Layer *layer)
|
|||
void LayerStack::DetachLayerImpl(Layer *layer)
|
||||
{
|
||||
// #todo: handle detaching layer inside a for loop
|
||||
m_Layers.erase(std::find(m_Layers.begin(), m_Layers.end(), layer));
|
||||
m_Begin = m_Layers.begin();
|
||||
m_End = m_Layers.end();
|
||||
m_layers.erase(std::find(m_layers.begin(), m_layers.end(), layer));
|
||||
m_begin = m_layers.begin();
|
||||
m_end = m_layers.end();
|
||||
|
||||
LOG(trace, "Detached [{}]", layer->GetName());
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace Light {
|
||||
|
||||
dxBlender::dxBlender(Ref<dxSharedContext> sharedContext)
|
||||
: m_Context(sharedContext), m_FactorMap { // constants
|
||||
: m_context(sharedContext), m_factor_map { // constants
|
||||
{ BlendFactor::ZERO, D3D11_BLEND_ZERO },
|
||||
{ BlendFactor::ONE, D3D11_BLEND_ONE },
|
||||
|
||||
|
@ -29,53 +29,53 @@ dxBlender::dxBlender(Ref<dxSharedContext> sharedContext)
|
|||
{ BlendFactor::SRC1_ALPHA, D3D11_BLEND_SRC1_ALPHA },
|
||||
{ BlendFactor::INVERSE_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA }
|
||||
}
|
||||
, m_BlendState(nullptr)
|
||||
, m_Desc {}
|
||||
, m_blend_state(nullptr)
|
||||
, m_desc {}
|
||||
{
|
||||
// factor map
|
||||
// blender desc
|
||||
m_Desc = {};
|
||||
m_desc = {};
|
||||
|
||||
m_Desc.RenderTarget[0].BlendEnable = true;
|
||||
m_Desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ZERO;
|
||||
m_Desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO;
|
||||
m_Desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
||||
m_Desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
||||
m_Desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
|
||||
m_Desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
m_Desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
m_desc.RenderTarget[0].BlendEnable = true;
|
||||
m_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ZERO;
|
||||
m_desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO;
|
||||
m_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
||||
m_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
||||
m_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
|
||||
m_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
m_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
|
||||
// create blend state
|
||||
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)
|
||||
{
|
||||
// update desc
|
||||
m_Desc.RenderTarget[0].BlendEnable = true;
|
||||
m_Desc.RenderTarget[0].SrcBlend = m_FactorMap.at(srcFactor);
|
||||
m_Desc.RenderTarget[0].DestBlend = m_FactorMap.at(dstFactor);
|
||||
m_desc.RenderTarget[0].BlendEnable = true;
|
||||
m_desc.RenderTarget[0].SrcBlend = m_factor_map.at(srcFactor);
|
||||
m_desc.RenderTarget[0].DestBlend = m_factor_map.at(dstFactor);
|
||||
|
||||
// re-create blind state
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState));
|
||||
DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_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()
|
||||
{
|
||||
// update desc
|
||||
m_Desc.RenderTarget[0].BlendEnable = false;
|
||||
m_desc.RenderTarget[0].BlendEnable = false;
|
||||
|
||||
// re-create blind state
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState));
|
||||
DXC(m_context->GetDevice()->CreateBlendState(&m_desc, &m_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
|
||||
|
|
|
@ -10,10 +10,10 @@ dxConstantBuffer::dxConstantBuffer(
|
|||
unsigned int size,
|
||||
Ref<dxSharedContext> sharedContext
|
||||
)
|
||||
: m_Context(sharedContext)
|
||||
, m_Buffer(nullptr)
|
||||
, m_Map {}
|
||||
, m_Index(static_cast<int>(index))
|
||||
: m_context(sharedContext)
|
||||
, m_buffer(nullptr)
|
||||
, m_map {}
|
||||
, m_index(static_cast<int>(index))
|
||||
{
|
||||
D3D11_BUFFER_DESC bDesc = {};
|
||||
|
||||
|
@ -23,25 +23,25 @@ dxConstantBuffer::dxConstantBuffer(
|
|||
bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_Buffer));
|
||||
m_Context->GetDeviceContext()->VSSetConstantBuffers(m_Index, 1u, m_Buffer.GetAddressOf());
|
||||
DXC(m_context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_buffer));
|
||||
m_context->GetDeviceContext()->VSSetConstantBuffers(m_index, 1u, m_buffer.GetAddressOf());
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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);
|
||||
return m_Map.pData;
|
||||
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);
|
||||
return m_map.pData;
|
||||
}
|
||||
|
||||
void dxConstantBuffer::UnMap()
|
||||
{
|
||||
m_Context->GetDeviceContext()->Unmap(m_Buffer.Get(), NULL);
|
||||
m_context->GetDeviceContext()->Unmap(m_buffer.Get(), NULL);
|
||||
}
|
||||
//======================================== CONSTANT_BUFFER
|
||||
//========================================//
|
||||
|
@ -54,10 +54,10 @@ dxVertexBuffer::dxVertexBuffer(
|
|||
unsigned int count,
|
||||
Ref<dxSharedContext> sharedContext
|
||||
)
|
||||
: m_Context(sharedContext)
|
||||
, m_Buffer(nullptr)
|
||||
, m_Map {}
|
||||
, m_Stride(stride)
|
||||
: m_context(sharedContext)
|
||||
, m_buffer(nullptr)
|
||||
, m_map {}
|
||||
, m_stride(stride)
|
||||
{
|
||||
// buffer desc
|
||||
D3D11_BUFFER_DESC bDesc = {};
|
||||
|
@ -71,7 +71,7 @@ dxVertexBuffer::dxVertexBuffer(
|
|||
|
||||
// create buffer
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_Buffer));
|
||||
DXC(m_context->GetDevice()->CreateBuffer(&bDesc, nullptr, &m_buffer));
|
||||
}
|
||||
|
||||
dxVertexBuffer::~dxVertexBuffer()
|
||||
|
@ -81,20 +81,20 @@ dxVertexBuffer::~dxVertexBuffer()
|
|||
|
||||
void *dxVertexBuffer::Map()
|
||||
{
|
||||
m_Context->GetDeviceContext()->Map(m_Buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_Map);
|
||||
return m_Map.pData;
|
||||
m_context->GetDeviceContext()->Map(m_buffer.Get(), NULL, D3D11_MAP_WRITE_DISCARD, NULL, &m_map);
|
||||
return m_map.pData;
|
||||
}
|
||||
|
||||
void dxVertexBuffer::UnMap()
|
||||
{
|
||||
m_Context->GetDeviceContext()->Unmap(m_Buffer.Get(), NULL);
|
||||
m_context->GetDeviceContext()->Unmap(m_buffer.Get(), NULL);
|
||||
}
|
||||
|
||||
void dxVertexBuffer::Bind()
|
||||
{
|
||||
static const unsigned int offset = 0u;
|
||||
m_Context->GetDeviceContext()
|
||||
->IASetVertexBuffers(0u, 1u, m_Buffer.GetAddressOf(), &m_Stride, &offset);
|
||||
m_context->GetDeviceContext()
|
||||
->IASetVertexBuffers(0u, 1u, m_buffer.GetAddressOf(), &m_stride, &offset);
|
||||
}
|
||||
|
||||
void dxVertexBuffer::UnBind()
|
||||
|
@ -102,7 +102,7 @@ void dxVertexBuffer::UnBind()
|
|||
static const unsigned int offset = 0u;
|
||||
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
|
||||
//==================================================//
|
||||
|
@ -113,8 +113,8 @@ dxIndexBuffer::dxIndexBuffer(
|
|||
unsigned int count,
|
||||
Ref<dxSharedContext> sharedContext
|
||||
)
|
||||
: m_Context(sharedContext)
|
||||
, m_Buffer(nullptr)
|
||||
: m_context(sharedContext)
|
||||
, m_buffer(nullptr)
|
||||
{
|
||||
// generate indices if not provided
|
||||
bool hasIndices = !!indices;
|
||||
|
@ -159,7 +159,7 @@ dxIndexBuffer::dxIndexBuffer(
|
|||
|
||||
// create buffer
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateBuffer(&bDesc, &sDesc, &m_Buffer));
|
||||
DXC(m_context->GetDevice()->CreateBuffer(&bDesc, &sDesc, &m_buffer));
|
||||
|
||||
// delete indices
|
||||
if (!hasIndices)
|
||||
|
@ -173,7 +173,7 @@ dxIndexBuffer::~dxIndexBuffer()
|
|||
|
||||
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()
|
||||
|
@ -181,7 +181,7 @@ void dxIndexBuffer::UnBind()
|
|||
static const unsigned int offset = 0u;
|
||||
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 ========================================//
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ dxFramebuffer::dxFramebuffer(
|
|||
const FramebufferSpecification &specification,
|
||||
Ref<dxSharedContext> sharedContext
|
||||
)
|
||||
: m_Context(sharedContext)
|
||||
, m_Specification(specification)
|
||||
, m_RenderTargetView(nullptr)
|
||||
, m_ColorAttachment(nullptr)
|
||||
, m_DepthStencilAttachment(nullptr)
|
||||
, m_ShaderResourceView(nullptr)
|
||||
, m_DepthStencilView(nullptr)
|
||||
: m_context(sharedContext)
|
||||
, m_specification(specification)
|
||||
, m_render_target_view(nullptr)
|
||||
, m_color_attachment(nullptr)
|
||||
, m_depth_stencil_attachment(nullptr)
|
||||
, m_shader_resource_view(nullptr)
|
||||
, m_depth_stencil_view(nullptr)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -29,22 +29,22 @@ dxFramebuffer::dxFramebuffer(
|
|||
t2dDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
|
||||
t2dDesc.CPUAccessFlags = NULL;
|
||||
t2dDesc.MiscFlags = NULL;
|
||||
DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_ColorAttachment));
|
||||
DXC(m_context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_color_attachment));
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Format = t2dDesc.Format;
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = 1;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
DXC(m_Context->GetDevice()
|
||||
->CreateShaderResourceView(m_ColorAttachment.Get(), &srvDesc, &m_ShaderResourceView));
|
||||
DXC(m_context->GetDevice()
|
||||
->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view));
|
||||
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
|
||||
rtvDesc.Format = t2dDesc.Format;
|
||||
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
rtvDesc.Texture2D.MipSlice = 0u;
|
||||
DXC(m_Context->GetDevice()
|
||||
->CreateRenderTargetView(m_ColorAttachment.Get(), &rtvDesc, &m_RenderTargetView));
|
||||
DXC(m_context->GetDevice()
|
||||
->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view));
|
||||
}
|
||||
|
||||
void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor)
|
||||
|
@ -56,23 +56,23 @@ void dxFramebuffer::BindAsTarget(const glm::vec4 &clearColor)
|
|||
clearColor.a,
|
||||
};
|
||||
|
||||
m_Context->GetDeviceContext()
|
||||
->OMSetRenderTargets(1u, m_RenderTargetView.GetAddressOf(), nullptr);
|
||||
m_Context->GetDeviceContext()->ClearRenderTargetView(m_RenderTargetView.Get(), color);
|
||||
m_context->GetDeviceContext()
|
||||
->OMSetRenderTargets(1u, m_render_target_view.GetAddressOf(), nullptr);
|
||||
m_context->GetDeviceContext()->ClearRenderTargetView(m_render_target_view.Get(), color);
|
||||
|
||||
D3D11_VIEWPORT viewport;
|
||||
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
|
||||
viewport.Width = m_Specification.width;
|
||||
viewport.Height = m_Specification.height;
|
||||
viewport.Width = m_specification.width;
|
||||
viewport.Height = m_specification.height;
|
||||
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
// set viewport
|
||||
m_Context->GetDeviceContext()->RSSetViewports(1u, &viewport);
|
||||
m_context->GetDeviceContext()->RSSetViewports(1u, &viewport);
|
||||
}
|
||||
|
||||
void dxFramebuffer::BindAsResource()
|
||||
|
@ -82,26 +82,26 @@ void dxFramebuffer::BindAsResource()
|
|||
|
||||
void dxFramebuffer::Resize(const glm::uvec2 &size)
|
||||
{
|
||||
m_Specification.width = std::clamp(size.x, 1u, 16384u);
|
||||
m_Specification.height = std::clamp(size.y, 1u, 16384u);
|
||||
m_specification.width = std::clamp(size.x, 1u, 16384u);
|
||||
m_specification.height = std::clamp(size.y, 1u, 16384u);
|
||||
|
||||
D3D11_TEXTURE2D_DESC textureDesc;
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
|
||||
m_ColorAttachment->GetDesc(&textureDesc);
|
||||
m_RenderTargetView->GetDesc(&rtvDesc);
|
||||
m_ShaderResourceView->GetDesc(&srvDesc);
|
||||
m_color_attachment->GetDesc(&textureDesc);
|
||||
m_render_target_view->GetDesc(&rtvDesc);
|
||||
m_shader_resource_view->GetDesc(&srvDesc);
|
||||
|
||||
textureDesc.Width = m_Specification.width;
|
||||
textureDesc.Height = m_Specification.height;
|
||||
textureDesc.Width = m_specification.width;
|
||||
textureDesc.Height = m_specification.height;
|
||||
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &m_ColorAttachment));
|
||||
DXC(m_Context->GetDevice()
|
||||
->CreateRenderTargetView(m_ColorAttachment.Get(), &rtvDesc, &m_RenderTargetView));
|
||||
DXC(m_Context->GetDevice()
|
||||
->CreateShaderResourceView(m_ColorAttachment.Get(), &srvDesc, &m_ShaderResourceView));
|
||||
DXC(m_context->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &m_color_attachment));
|
||||
DXC(m_context->GetDevice()
|
||||
->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view));
|
||||
DXC(m_context->GetDevice()
|
||||
->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view));
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
namespace Light {
|
||||
|
||||
dxGraphicsContext::dxGraphicsContext(GLFWwindow *windowHandle)
|
||||
: m_WindowHandle(windowHandle)
|
||||
, m_DebugInterface(nullptr)
|
||||
: m_window_handle(windowHandle)
|
||||
, m_debug_interface(nullptr)
|
||||
{
|
||||
// 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
|
||||
SetupDeviceAndSwapChain(windowHandle);
|
||||
|
@ -31,7 +31,7 @@ dxGraphicsContext::dxGraphicsContext(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
|
||||
DXGI_SWAP_CHAIN_DESC sd = { 0 };
|
||||
|
@ -86,7 +86,7 @@ void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow *windowHandle)
|
|||
|
||||
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
|
||||
context->GetDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
@ -107,7 +107,7 @@ void dxGraphicsContext::SetupRenderTargets()
|
|||
void dxGraphicsContext::SetupDebugInterface()
|
||||
{
|
||||
#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;
|
||||
Microsoft::WRL::ComPtr<ID3D11Debug> debugInterface = nullptr;
|
||||
|
@ -134,7 +134,7 @@ void dxGraphicsContext::SetupDebugInterface()
|
|||
|
||||
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
|
||||
IDXGIDevice *DXGIDevice;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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
|
||||
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)
|
||||
{
|
||||
LOG(critical, "dxRenderCommand::SwapBuffers: DeviceRemoved:");
|
||||
LOG(critical, " {}", m_Context->GetDevice()->GetDeviceRemovedReason());
|
||||
LOG(critical, " {}", m_context->GetDevice()->GetDeviceRemovedReason());
|
||||
throw dxException(hr, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
#else
|
||||
m_Context->GetSwapChain()->Present(0u, 0u);
|
||||
m_context->GetSwapChain()->Present(0u, 0u);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dxRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor)
|
||||
{
|
||||
m_Context->GetDeviceContext()->ClearRenderTargetView(
|
||||
m_Context->GetRenderTargetView().Get(),
|
||||
m_context->GetDeviceContext()->ClearRenderTargetView(
|
||||
m_context->GetRenderTargetView().Get(),
|
||||
&clearColor[0]
|
||||
);
|
||||
}
|
||||
|
||||
void dxRenderCommand::Draw(unsigned int count)
|
||||
{
|
||||
m_Context->GetDeviceContext()->Draw(count, 0u);
|
||||
m_context->GetDeviceContext()->Draw(count, 0u);
|
||||
}
|
||||
|
||||
void dxRenderCommand::DrawIndexed(unsigned int count)
|
||||
{
|
||||
m_Context->GetDeviceContext()->DrawIndexed(count, 0u, 0u);
|
||||
m_context->GetDeviceContext()->DrawIndexed(count, 0u, 0u);
|
||||
}
|
||||
|
||||
void dxRenderCommand::DefaultTargetFramebuffer()
|
||||
{
|
||||
m_Context->GetDeviceContext()
|
||||
->OMSetRenderTargets(1, m_Context->GetRenderTargetView().GetAddressOf(), nullptr);
|
||||
m_context->GetDeviceContext()
|
||||
->OMSetRenderTargets(1, m_context->GetRenderTargetView().GetAddressOf(), nullptr);
|
||||
}
|
||||
|
||||
void dxRenderCommand::SetViewport(
|
||||
|
@ -72,7 +72,7 @@ void dxRenderCommand::SetViewport(
|
|||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
// set viewport
|
||||
m_Context->GetDeviceContext()->RSSetViewports(1u, &viewport);
|
||||
m_context->GetDeviceContext()->RSSetViewports(1u, &viewport);
|
||||
}
|
||||
|
||||
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
|
||||
ID3D11RenderTargetView *nullViews[] = { nullptr };
|
||||
m_Context->GetDeviceContext()->OMSetRenderTargets(1u, nullViews, nullptr);
|
||||
m_Context->GetRenderTargetViewRef().Reset();
|
||||
m_context->GetDeviceContext()->OMSetRenderTargets(1u, nullViews, nullptr);
|
||||
m_context->GetRenderTargetViewRef().Reset();
|
||||
|
||||
// resize buffer
|
||||
DXC(m_Context->GetSwapChain()
|
||||
DXC(m_context->GetSwapChain()
|
||||
->ResizeBuffers(0u, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, NULL));
|
||||
|
||||
// create render target
|
||||
Microsoft::WRL::ComPtr<ID3D11Resource> backBuffer = nullptr;
|
||||
DXC(m_Context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer));
|
||||
DXC(m_Context->GetDevice()->CreateRenderTargetView(
|
||||
DXC(m_context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer));
|
||||
DXC(m_context->GetDevice()->CreateRenderTargetView(
|
||||
backBuffer.Get(),
|
||||
nullptr,
|
||||
&m_Context->GetRenderTargetViewRef()
|
||||
&m_context->GetRenderTargetViewRef()
|
||||
));
|
||||
|
||||
// set render target
|
||||
m_Context->GetDeviceContext()
|
||||
->OMSetRenderTargets(1u, m_Context->GetRenderTargetView().GetAddressOf(), nullptr);
|
||||
m_context->GetDeviceContext()
|
||||
->OMSetRenderTargets(1u, m_context->GetRenderTargetView().GetAddressOf(), nullptr);
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -9,10 +9,10 @@ dxShader::dxShader(
|
|||
BasicFileHandle pixelFile,
|
||||
Ref<dxSharedContext> sharedContext
|
||||
)
|
||||
: m_Context(sharedContext)
|
||||
, m_VertexShader(nullptr)
|
||||
, m_PixelShader(nullptr)
|
||||
, m_VertexBlob(nullptr)
|
||||
: m_context(sharedContext)
|
||||
, m_vertex_shader(nullptr)
|
||||
, m_pixel_shader(nullptr)
|
||||
, m_vertex_blob(nullptr)
|
||||
{
|
||||
Microsoft::WRL::ComPtr<ID3DBlob> ps = nullptr, vsErr = nullptr, psErr = nullptr;
|
||||
|
||||
|
@ -28,7 +28,7 @@ dxShader::dxShader(
|
|||
"vs_4_0",
|
||||
NULL,
|
||||
NULL,
|
||||
&m_VertexBlob,
|
||||
&m_vertex_blob,
|
||||
&vsErr
|
||||
);
|
||||
D3DCompile(
|
||||
|
@ -51,14 +51,14 @@ dxShader::dxShader(
|
|||
|
||||
// create shaders
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateVertexShader(
|
||||
m_VertexBlob->GetBufferPointer(),
|
||||
m_VertexBlob->GetBufferSize(),
|
||||
DXC(m_context->GetDevice()->CreateVertexShader(
|
||||
m_vertex_blob->GetBufferPointer(),
|
||||
m_vertex_blob->GetBufferSize(),
|
||||
NULL,
|
||||
&m_VertexShader
|
||||
&m_vertex_shader
|
||||
));
|
||||
DXC(m_Context->GetDevice()
|
||||
->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_PixelShader));
|
||||
DXC(m_context->GetDevice()
|
||||
->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_pixel_shader));
|
||||
}
|
||||
|
||||
dxShader::~dxShader()
|
||||
|
@ -68,14 +68,14 @@ dxShader::~dxShader()
|
|||
|
||||
void dxShader::Bind()
|
||||
{
|
||||
m_Context->GetDeviceContext()->VSSetShader(m_VertexShader.Get(), nullptr, 0u);
|
||||
m_Context->GetDeviceContext()->PSSetShader(m_PixelShader.Get(), nullptr, 0u);
|
||||
m_context->GetDeviceContext()->VSSetShader(m_vertex_shader.Get(), nullptr, 0u);
|
||||
m_context->GetDeviceContext()->PSSetShader(m_pixel_shader.Get(), nullptr, 0u);
|
||||
}
|
||||
|
||||
void dxShader::UnBind()
|
||||
{
|
||||
m_Context->GetDeviceContext()->VSSetShader(nullptr, nullptr, 0u);
|
||||
m_Context->GetDeviceContext()->PSSetShader(nullptr, nullptr, 0u);
|
||||
m_context->GetDeviceContext()->VSSetShader(nullptr, nullptr, 0u);
|
||||
m_context->GetDeviceContext()->PSSetShader(nullptr, nullptr, 0u);
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -12,10 +12,10 @@ dxTexture::dxTexture(
|
|||
const std::string &filePath
|
||||
)
|
||||
: Texture(filePath)
|
||||
, m_Context(sharedContext)
|
||||
, m_Texture2D(nullptr)
|
||||
, m_ShaderResourceView(nullptr)
|
||||
, m_SamplerState(nullptr)
|
||||
, m_context(sharedContext)
|
||||
, m_texture_2d(nullptr)
|
||||
, m_shader_resource_view(nullptr)
|
||||
, m_sampler_state(nullptr)
|
||||
{
|
||||
// texture2d desc
|
||||
D3D11_TEXTURE2D_DESC t2dDesc = {};
|
||||
|
@ -38,11 +38,11 @@ dxTexture::dxTexture(
|
|||
|
||||
// create texture
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_Texture2D));
|
||||
m_Context->GetDeviceContext()
|
||||
->UpdateSubresource(m_Texture2D.Get(), 0u, nullptr, pixels, width * 4u, 0u);
|
||||
DXC(m_context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_texture_2d));
|
||||
m_context->GetDeviceContext()
|
||||
->UpdateSubresource(m_texture_2d.Get(), 0u, nullptr, pixels, width * 4u, 0u);
|
||||
|
||||
m_Texture2D->GetDesc(&t2dDesc);
|
||||
m_texture_2d->GetDesc(&t2dDesc);
|
||||
|
||||
// shader resource view desc
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
|
@ -52,9 +52,9 @@ dxTexture::dxTexture(
|
|||
srvDesc.Texture2D.MipLevels = -1;
|
||||
|
||||
// create shader resource view
|
||||
m_Context->GetDevice()
|
||||
->CreateShaderResourceView(m_Texture2D.Get(), &srvDesc, &m_ShaderResourceView);
|
||||
m_Context->GetDeviceContext()->GenerateMips(m_ShaderResourceView.Get());
|
||||
m_context->GetDevice()
|
||||
->CreateShaderResourceView(m_texture_2d.Get(), &srvDesc, &m_shader_resource_view);
|
||||
m_context->GetDeviceContext()->GenerateMips(m_shader_resource_view.Get());
|
||||
|
||||
// sampler desc
|
||||
D3D11_SAMPLER_DESC sDesc = {};
|
||||
|
@ -67,14 +67,14 @@ dxTexture::dxTexture(
|
|||
sDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
// create sampler
|
||||
m_Context->GetDevice()->CreateSamplerState(&sDesc, &m_SamplerState);
|
||||
m_context->GetDevice()->CreateSamplerState(&sDesc, &m_sampler_state);
|
||||
}
|
||||
|
||||
void dxTexture::Bind(unsigned int slot /* = 0u */)
|
||||
{
|
||||
m_Context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_SamplerState.GetAddressOf());
|
||||
m_Context->GetDeviceContext()
|
||||
->PSSetShaderResources(slot, 1u, m_ShaderResourceView.GetAddressOf());
|
||||
m_context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_sampler_state.GetAddressOf());
|
||||
m_context->GetDeviceContext()
|
||||
->PSSetShaderResources(slot, 1u, m_shader_resource_view.GetAddressOf());
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -9,8 +9,8 @@ dxVertexLayout::dxVertexLayout(
|
|||
const std::vector<std::pair<std::string, VertexElementType>> &elements,
|
||||
Ref<dxSharedContext> sharedContext
|
||||
)
|
||||
: m_Context(sharedContext)
|
||||
, m_InputLayout(nullptr)
|
||||
: m_context(sharedContext)
|
||||
, m_input_layout(nullptr)
|
||||
{
|
||||
// occupy space for input elements
|
||||
std::vector<D3D11_INPUT_ELEMENT_DESC> inputElementsDesc;
|
||||
|
@ -33,12 +33,12 @@ dxVertexLayout::dxVertexLayout(
|
|||
|
||||
// create input layout (vertex layout)
|
||||
HRESULT hr;
|
||||
DXC(m_Context->GetDevice()->CreateInputLayout(
|
||||
DXC(m_context->GetDevice()->CreateInputLayout(
|
||||
&inputElementsDesc[0],
|
||||
inputElementsDesc.size(),
|
||||
dxpShader->GetVertexBlob().Get()->GetBufferPointer(),
|
||||
dxpShader->GetVertexBlob().Get()->GetBufferSize(),
|
||||
&m_InputLayout
|
||||
&m_input_layout
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,12 @@ dxVertexLayout::~dxVertexLayout()
|
|||
|
||||
void dxVertexLayout::Bind()
|
||||
{
|
||||
m_Context->GetDeviceContext()->IASetInputLayout(m_InputLayout.Get());
|
||||
m_context->GetDeviceContext()->IASetInputLayout(m_input_layout.Get());
|
||||
}
|
||||
|
||||
void dxVertexLayout::UnBind()
|
||||
{
|
||||
m_Context->GetDeviceContext()->IASetInputLayout(nullptr);
|
||||
m_context->GetDeviceContext()->IASetInputLayout(nullptr);
|
||||
}
|
||||
|
||||
DXGI_FORMAT dxVertexLayout::GetDxgiFormat(VertexElementType type)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace Light {
|
||||
|
||||
glBlender::glBlender()
|
||||
: m_FactorMap { // constants
|
||||
: m_factor_map { // constants
|
||||
{ BlendFactor::ZERO, GL_ZERO },
|
||||
{ BlendFactor::ONE, GL_ONE },
|
||||
|
||||
|
@ -35,7 +35,7 @@ glBlender::glBlender()
|
|||
void glBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor)
|
||||
{
|
||||
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()
|
||||
|
|
|
@ -5,53 +5,53 @@ namespace Light {
|
|||
|
||||
//==================== CONSTANT_BUFFER ====================//
|
||||
glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size)
|
||||
: m_BufferID(NULL)
|
||||
, m_Index(static_cast<int>(index))
|
||||
: m_buffer_id(NULL)
|
||||
, m_index(static_cast<int>(index))
|
||||
{
|
||||
glCreateBuffers(1, &m_BufferID);
|
||||
glNamedBufferData(m_BufferID, size, nullptr, GL_DYNAMIC_DRAW);
|
||||
glCreateBuffers(1, &m_buffer_id);
|
||||
glNamedBufferData(m_buffer_id, size, nullptr, GL_DYNAMIC_DRAW);
|
||||
|
||||
Bind();
|
||||
}
|
||||
|
||||
glConstantBuffer::~glConstantBuffer()
|
||||
{
|
||||
glDeleteBuffers(1, &m_BufferID);
|
||||
glDeleteBuffers(1, &m_buffer_id);
|
||||
}
|
||||
|
||||
void glConstantBuffer::Bind()
|
||||
{
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, m_Index, m_BufferID);
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, m_index, m_buffer_id);
|
||||
}
|
||||
|
||||
void *glConstantBuffer::Map()
|
||||
{
|
||||
void *map = glMapNamedBuffer(m_BufferID, GL_WRITE_ONLY);
|
||||
void *map = glMapNamedBuffer(m_buffer_id, GL_WRITE_ONLY);
|
||||
return map;
|
||||
}
|
||||
|
||||
void glConstantBuffer::UnMap()
|
||||
{
|
||||
glUnmapNamedBuffer(m_BufferID);
|
||||
glUnmapNamedBuffer(m_buffer_id);
|
||||
}
|
||||
//==================== CONSTANT_BUFFER ====================//
|
||||
|
||||
//==================== VERTEX_BUFFER ====================//
|
||||
glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count)
|
||||
: m_BufferID(NULL)
|
||||
: m_buffer_id(NULL)
|
||||
{
|
||||
glCreateBuffers(1, &m_BufferID);
|
||||
glNamedBufferData(m_BufferID, stride * count, vertices, GL_DYNAMIC_DRAW);
|
||||
glCreateBuffers(1, &m_buffer_id);
|
||||
glNamedBufferData(m_buffer_id, stride * count, vertices, GL_DYNAMIC_DRAW);
|
||||
}
|
||||
|
||||
glVertexBuffer::~glVertexBuffer()
|
||||
{
|
||||
glDeleteBuffers(1, &m_BufferID);
|
||||
glDeleteBuffers(1, &m_buffer_id);
|
||||
}
|
||||
|
||||
void glVertexBuffer::Bind()
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_BufferID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id);
|
||||
}
|
||||
|
||||
void glVertexBuffer::UnBind()
|
||||
|
@ -61,17 +61,17 @@ void glVertexBuffer::UnBind()
|
|||
|
||||
void *glVertexBuffer::Map()
|
||||
{
|
||||
return glMapNamedBuffer(m_BufferID, GL_WRITE_ONLY);
|
||||
return glMapNamedBuffer(m_buffer_id, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
void glVertexBuffer::UnMap()
|
||||
{
|
||||
glUnmapNamedBuffer(m_BufferID);
|
||||
glUnmapNamedBuffer(m_buffer_id);
|
||||
}
|
||||
//==================== VERTEX_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
|
||||
bool hasIndices = !!indices;
|
||||
|
@ -103,8 +103,8 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_Buffe
|
|||
}
|
||||
|
||||
// create buffer
|
||||
glCreateBuffers(1, &m_BufferID);
|
||||
glNamedBufferData(m_BufferID, count * sizeof(unsigned int), indices, GL_STATIC_DRAW);
|
||||
glCreateBuffers(1, &m_buffer_id);
|
||||
glNamedBufferData(m_buffer_id, count * sizeof(unsigned int), indices, GL_STATIC_DRAW);
|
||||
|
||||
// delete indices
|
||||
if (!hasIndices)
|
||||
|
@ -113,12 +113,12 @@ glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_Buffe
|
|||
|
||||
glIndexBuffer::~glIndexBuffer()
|
||||
{
|
||||
glDeleteBuffers(1, &m_BufferID);
|
||||
glDeleteBuffers(1, &m_buffer_id);
|
||||
}
|
||||
|
||||
void glIndexBuffer::Bind()
|
||||
{
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BufferID);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer_id);
|
||||
}
|
||||
|
||||
void glIndexBuffer::UnBind()
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
namespace Light {
|
||||
|
||||
glFramebuffer::glFramebuffer(const FramebufferSpecification &specification)
|
||||
: m_Specification(specification)
|
||||
, m_BufferID(NULL)
|
||||
, m_ColorAttachmentID(NULL)
|
||||
, m_DepthStencilAttachmentID(NULL)
|
||||
: m_specification(specification)
|
||||
, m_buffer_id(NULL)
|
||||
, m_color_attachment_id(NULL)
|
||||
, m_depth_stencil_attachment_id(NULL)
|
||||
{
|
||||
Resize({ specification.width, specification.height });
|
||||
}
|
||||
|
||||
glFramebuffer::~glFramebuffer()
|
||||
{
|
||||
glDeleteFramebuffers(1, &m_BufferID);
|
||||
glDeleteTextures(1, &m_ColorAttachmentID);
|
||||
// glDeleteTextures(1, &m_DepthStencilAttachmentID);
|
||||
glDeleteFramebuffers(1, &m_buffer_id);
|
||||
glDeleteTextures(1, &m_color_attachment_id);
|
||||
// glDeleteTextures(1, &m_depth_stencil_attachment_id);
|
||||
}
|
||||
|
||||
void glFramebuffer::BindAsTarget(const glm::vec4 &clearColor)
|
||||
{
|
||||
// #todo: use viewport instead of default x=0, y=0
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferID);
|
||||
glViewport(0, 0, m_Specification.width, m_Specification.height);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_buffer_id);
|
||||
glViewport(0, 0, m_specification.width, m_specification.height);
|
||||
|
||||
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
@ -37,53 +37,53 @@ void glFramebuffer::BindAsResource()
|
|||
|
||||
void glFramebuffer::Resize(const glm::uvec2 &size)
|
||||
{
|
||||
if (m_BufferID)
|
||||
if (m_buffer_id)
|
||||
{
|
||||
glDeleteFramebuffers(1, &m_BufferID);
|
||||
glDeleteTextures(1, &m_ColorAttachmentID);
|
||||
// glDeleteTextures(1, &m_DepthStencilAttachmentID);
|
||||
glDeleteFramebuffers(1, &m_buffer_id);
|
||||
glDeleteTextures(1, &m_color_attachment_id);
|
||||
// glDeleteTextures(1, &m_depth_stencil_attachment_id);
|
||||
}
|
||||
|
||||
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.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);
|
||||
|
||||
glCreateFramebuffers(1, &m_BufferID);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferID);
|
||||
glCreateFramebuffers(1, &m_buffer_id);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_buffer_id);
|
||||
|
||||
// create color attachment
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_ColorAttachmentID);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ColorAttachmentID);
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_color_attachment_id);
|
||||
glBindTexture(GL_TEXTURE_2D, m_color_attachment_id);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA8,
|
||||
m_Specification.width,
|
||||
m_Specification.height,
|
||||
m_specification.width,
|
||||
m_specification.height,
|
||||
NULL,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
nullptr
|
||||
);
|
||||
glTextureParameteri(m_ColorAttachmentID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_ColorAttachmentID, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_color_attachment_id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_color_attachment_id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D,
|
||||
m_ColorAttachmentID,
|
||||
m_color_attachment_id,
|
||||
0
|
||||
);
|
||||
|
||||
// glTextureStorage2D(m_ColorAttachmentID, 0, GL_RGBA8, m_Specification.width,
|
||||
// m_Specification.height);
|
||||
// glTextureStorage2D(m_color_attachment_id, 0, GL_RGBA8, m_specification.width,
|
||||
// m_specification.height);
|
||||
|
||||
// glCreateTextures(GL_TEXTURE_2D, 1, &m_DepthStencilAttachmentID);
|
||||
// glBindTexture(GL_TEXTURE_2D, m_DepthStencilAttachmentID);
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_Specification.width,
|
||||
// m_Specification.height, NULL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||
// // glTextureStorage2D(m_DepthStencilAttachmentID, 0, GL_DEPTH24_STENCIL8,
|
||||
// m_Specification.width, m_Specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
// GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthStencilAttachmentID, 0);
|
||||
// glCreateTextures(GL_TEXTURE_2D, 1, &m_depth_stencil_attachment_id);
|
||||
// glBindTexture(GL_TEXTURE_2D, m_depth_stencil_attachment_id);
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_specification.width,
|
||||
// m_specification.height, NULL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||
// // glTextureStorage2D(m_depth_stencil_attachment_id, 0, GL_DEPTH24_STENCIL8,
|
||||
// m_specification.width, m_specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
// GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depth_stencil_attachment_id, 0);
|
||||
|
||||
ASSERT(
|
||||
(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE),
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
glGraphicsContext::glGraphicsContext(GLFWwindow *windowHandle): m_WindowHandle(windowHandle)
|
||||
glGraphicsContext::glGraphicsContext(GLFWwindow *windowHandle): m_window_handle(windowHandle)
|
||||
{
|
||||
// set 'GraphicsAPI'
|
||||
m_GraphicsAPI = GraphicsAPI::OpenGL;
|
||||
m_graphics_api = GraphicsAPI::OpenGL;
|
||||
|
||||
// make context current
|
||||
glfwMakeContextCurrent(windowHandle);
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_WindowHandle(windowHandle)
|
||||
glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_window_handle(windowHandle)
|
||||
{
|
||||
}
|
||||
|
||||
void glRenderCommand::SwapBuffers()
|
||||
{
|
||||
glfwSwapBuffers(m_WindowHandle);
|
||||
glfwSwapBuffers(m_window_handle);
|
||||
}
|
||||
|
||||
void glRenderCommand::ClearBackBuffer(const glm::vec4 &clearColor)
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_ShaderID(0u)
|
||||
glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_shader_id(0u)
|
||||
{
|
||||
// create
|
||||
m_ShaderID = glCreateProgram();
|
||||
m_shader_id = glCreateProgram();
|
||||
|
||||
std::string vertexSource(vertexFile.GetData(), vertexFile.GetData() + vertexFile.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);
|
||||
|
||||
// attach shaders
|
||||
glAttachShader(m_ShaderID, vertexShader);
|
||||
glAttachShader(m_ShaderID, pixelShader);
|
||||
glAttachShader(m_shader_id, vertexShader);
|
||||
glAttachShader(m_shader_id, pixelShader);
|
||||
|
||||
// link shader program
|
||||
glLinkProgram(m_ShaderID);
|
||||
glLinkProgram(m_shader_id);
|
||||
|
||||
// delete shaders (free memory)
|
||||
glDeleteShader(vertexShader);
|
||||
|
@ -31,12 +31,12 @@ glShader::glShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile): m_Sha
|
|||
|
||||
glShader::~glShader()
|
||||
{
|
||||
glDeleteProgram(m_ShaderID);
|
||||
glDeleteProgram(m_shader_id);
|
||||
}
|
||||
|
||||
void glShader::Bind()
|
||||
{
|
||||
glUseProgram(m_ShaderID);
|
||||
glUseProgram(m_shader_id);
|
||||
}
|
||||
|
||||
void glShader::UnBind()
|
||||
|
|
|
@ -11,16 +11,16 @@ glTexture::glTexture(
|
|||
const std::string &filePath
|
||||
)
|
||||
: Texture(filePath)
|
||||
, m_TextureID(NULL)
|
||||
, m_texture_id(NULL)
|
||||
{
|
||||
// create texture
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_TextureID);
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &m_texture_id);
|
||||
|
||||
// set texture parameters
|
||||
glTextureParameteri(m_TextureID, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTextureParameteri(m_TextureID, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_TextureID, 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_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTextureParameteri(m_texture_id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(m_texture_id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(m_texture_id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// determine formats
|
||||
unsigned int format = components == 4u ? GL_RGBA :
|
||||
|
@ -58,18 +58,18 @@ glTexture::glTexture(
|
|||
|
||||
glTexture::~glTexture()
|
||||
{
|
||||
glDeleteTextures(1, &m_TextureID);
|
||||
glDeleteTextures(1, &m_texture_id);
|
||||
}
|
||||
|
||||
void glTexture::Bind(unsigned int slot /* = 0u */)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + slot);
|
||||
glBindTexture(GL_TEXTURE_2D, m_TextureID);
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture_id);
|
||||
}
|
||||
|
||||
void *glTexture::GetTexture()
|
||||
{
|
||||
return (void *)(intptr_t)m_TextureID;
|
||||
return (void *)(intptr_t)m_texture_id;
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -12,7 +12,7 @@ void glUserInterface::PlatformImplementation(
|
|||
Ref<SharedContext> sharedContext
|
||||
)
|
||||
{
|
||||
m_WindowHandle = windowHandle;
|
||||
m_window_handle = windowHandle;
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(windowHandle, false);
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
|
@ -45,7 +45,7 @@ void glUserInterface::End()
|
|||
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
glfwMakeContextCurrent(m_WindowHandle);
|
||||
glfwMakeContextCurrent(m_window_handle);
|
||||
}
|
||||
|
||||
void glUserInterface::LogDebugData()
|
||||
|
|
|
@ -8,7 +8,7 @@ glVertexLayout::glVertexLayout(
|
|||
Ref<VertexBuffer> buffer,
|
||||
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
||||
)
|
||||
: m_ArrayID(NULL)
|
||||
: m_array_id(NULL)
|
||||
{
|
||||
// check
|
||||
ASSERT(
|
||||
|
@ -30,7 +30,7 @@ glVertexLayout::glVertexLayout(
|
|||
}
|
||||
|
||||
// create vertex array
|
||||
glCreateVertexArrays(1, &m_ArrayID);
|
||||
glCreateVertexArrays(1, &m_array_id);
|
||||
|
||||
// bind buffer and array
|
||||
buffer->Bind();
|
||||
|
@ -54,12 +54,12 @@ glVertexLayout::glVertexLayout(
|
|||
|
||||
glVertexLayout::~glVertexLayout()
|
||||
{
|
||||
glDeleteVertexArrays(1, &m_ArrayID);
|
||||
glDeleteVertexArrays(1, &m_array_id);
|
||||
}
|
||||
|
||||
void glVertexLayout::Bind()
|
||||
{
|
||||
glBindVertexArray(m_ArrayID);
|
||||
glBindVertexArray(m_array_id);
|
||||
}
|
||||
|
||||
void glVertexLayout::UnBind()
|
||||
|
|
|
@ -15,8 +15,8 @@ Scope<Window> Window::Create(std::function<void(Event &)> callback)
|
|||
}
|
||||
|
||||
lWindow::lWindow(std::function<void(Event &)> callback)
|
||||
: m_Handle(nullptr)
|
||||
, m_EventCallback(callback)
|
||||
: m_handle(nullptr)
|
||||
, m_event_callback(callback)
|
||||
{
|
||||
// init 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_VISIBLE, GLFW_FALSE);
|
||||
|
||||
m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
|
||||
ASSERT(m_Handle, "lWindow::lWindow: failed to create 'GLFWwindow'");
|
||||
m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
|
||||
ASSERT(m_handle, "lWindow::lWindow: failed to create 'GLFWwindow'");
|
||||
|
||||
// bind event stuff
|
||||
glfwSetWindowUserPointer(m_Handle, &m_EventCallback);
|
||||
glfwSetWindowUserPointer(m_handle, &m_event_callback);
|
||||
BindGlfwEvents();
|
||||
|
||||
// create graphics context
|
||||
m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::OpenGL, m_Handle);
|
||||
ASSERT(m_GraphicsContext, "lWindow::lWindow: failed to create 'GraphicsContext'");
|
||||
m_graphics_context = GraphicsContext::Create(GraphicsAPI::OpenGL, m_handle);
|
||||
ASSERT(m_graphics_context, "lWindow::lWindow: failed to create 'GraphicsContext'");
|
||||
}
|
||||
|
||||
lWindow::~lWindow()
|
||||
{
|
||||
glfwDestroyWindow(m_Handle);
|
||||
glfwDestroyWindow(m_handle);
|
||||
}
|
||||
|
||||
void lWindow::PollEvents()
|
||||
|
@ -63,16 +63,16 @@ void lWindow::OnEvent(const Event &event)
|
|||
|
||||
void lWindow::OnWindowResize(const WindowResizedEvent &event)
|
||||
{
|
||||
m_Properties.size = event.GetSize();
|
||||
m_properties.size = event.GetSize();
|
||||
}
|
||||
|
||||
void lWindow::
|
||||
SetProperties(const WindowProperties &properties, bool overrideVisibility /* = false */)
|
||||
{
|
||||
// save the visibility status and re-assign if 'overrideVisibility' is false
|
||||
bool visible = overrideVisibility ? properties.visible : m_Properties.visible;
|
||||
m_Properties = properties;
|
||||
m_Properties.visible = visible;
|
||||
bool visible = overrideVisibility ? properties.visible : m_properties.visible;
|
||||
m_properties = properties;
|
||||
m_properties.visible = visible;
|
||||
|
||||
// set properties
|
||||
SetTitle(properties.title);
|
||||
|
@ -83,46 +83,46 @@ void lWindow::
|
|||
|
||||
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 */)
|
||||
{
|
||||
m_Properties.size.x = size.x == 0u ? m_Properties.size.x :
|
||||
additive ? m_Properties.size.x + size.x :
|
||||
m_properties.size.x = size.x == 0u ? m_properties.size.x :
|
||||
additive ? m_properties.size.x + size.x :
|
||||
size.x;
|
||||
m_Properties.size.y = size.y == 0u ? m_Properties.size.y :
|
||||
additive ? m_Properties.size.y + size.y :
|
||||
m_properties.size.y = size.y == 0u ? m_properties.size.y :
|
||||
additive ? m_properties.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 */)
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_Properties.visible = toggle ? !m_Properties.visible : visible;
|
||||
m_properties.visible = toggle ? !m_properties.visible : visible;
|
||||
|
||||
if (m_Properties.visible)
|
||||
glfwShowWindow(m_Handle);
|
||||
if (m_properties.visible)
|
||||
glfwShowWindow(m_handle);
|
||||
else
|
||||
glfwHideWindow(m_Handle);
|
||||
glfwHideWindow(m_handle);
|
||||
}
|
||||
|
||||
void lWindow::BindGlfwEvents()
|
||||
{
|
||||
//============================== MOUSE_EVENTS ==============================//
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -131,7 +131,7 @@ void lWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -148,7 +148,7 @@ void lWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -160,7 +160,7 @@ void lWindow::BindGlfwEvents()
|
|||
//============================== KEYBOARD_EVENTS ==============================//
|
||||
/* key */
|
||||
glfwSetKeyCallback(
|
||||
m_Handle,
|
||||
m_handle,
|
||||
[](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
@ -178,7 +178,7 @@ void lWindow::BindGlfwEvents()
|
|||
}
|
||||
);
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -190,7 +190,7 @@ void lWindow::BindGlfwEvents()
|
|||
|
||||
//============================== WINDOW_EVENTS ==============================//
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowMovedEvent event(xpos, ypos);
|
||||
|
@ -199,7 +199,7 @@ void lWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowResizedEvent event(width, height);
|
||||
|
@ -208,7 +208,7 @@ void lWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* window close */
|
||||
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow *window) {
|
||||
glfwSetWindowCloseCallback(m_handle, [](GLFWwindow *window) {
|
||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowClosedEvent event;
|
||||
|
@ -217,7 +217,7 @@ void lWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ Scope<Window> Window::Create(std::function<void(Event &)> callback)
|
|||
}
|
||||
|
||||
wWindow::wWindow(std::function<void(Event &)> callback)
|
||||
: m_Handle(nullptr)
|
||||
, m_EventCallback(callback)
|
||||
: m_handle(nullptr)
|
||||
, m_event_callback(callback)
|
||||
{
|
||||
// init 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_VISIBLE, GLFW_FALSE);
|
||||
|
||||
m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
|
||||
ASSERT(m_Handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'");
|
||||
m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
|
||||
ASSERT(m_handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'");
|
||||
|
||||
// bind event stuff
|
||||
glfwSetWindowUserPointer(m_Handle, &m_EventCallback);
|
||||
glfwSetWindowUserPointer(m_handle, &m_event_callback);
|
||||
BindGlfwEvents();
|
||||
|
||||
// create graphics context
|
||||
m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle);
|
||||
ASSERT(m_GraphicsContext, "wWindow::wWindow: failed to create 'GraphicsContext'");
|
||||
m_graphics_context = GraphicsContext::Create(GraphicsAPI::DirectX, m_handle);
|
||||
ASSERT(m_graphics_context, "wWindow::wWindow: failed to create 'GraphicsContext'");
|
||||
}
|
||||
|
||||
wWindow::~wWindow()
|
||||
{
|
||||
glfwDestroyWindow(m_Handle);
|
||||
glfwDestroyWindow(m_handle);
|
||||
}
|
||||
|
||||
void wWindow::PollEvents()
|
||||
|
@ -70,16 +70,16 @@ void wWindow::OnEvent(const Event &event)
|
|||
|
||||
void wWindow::OnWindowResize(const WindowResizedEvent &event)
|
||||
{
|
||||
m_Properties.size = event.GetSize();
|
||||
m_properties.size = event.GetSize();
|
||||
}
|
||||
|
||||
void wWindow::
|
||||
SetProperties(const WindowProperties &properties, bool overrideVisiblity /* = false */)
|
||||
{
|
||||
// save the visibility status and re-assign if 'overrideVisibility' is false
|
||||
bool visible = overrideVisiblity ? properties.visible : m_Properties.visible;
|
||||
m_Properties = properties;
|
||||
m_Properties.visible = visible;
|
||||
bool visible = overrideVisiblity ? properties.visible : m_properties.visible;
|
||||
m_properties = properties;
|
||||
m_properties.visible = visible;
|
||||
|
||||
// set properties
|
||||
SetTitle(properties.title);
|
||||
|
@ -90,46 +90,46 @@ void wWindow::
|
|||
|
||||
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 */)
|
||||
{
|
||||
m_Properties.size.x = size.x == 0u ? m_Properties.size.x :
|
||||
additive ? m_Properties.size.x + size.x :
|
||||
m_properties.size.x = size.x == 0u ? m_properties.size.x :
|
||||
additive ? m_properties.size.x + size.x :
|
||||
size.x;
|
||||
m_Properties.size.y = size.y == 0u ? m_Properties.size.y :
|
||||
additive ? m_Properties.size.y + size.y :
|
||||
m_properties.size.y = size.y == 0u ? m_properties.size.y :
|
||||
additive ? m_properties.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 */)
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_Properties.visible = toggle ? !m_Properties.visible : visible;
|
||||
m_properties.visible = toggle ? !m_properties.visible : visible;
|
||||
|
||||
if (m_Properties.visible)
|
||||
glfwShowWindow(m_Handle);
|
||||
if (m_properties.visible)
|
||||
glfwShowWindow(m_handle);
|
||||
else
|
||||
glfwHideWindow(m_Handle);
|
||||
glfwHideWindow(m_handle);
|
||||
}
|
||||
|
||||
void wWindow::BindGlfwEvents()
|
||||
{
|
||||
//============================== MOUSE_EVENTS ==============================//
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -138,7 +138,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -155,7 +155,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -167,7 +167,7 @@ void wWindow::BindGlfwEvents()
|
|||
//============================== KEYBOARD_EVENTS ==============================//
|
||||
/* key */
|
||||
glfwSetKeyCallback(
|
||||
m_Handle,
|
||||
m_handle,
|
||||
[](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
@ -185,7 +185,7 @@ void wWindow::BindGlfwEvents()
|
|||
}
|
||||
);
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
@ -197,7 +197,7 @@ void wWindow::BindGlfwEvents()
|
|||
|
||||
//============================== WINDOW_EVENTS ==============================//
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowMovedEvent event(xpos, ypos);
|
||||
|
@ -206,7 +206,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowResizedEvent event(width, height);
|
||||
|
@ -215,7 +215,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* window close */
|
||||
glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow *window) {
|
||||
glfwSetWindowCloseCallback(m_handle, [](GLFWwindow *window) {
|
||||
std::function<void(Event &)> callback = *(std::function<void(Event &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
WindowClosedEvent event;
|
||||
|
@ -224,7 +224,7 @@ void wWindow::BindGlfwEvents()
|
|||
});
|
||||
|
||||
/* 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 &)> *)
|
||||
glfwGetWindowUserPointer(window);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace Light {
|
||||
|
||||
Scene::Scene(): m_Registry()
|
||||
Scene::Scene(): m_registry()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ void Scene::OnCreate()
|
|||
{
|
||||
/* native scripts */
|
||||
{
|
||||
m_Registry.view<NativeScriptComponent>().each([](NativeScriptComponent &nsc) {
|
||||
m_registry.view<NativeScriptComponent>().each([](NativeScriptComponent &nsc) {
|
||||
if (nsc.instance == nullptr)
|
||||
{
|
||||
nsc.instance = nsc.CreateInstance();
|
||||
|
@ -32,7 +32,7 @@ void Scene::OnUpdate(float deltaTime)
|
|||
{
|
||||
/* native scripts */
|
||||
{
|
||||
m_Registry.view<NativeScriptComponent>().each([=](NativeScriptComponent &nsc) {
|
||||
m_registry.view<NativeScriptComponent>().each([=](NativeScriptComponent &nsc) {
|
||||
nsc.instance->OnUpdate(deltaTime);
|
||||
});
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void Scene::OnRender(const Ref<Framebuffer> &targetFrameBuffer /* = nullptr */)
|
|||
|
||||
/* scene camera */
|
||||
{
|
||||
m_Registry.group(entt::get<TransformComponent, CameraComponent>)
|
||||
m_registry.group(entt::get<TransformComponent, CameraComponent>)
|
||||
.each([&](TransformComponent &transformComp, CameraComponent &cameraComp) {
|
||||
if (cameraComp.isPrimary)
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ void Scene::OnRender(const Ref<Framebuffer> &targetFrameBuffer /* = nullptr */)
|
|||
{
|
||||
Renderer::BeginScene(sceneCamera, *sceneCameraTransform, targetFrameBuffer);
|
||||
|
||||
m_Registry.group(entt::get<TransformComponent, SpriteRendererComponent>)
|
||||
m_registry.group(entt::get<TransformComponent, SpriteRendererComponent>)
|
||||
.each([](TransformComponent &transformComp,
|
||||
SpriteRendererComponent &spriteRendererComp) {
|
||||
Renderer::DrawQuad(
|
||||
|
@ -84,12 +84,12 @@ Entity Scene::CreateEntity(const std::string &name, const TransformComponent &tr
|
|||
Entity Scene::GetEntityByTag(const std::string &tag)
|
||||
{
|
||||
// TagComponent tagComp(tag);
|
||||
// entt::entity entity = entt::to_entity(m_Registry, tagComp);
|
||||
// entt::entity entity = entt::to_entity(m_registry, tagComp);
|
||||
Entity entity;
|
||||
|
||||
m_Registry.view<TagComponent>().each([&](TagComponent &tagComp) {
|
||||
m_registry.view<TagComponent>().each([&](TagComponent &tagComp) {
|
||||
// if (tagComp.tag == tag)
|
||||
// entity = Entity(entt::to_entity(m_Registry, tagComp), this);
|
||||
// entity = Entity(entt::to_entity(m_registry, tagComp), this);
|
||||
});
|
||||
|
||||
if (entity.IsValid())
|
||||
|
@ -107,7 +107,7 @@ Entity Scene::CreateEntityWithUUID(
|
|||
const TransformComponent &transform
|
||||
)
|
||||
{
|
||||
Entity entity { m_Registry.create(), this };
|
||||
Entity entity { m_registry.create(), this };
|
||||
entity.AddComponent<TagComponent>(name);
|
||||
entity.AddComponent<TransformComponent>(transform);
|
||||
entity.AddComponent<UUIDComponent>(uuid);
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
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()
|
||||
{
|
||||
float currentFrame = timer.GetElapsedTime();
|
||||
m_DeltaTime = currentFrame - m_PreviousFrame;
|
||||
m_PreviousFrame = currentFrame;
|
||||
m_delta_time = currentFrame - m_previous_frame;
|
||||
m_previous_frame = currentFrame;
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -45,7 +45,7 @@ Scope<UserInterface> UserInterface::Create(
|
|||
}
|
||||
|
||||
UserInterface::UserInterface()
|
||||
: m_DockspaceFlags(
|
||||
: m_dockspace_flags(
|
||||
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove
|
||||
| ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus
|
||||
|
@ -129,7 +129,7 @@ void UserInterface::DockspaceBegin()
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::Begin("Dockspace", (bool *)0, s_Context->m_DockspaceFlags);
|
||||
ImGui::Begin("Dockspace", (bool *)0, s_Context->m_dockspace_flags);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
|
|
|
@ -11,19 +11,19 @@ BasicFileHandle::BasicFileHandle(
|
|||
const std::string &name,
|
||||
const std::string &extension
|
||||
)
|
||||
: m_Data(data)
|
||||
, m_Size(size)
|
||||
, m_Path(path)
|
||||
, m_Name(name)
|
||||
, m_Extension(extension)
|
||||
: m_data(data)
|
||||
, m_size(size)
|
||||
, m_path(path)
|
||||
, m_name(name)
|
||||
, m_extension(extension)
|
||||
{
|
||||
}
|
||||
|
||||
void BasicFileHandle::Release()
|
||||
{
|
||||
delete m_Data;
|
||||
m_Data = nullptr;
|
||||
m_Size = 0ull;
|
||||
delete m_data;
|
||||
m_data = nullptr;
|
||||
m_size = 0ull;
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,9 +101,9 @@ ImageFileHandle FileManager::ReadImageFile(const std::string &path, int32_t desi
|
|||
|
||||
void ImageFileHandle::Release()
|
||||
{
|
||||
stbi_image_free(reinterpret_cast<void *>(m_Data));
|
||||
m_Data = nullptr;
|
||||
m_Size = 0ull;
|
||||
stbi_image_free(reinterpret_cast<void *>(m_data));
|
||||
m_data = nullptr;
|
||||
m_size = 0ull;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Scope<ResourceManager> ResourceManager::Create()
|
|||
return MakeScope(new ResourceManager());
|
||||
}
|
||||
|
||||
ResourceManager::ResourceManager(): m_Shaders {}, m_Textures {}
|
||||
ResourceManager::ResourceManager(): m_shaders {}, m_textures {}
|
||||
{
|
||||
ASSERT(!s_Context, "Repeated singleton construction");
|
||||
s_Context = this;
|
||||
|
@ -39,7 +39,7 @@ void ResourceManager::LoadShaderImpl(
|
|||
ASSERT(pixelFile.IsValid(), "Failed to read vertex file: {}", pixelPath);
|
||||
|
||||
// create shader
|
||||
m_Shaders[name] = Ref<Shader>(
|
||||
m_shaders[name] = Ref<Shader>(
|
||||
Shader::Create(vertexFile, pixelFile, GraphicsContext::GetSharedContext())
|
||||
);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void ResourceManager::LoadTextureImpl(
|
|||
ImageFileHandle imgFile = FileManager::ReadImageFile(path, desiredComponents);
|
||||
|
||||
// create texture
|
||||
m_Textures[name] = Ref<Texture>(Texture::Create(
|
||||
m_textures[name] = Ref<Texture>(Texture::Create(
|
||||
imgFile.GetWidth(),
|
||||
imgFile.GetHeight(),
|
||||
imgFile.GetComponents(),
|
||||
|
@ -75,13 +75,13 @@ void ResourceManager::LoadTextureImpl(
|
|||
|
||||
void ResourceManager::ReleaseTextureImpl(const std::string &name)
|
||||
{
|
||||
if (!m_Textures[name])
|
||||
if (!m_textures[name])
|
||||
{
|
||||
LOG(warn, "Failed to find texture named: {}", name);
|
||||
return;
|
||||
}
|
||||
|
||||
m_Textures[name] = nullptr;
|
||||
m_textures[name] = nullptr;
|
||||
}
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -72,7 +72,7 @@ static YAML::Emitter &operator<<(YAML::Emitter &out, const glm::vec4 &v)
|
|||
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 << "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())
|
||||
return;
|
||||
|
||||
|
@ -134,7 +134,7 @@ bool SceneSerializer::Deserialize(const std::string &filePath)
|
|||
|
||||
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>();
|
||||
LOG(trace, gg.tag);
|
||||
|
|
|
@ -11,23 +11,23 @@ namespace Light {
|
|||
class EditorLayer: public Layer
|
||||
{
|
||||
private:
|
||||
std::string m_SceneDir;
|
||||
std::string m_scene_dir;
|
||||
|
||||
// #todo: add camera controller class to the engine
|
||||
glm::vec2 m_Direction;
|
||||
float m_Speed = 1000.0f;
|
||||
glm::vec2 m_direction;
|
||||
float m_speed = 1000.0f;
|
||||
|
||||
Ref<Scene> m_Scene;
|
||||
Ref<Scene> m_scene;
|
||||
|
||||
Ref<SceneHierarchyPanel> m_SceneHierarchyPanel;
|
||||
Ref<PropertiesPanel> m_PropertiesPanel;
|
||||
Ref<AssetBrowserPanel> m_ContentBrowserPanel;
|
||||
Ref<SceneHierarchyPanel> m_sceneHierarchyPanel;
|
||||
Ref<PropertiesPanel> m_properties_panel;
|
||||
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:
|
||||
EditorLayer(const std::string &name);
|
||||
|
|
|
@ -24,19 +24,19 @@ public:
|
|||
void OnUserInterfaceUpdate();
|
||||
|
||||
private:
|
||||
std::filesystem::path m_CurrentDirectory;
|
||||
const std::filesystem::path m_AssetsPath;
|
||||
std::filesystem::path m_current_directory;
|
||||
const std::filesystem::path m_assets_path;
|
||||
|
||||
// TODO: Save configuration
|
||||
uint32_t m_FileSize = 128u;
|
||||
uint32_t m_FilePadding = 8u;
|
||||
uint32_t m_file_size = 128u;
|
||||
uint32_t m_file_padding = 8u;
|
||||
|
||||
Ref<Scene> m_ActiveScene;
|
||||
Ref<Scene> m_active_scene;
|
||||
|
||||
Ref<Texture> m_DirectoryTexture;
|
||||
Ref<Texture> m_SceneTexture;
|
||||
Ref<Texture> m_ImageTexture;
|
||||
Ref<Texture> m_TextTexture;
|
||||
Ref<Texture> m_directory_texture;
|
||||
Ref<Texture> m_scene_texture;
|
||||
Ref<Texture> m_image_texture;
|
||||
Ref<Texture> m_text_texture;
|
||||
};
|
||||
|
||||
} // namespace Light
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Light {
|
|||
class PropertiesPanel: public Panel
|
||||
{
|
||||
private:
|
||||
Entity m_EntityContext;
|
||||
Entity m_entity_context;
|
||||
|
||||
public:
|
||||
PropertiesPanel() = default;
|
||||
|
|
|
@ -12,9 +12,9 @@ class PropertiesPanel;
|
|||
class SceneHierarchyPanel: public Panel
|
||||
{
|
||||
private:
|
||||
Ref<Scene> m_Context;
|
||||
Ref<PropertiesPanel> m_PropertiesPanelContext;
|
||||
Entity m_SelectionContext;
|
||||
Ref<Scene> m_context;
|
||||
Ref<PropertiesPanel> m_properties_panel_context;
|
||||
Entity m_selection_context;
|
||||
|
||||
public:
|
||||
SceneHierarchyPanel();
|
||||
|
|
|
@ -3,23 +3,23 @@
|
|||
|
||||
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_SceneHierarchyPanel = CreateRef<SceneHierarchyPanel>(m_Scene, m_PropertiesPanel);
|
||||
m_ContentBrowserPanel = CreateRef<AssetBrowserPanel>(m_Scene);
|
||||
m_properties_panel = CreateRef<PropertiesPanel>();
|
||||
m_sceneHierarchyPanel = CreateRef<SceneHierarchyPanel>(m_scene, m_properties_panel);
|
||||
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_CameraEntity.AddComponent<CameraComponent>(SceneCamera(), true);
|
||||
m_camera_entity = m_scene->CreateEntity("Camera");
|
||||
m_camera_entity.AddComponent<CameraComponent>(SceneCamera(), true);
|
||||
|
||||
ResourceManager::LoadTexture("Awesomeface", "Assets/Textures/awesomeface.png");
|
||||
Entity entity = m_Scene->CreateEntity("Awesomeface", {});
|
||||
Entity entity = m_scene->CreateEntity("Awesomeface", {});
|
||||
entity.AddComponent<SpriteRendererComponent>(
|
||||
ResourceManager::GetTexture("Awesomeface"),
|
||||
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
|
||||
{
|
||||
SceneSerializer serializer(m_Scene);
|
||||
ASSERT(serializer.Deserialize(m_SceneDir), "Failed to de-serialize: {}", m_SceneDir);
|
||||
SceneSerializer serializer(m_scene);
|
||||
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()
|
||||
{
|
||||
if (!m_SceneDir.empty())
|
||||
if (!m_scene_dir.empty())
|
||||
{
|
||||
SceneSerializer serializer(m_Scene);
|
||||
serializer.Serialize(m_SceneDir);
|
||||
SceneSerializer serializer(m_scene);
|
||||
serializer.Serialize(m_scene_dir);
|
||||
}
|
||||
}
|
||||
|
||||
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 :
|
||||
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 :
|
||||
0.0f;
|
||||
|
||||
auto &cameraTranslation = m_CameraEntity.GetComponent<TransformComponent>().translation;
|
||||
cameraTranslation += glm::vec3(m_Direction * m_Speed * deltaTime, 0.0f);
|
||||
auto &cameraTranslation = m_camera_entity.GetComponent<TransformComponent>().translation;
|
||||
cameraTranslation += glm::vec3(m_direction * m_speed * deltaTime, 0.0f);
|
||||
|
||||
if (Input::GetKeyboardKey(Key::Escape))
|
||||
Application::Quit();
|
||||
|
@ -64,7 +64,7 @@ void EditorLayer::OnUpdate(float deltaTime)
|
|||
|
||||
void EditorLayer::OnRender()
|
||||
{
|
||||
m_Scene->OnRender(m_Framebuffer);
|
||||
m_scene->OnRender(m_framebuffer);
|
||||
}
|
||||
|
||||
void EditorLayer::OnUserInterfaceUpdate()
|
||||
|
@ -77,20 +77,20 @@ void EditorLayer::OnUserInterfaceUpdate()
|
|||
Input::ReceiveGameEvents(ImGui::IsWindowFocused());
|
||||
ImVec2 regionAvail = ImGui::GetContentRegionAvail();
|
||||
|
||||
if (m_AvailableContentRegionPrev != regionAvail)
|
||||
if (m_available_content_region_prev != regionAvail)
|
||||
{
|
||||
m_Framebuffer->Resize({ regionAvail.x, regionAvail.y });
|
||||
auto &camera = m_CameraEntity.GetComponent<CameraComponent>().camera;
|
||||
m_framebuffer->Resize({ regionAvail.x, regionAvail.y });
|
||||
auto &camera = m_camera_entity.GetComponent<CameraComponent>().camera;
|
||||
camera.SetViewportSize(regionAvail.x, regionAvail.y);
|
||||
|
||||
m_AvailableContentRegionPrev = regionAvail;
|
||||
m_available_content_region_prev = regionAvail;
|
||||
}
|
||||
|
||||
if (GraphicsContext::GetGraphicsAPI() == GraphicsAPI::DirectX)
|
||||
ImGui::Image(m_Framebuffer->GetColorAttachment(), regionAvail);
|
||||
ImGui::Image(m_framebuffer->GetColorAttachment(), regionAvail);
|
||||
else
|
||||
ImGui::Image(
|
||||
m_Framebuffer->GetColorAttachment(),
|
||||
m_framebuffer->GetColorAttachment(),
|
||||
regionAvail,
|
||||
ImVec2(0, 1),
|
||||
ImVec2(1, 0)
|
||||
|
@ -99,9 +99,9 @@ void EditorLayer::OnUserInterfaceUpdate()
|
|||
ImGui::End();
|
||||
|
||||
// Panels
|
||||
m_SceneHierarchyPanel->OnUserInterfaceUpdate();
|
||||
m_PropertiesPanel->OnUserInterfaceUpdate();
|
||||
m_ContentBrowserPanel->OnUserInterfaceUpdate();
|
||||
m_sceneHierarchyPanel->OnUserInterfaceUpdate();
|
||||
m_properties_panel->OnUserInterfaceUpdate();
|
||||
m_content_browser_panel->OnUserInterfaceUpdate();
|
||||
|
||||
UserInterface::DockspaceEnd();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
properties.size = glm::uvec2(1280u, 720u);
|
||||
properties.vsync = true;
|
||||
|
||||
m_Window->SetProperties(properties);
|
||||
m_window->SetProperties(properties);
|
||||
|
||||
// Attach the sandbox layer
|
||||
LayerStack::EmplaceLayer<EditorLayer>(("MirrorLayer"));
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
namespace Light {
|
||||
|
||||
AssetBrowserPanel::AssetBrowserPanel(Ref<Scene> activeScene)
|
||||
: m_CurrentDirectory("Assets")
|
||||
, m_AssetsPath("Assets")
|
||||
, m_ActiveScene(activeScene)
|
||||
: m_current_directory("Assets")
|
||||
, m_assets_path("Assets")
|
||||
, m_active_scene(activeScene)
|
||||
{
|
||||
ResourceManager::LoadTexture("_Assets_Directory", "EngineResources/Icons/Asset_Directory.png");
|
||||
ResourceManager::LoadTexture("_Assets_Scene", "EngineResources/Icons/Asset_Scene.png");
|
||||
ResourceManager::LoadTexture("_Assets_Image", "EngineResources/Icons/Asset_Image.png");
|
||||
ResourceManager::LoadTexture("_Assets_Text", "EngineResources/Icons/Asset_Text.png");
|
||||
|
||||
m_DirectoryTexture = ResourceManager::GetTexture("_Assets_Directory");
|
||||
m_SceneTexture = ResourceManager::GetTexture("_Assets_Scene");
|
||||
m_ImageTexture = ResourceManager::GetTexture("_Assets_Image");
|
||||
m_TextTexture = ResourceManager::GetTexture("_Assets_Text");
|
||||
m_directory_texture = ResourceManager::GetTexture("_Assets_Directory");
|
||||
m_scene_texture = ResourceManager::GetTexture("_Assets_Scene");
|
||||
m_image_texture = ResourceManager::GetTexture("_Assets_Image");
|
||||
m_text_texture = ResourceManager::GetTexture("_Assets_Text");
|
||||
}
|
||||
|
||||
void AssetBrowserPanel::OnUserInterfaceUpdate()
|
||||
|
@ -26,16 +26,16 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
ImGui::Begin("Content Browser");
|
||||
|
||||
// Parent directory button
|
||||
if (m_CurrentDirectory != std::filesystem::path("Assets"))
|
||||
if (m_current_directory != std::filesystem::path("Assets"))
|
||||
{
|
||||
if (ImGui::Button(" <-- "))
|
||||
{
|
||||
m_CurrentDirectory = m_CurrentDirectory.parent_path();
|
||||
m_current_directory = m_current_directory.parent_path();
|
||||
}
|
||||
}
|
||||
|
||||
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(
|
||||
static_cast<uint32_t>(std::floor(regionAvail.x / cellSize)),
|
||||
1u,
|
||||
|
@ -44,8 +44,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
|
||||
if (ImGui::BeginTable("ContentBrowser", columnCount))
|
||||
{
|
||||
m_DirectoryTexture->Bind(0u);
|
||||
for (auto &dirEntry : std::filesystem::directory_iterator(m_CurrentDirectory))
|
||||
m_directory_texture->Bind(0u);
|
||||
for (auto &dirEntry : std::filesystem::directory_iterator(m_current_directory))
|
||||
{
|
||||
const auto &path = dirEntry.path();
|
||||
std::string extension = dirEntry.path().extension().string();
|
||||
|
@ -77,8 +77,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
// Directory
|
||||
case AssetType::Directory:
|
||||
if (ImGui::ImageButton(
|
||||
m_DirectoryTexture->GetTexture(),
|
||||
ImVec2(m_FileSize, m_FileSize),
|
||||
m_directory_texture->GetTexture(),
|
||||
ImVec2(m_file_size, m_file_size),
|
||||
ImVec2 { 0.0f, 0.0f },
|
||||
ImVec2 { 1.0f, 1.0f },
|
||||
0,
|
||||
|
@ -86,15 +86,15 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
ImVec4 { 1.0f, 1.0f, 1.0f, 1.0f }
|
||||
))
|
||||
{
|
||||
m_CurrentDirectory /= path.filename();
|
||||
m_current_directory /= path.filename();
|
||||
}
|
||||
break;
|
||||
|
||||
// Scene
|
||||
case AssetType::Scene:
|
||||
if (ImGui::ImageButton(
|
||||
m_SceneTexture->GetTexture(),
|
||||
ImVec2(m_FileSize, m_FileSize),
|
||||
m_scene_texture->GetTexture(),
|
||||
ImVec2(m_file_size, m_file_size),
|
||||
ImVec2 { 0.0f, 0.0f },
|
||||
ImVec2 { 1.0f, 1.0f },
|
||||
0,
|
||||
|
@ -102,7 +102,7 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
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());
|
||||
serializer.Deserialize(path.string());
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
// Image
|
||||
case AssetType::Image:
|
||||
if (ImGui::ImageButton(
|
||||
m_ImageTexture->GetTexture(),
|
||||
ImVec2(m_FileSize, m_FileSize),
|
||||
m_image_texture->GetTexture(),
|
||||
ImVec2(m_file_size, m_file_size),
|
||||
ImVec2 { 0.0f, 0.0f },
|
||||
ImVec2 { 1.0f, 1.0f },
|
||||
0,
|
||||
|
@ -126,8 +126,8 @@ void AssetBrowserPanel::OnUserInterfaceUpdate()
|
|||
// Text
|
||||
case AssetType::Text:
|
||||
if (ImGui::ImageButton(
|
||||
m_TextTexture->GetTexture(),
|
||||
ImVec2(m_FileSize, m_FileSize),
|
||||
m_text_texture->GetTexture(),
|
||||
ImVec2(m_file_size, m_file_size),
|
||||
ImVec2 { 0.0f, 0.0f },
|
||||
ImVec2 { 1.0f, 1.0f },
|
||||
0,
|
||||
|
|
|
@ -12,11 +12,11 @@ void PropertiesPanel::OnUserInterfaceUpdate()
|
|||
{
|
||||
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];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
@ -37,22 +37,22 @@ void PropertiesPanel::OnUserInterfaceUpdate()
|
|||
if (ImGui::Selectable(
|
||||
"SpriteRenderer",
|
||||
false,
|
||||
m_EntityContext.HasComponent<SpriteRendererComponent>() ?
|
||||
m_entity_context.HasComponent<SpriteRendererComponent>() ?
|
||||
ImGuiSelectableFlags_Disabled :
|
||||
NULL
|
||||
))
|
||||
m_EntityContext.AddComponent<SpriteRendererComponent>(
|
||||
m_entity_context.AddComponent<SpriteRendererComponent>(
|
||||
Light::ResourceManager::GetTexture("awesomeface")
|
||||
);
|
||||
|
||||
if (ImGui::Selectable(
|
||||
"Camera",
|
||||
false,
|
||||
m_EntityContext.HasComponent<CameraComponent>() ?
|
||||
m_entity_context.HasComponent<CameraComponent>() ?
|
||||
ImGuiSelectableFlags_Disabled :
|
||||
NULL
|
||||
))
|
||||
m_EntityContext.AddComponent<CameraComponent>();
|
||||
m_entity_context.AddComponent<CameraComponent>();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
|
|||
|
||||
DrawComponent<TransformComponent>(
|
||||
"Transform Component",
|
||||
m_EntityContext,
|
||||
m_entity_context,
|
||||
[&](auto &transformComponent) {
|
||||
DrawVec3Control("Translation", transformComponent.translation);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
|
|||
|
||||
DrawComponent<SpriteRendererComponent>(
|
||||
"SpriteRenderer Component",
|
||||
m_EntityContext,
|
||||
m_entity_context,
|
||||
[&](auto &spriteRendererComponent) {
|
||||
ImGui::ColorEdit4("Color", &spriteRendererComponent.tint[0]);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
|
|||
|
||||
DrawComponent<CameraComponent>(
|
||||
"Camera Component",
|
||||
m_EntityContext,
|
||||
m_entity_context,
|
||||
[&](auto &cameraComponent) {
|
||||
auto &camera = cameraComponent.camera;
|
||||
|
||||
|
@ -147,7 +147,7 @@ void PropertiesPanel::OnUserInterfaceUpdate()
|
|||
|
||||
void PropertiesPanel::SetEntityContext(Entity entity)
|
||||
{
|
||||
m_EntityContext = entity;
|
||||
m_entity_context = entity;
|
||||
}
|
||||
|
||||
void PropertiesPanel::DrawVec3Control(
|
||||
|
|
|
@ -7,28 +7,28 @@
|
|||
namespace Light {
|
||||
|
||||
SceneHierarchyPanel::SceneHierarchyPanel()
|
||||
: m_Context(nullptr)
|
||||
, m_PropertiesPanelContext(nullptr)
|
||||
, m_SelectionContext()
|
||||
: m_context(nullptr)
|
||||
, m_properties_panel_context(nullptr)
|
||||
, m_selection_context()
|
||||
{
|
||||
}
|
||||
|
||||
SceneHierarchyPanel::
|
||||
SceneHierarchyPanel(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel /* = nullptr */)
|
||||
: m_Context(context)
|
||||
, m_PropertiesPanelContext(propertiesPanel)
|
||||
: m_context(context)
|
||||
, m_properties_panel_context(propertiesPanel)
|
||||
{
|
||||
}
|
||||
|
||||
void SceneHierarchyPanel::OnUserInterfaceUpdate()
|
||||
{
|
||||
if (m_Context)
|
||||
if (m_context)
|
||||
{
|
||||
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>();
|
||||
|
||||
DrawNode(entity, tag);
|
||||
|
@ -42,22 +42,22 @@ void SceneHierarchyPanel::
|
|||
SetContext(Ref<Scene> context, Ref<PropertiesPanel> propertiesPanel /* = nullptr */)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ImGuiTreeNodeFlags flags = (m_SelectionContext == entity ? ImGuiTreeNodeFlags_Selected : NULL)
|
||||
ImGuiTreeNodeFlags flags = (m_selection_context == entity ? ImGuiTreeNodeFlags_Selected : NULL)
|
||||
| ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth;
|
||||
|
||||
bool expanded = ImGui::TreeNodeEx((void *)(uint64_t)(uint32_t)(entity), flags, label.c_str());
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
m_SelectionContext = entity;
|
||||
m_PropertiesPanelContext->SetEntityContext(entity);
|
||||
m_selection_context = entity;
|
||||
m_properties_panel_context->SetEntityContext(entity);
|
||||
}
|
||||
|
||||
if (expanded)
|
||||
|
|
Loading…
Add table
Reference in a new issue