Skip to content
Permalink
Browse files

Code maintenance (#165)

- Convert smart pointers to Hazel wrappers: (Create)Scope and (Create)Ref
- Removing all DLL traces (removing all HAZEL_API macros)
- Fixing include statements:
      -> All includes relative to `Hazel/src`
      -> All external includes use `<>` instead of `""`
- Use default (de)constructor instead of an empty one
- Removed the dedicated (duplicate) `BIND_EVENT_FN` in application
- Removed obsolete logging messages in glfw
- Removed obsolete YAML keys in PR template
- Call Renderer2D::Shutdown() to free memory from allocated Renderer2DStorage
- Removed traces of OpenGL in the main Renderer and in Sandbox/ExampleLayer
  • Loading branch information
LovelySanta committed Nov 11, 2019
1 parent 8c35857 commit ccccfdca228c33ab89448239694b7f992b029f15
Showing with 209 additions and 197 deletions.
  1. +0 −6 .github/PULL_REQUEST_TEMPLATE.md
  2. +2 −0 Hazel/src/Hazel.h
  3. +12 −10 Hazel/src/Hazel/Core/Application.cpp
  4. +3 −3 Hazel/src/Hazel/Core/Application.h
  5. +0 −16 Hazel/src/Hazel/Core/Core.h
  6. +2 −1 Hazel/src/Hazel/Core/EntryPoint.h
  7. +1 −1 Hazel/src/Hazel/Core/Input.h
  8. +1 −1 Hazel/src/Hazel/Core/Layer.cpp
  9. +1 −1 Hazel/src/Hazel/Core/Layer.h
  10. +1 −5 Hazel/src/Hazel/Core/LayerStack.cpp
  11. +3 −3 Hazel/src/Hazel/Core/LayerStack.h
  12. +4 −4 Hazel/src/Hazel/Core/Log.cpp
  13. +9 −8 Hazel/src/Hazel/Core/Log.h
  14. +2 −2 Hazel/src/Hazel/Core/Window.h
  15. +10 −10 Hazel/src/Hazel/Events/ApplicationEvent.h
  16. +2 −2 Hazel/src/Hazel/Events/Event.h
  17. +5 −5 Hazel/src/Hazel/Events/KeyEvent.h
  18. +6 −6 Hazel/src/Hazel/Events/MouseEvent.h
  19. +2 −2 Hazel/src/Hazel/ImGui/ImGuiBuild.cpp
  20. +4 −4 Hazel/src/Hazel/ImGui/ImGuiLayer.cpp
  21. +1 −1 Hazel/src/Hazel/ImGui/ImGuiLayer.h
  22. +6 −6 Hazel/src/Hazel/Renderer/Buffer.cpp
  23. +2 −2 Hazel/src/Hazel/Renderer/Buffer.h
  24. +21 −0 Hazel/src/Hazel/Renderer/GraphicsContext.cpp
  25. +2 −0 Hazel/src/Hazel/Renderer/GraphicsContext.h
  26. +1 −1 Hazel/src/Hazel/Renderer/OrthographicCamera.cpp
  27. +1 −1 Hazel/src/Hazel/Renderer/OrthographicCameraController.cpp
  28. +2 −4 Hazel/src/Hazel/Renderer/RenderCommand.cpp
  29. +2 −2 Hazel/src/Hazel/Renderer/RenderCommand.h
  30. +10 −7 Hazel/src/Hazel/Renderer/Renderer.cpp
  31. +6 −4 Hazel/src/Hazel/Renderer/Renderer.h
  32. +6 −8 Hazel/src/Hazel/Renderer/Renderer2D.cpp
  33. +2 −2 Hazel/src/Hazel/Renderer/Renderer2D.h
  34. +15 −1 Hazel/src/Hazel/Renderer/RendererAPI.cpp
  35. +4 −2 Hazel/src/Hazel/Renderer/RendererAPI.h
  36. +4 −4 Hazel/src/Hazel/Renderer/Shader.cpp
  37. +2 −2 Hazel/src/Hazel/Renderer/Texture.cpp
  38. +3 −3 Hazel/src/Hazel/Renderer/VertexArray.cpp
  39. +4 −4 Hazel/src/Hazel/Renderer/VertexArray.h
  40. +1 −1 Hazel/src/Platform/OpenGL/OpenGLBuffer.cpp
  41. +1 −1 Hazel/src/Platform/OpenGL/OpenGLContext.cpp
  42. +2 −2 Hazel/src/Platform/OpenGL/OpenGLRendererAPI.cpp
  43. +1 −1 Hazel/src/Platform/OpenGL/OpenGLRendererAPI.h
  44. +1 −1 Hazel/src/Platform/OpenGL/OpenGLShader.cpp
  45. +2 −2 Hazel/src/Platform/OpenGL/OpenGLTexture.cpp
  46. +14 −14 Hazel/src/Platform/OpenGL/OpenGLVertexArray.cpp
  47. +6 −6 Hazel/src/Platform/OpenGL/OpenGLVertexArray.h
  48. +1 −1 Hazel/src/Platform/Windows/WindowsInput.cpp
  49. +6 −8 Hazel/src/Platform/Windows/WindowsWindow.cpp
  50. +1 −1 Sandbox/src/Sandbox2D.cpp
  51. +9 −15 Sandbox/src/SandboxApp.cpp
@@ -1,9 +1,3 @@
---
name: 'Pull Request'
about: Propose a fix for a (small) issue in Hazel

---

#### Describe the issue (if no issue has been made)
A clear and concise description of what the issue is. Explain the difference between the expected and the current behavior.
A screenshot or copy of the error could be helpful as well.
@@ -2,6 +2,8 @@

// For use by Hazel applications

#include "Hazel/Core/Core.h"

#include "Hazel/Core/Application.h"
#include "Hazel/Core/Layer.h"
#include "Hazel/Core/Log.h"
@@ -1,34 +1,36 @@
#include "hzpch.h"
#include "Application.h"
#include "Hazel/Core/Application.h"

#include "Hazel/Core/Log.h"

#include "Hazel/Renderer/Renderer.h"

#include "Input.h"
#include "Hazel/Core/Input.h"

#include <glfw/glfw3.h>

namespace Hazel {

#define BIND_EVENT_FN(x) std::bind(&Application::x, this, std::placeholders::_1)

Application* Application::s_Instance = nullptr;

Application::Application()
{
HZ_CORE_ASSERT(!s_Instance, "Application already exists!");
s_Instance = this;

m_Window = std::unique_ptr<Window>(Window::Create());
m_Window->SetEventCallback(BIND_EVENT_FN(OnEvent));
m_Window = Window::Create();
m_Window->SetEventCallback(HZ_BIND_EVENT_FN(Application::OnEvent));

Renderer::Init();

m_ImGuiLayer = new ImGuiLayer();
PushOverlay(m_ImGuiLayer);
}

Application::~Application()
{
Renderer::Shutdown();
}

void Application::PushLayer(Layer* layer)
{
m_LayerStack.PushLayer(layer);
@@ -42,8 +44,8 @@ namespace Hazel {
void Application::OnEvent(Event& e)
{
EventDispatcher dispatcher(e);
dispatcher.Dispatch<WindowCloseEvent>(BIND_EVENT_FN(OnWindowClose));
dispatcher.Dispatch<WindowResizeEvent>(BIND_EVENT_FN(OnWindowResize));
dispatcher.Dispatch<WindowCloseEvent>(HZ_BIND_EVENT_FN(Application::OnWindowClose));
dispatcher.Dispatch<WindowResizeEvent>(HZ_BIND_EVENT_FN(Application::OnWindowResize));

for (auto it = m_LayerStack.end(); it != m_LayerStack.begin(); )
{
@@ -96,4 +98,4 @@ namespace Hazel {
return false;
}

}
}
@@ -1,8 +1,8 @@
#pragma once

#include "Core.h"
#include "Hazel/Core/Core.h"

#include "Window.h"
#include "Hazel/Core/Window.h"
#include "Hazel/Core/LayerStack.h"
#include "Hazel/Events/Event.h"
#include "Hazel/Events/ApplicationEvent.h"
@@ -17,7 +17,7 @@ namespace Hazel {
{
public:
Application();
virtual ~Application() = default;
virtual ~Application();

void Run();

@@ -43,22 +43,6 @@
#error "Unknown platform!"
#endif // End of platform detection


// DLL support
#ifdef HZ_PLATFORM_WINDOWS
#if HZ_DYNAMIC_LINK
#ifdef HZ_BUILD_DLL
#define HAZEL_API __declspec(dllexport)
#else
#define HAZEL_API __declspec(dllimport)
#endif
#else
#define HAZEL_API
#endif
#else
#error Hazel only supports Windows!
#endif // End of DLL support

#ifdef HZ_DEBUG
#define HZ_ENABLE_ASSERTS
#endif
@@ -1,4 +1,5 @@
#pragma once
#include "Hazel/Core/Core.h"

#ifdef HZ_PLATFORM_WINDOWS

@@ -16,4 +17,4 @@ int main(int argc, char** argv)
delete app;
}

#endif
#endif
@@ -4,7 +4,7 @@

namespace Hazel {

class HAZEL_API Input
class Input
{
protected:
Input() = default;
@@ -1,5 +1,5 @@
#include "hzpch.h"
#include "Layer.h"
#include "Hazel/Core/Layer.h"

namespace Hazel {

@@ -6,7 +6,7 @@

namespace Hazel {

class HAZEL_API Layer
class Layer
{
public:
Layer(const std::string& name = "Layer");
@@ -1,12 +1,8 @@
#include "hzpch.h"
#include "LayerStack.h"
#include "Hazel/Core/LayerStack.h"

namespace Hazel {

LayerStack::LayerStack()
{
}

LayerStack::~LayerStack()
{
for (Layer* layer : m_Layers)
@@ -1,16 +1,16 @@
#pragma once

#include "Hazel/Core/Core.h"
#include "Layer.h"
#include "Hazel/Core/Layer.h"

#include <vector>

namespace Hazel {

class HAZEL_API LayerStack
class LayerStack
{
public:
LayerStack();
LayerStack() = default;
~LayerStack();

void PushLayer(Layer* layer);
@@ -1,12 +1,12 @@
#include "hzpch.h"
#include "Log.h"
#include "Hazel/Core/Log.h"

#include "spdlog/sinks/stdout_color_sinks.h"
#include <spdlog/sinks/stdout_color_sinks.h>

namespace Hazel {

std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
std::shared_ptr<spdlog::logger> Log::s_ClientLogger;
Ref<spdlog::logger> Log::s_CoreLogger;
Ref<spdlog::logger> Log::s_ClientLogger;

void Log::Init()
{
@@ -1,21 +1,22 @@
#pragma once

#include "Core.h"
#include "spdlog/spdlog.h"
#include "spdlog/fmt/ostr.h"
#include "Hazel/Core/Core.h"

#include <spdlog/spdlog.h>
#include <spdlog/fmt/ostr.h>

namespace Hazel {

class HAZEL_API Log
class Log
{
public:
static void Init();

inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
inline static Ref<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
inline static Ref<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
private:
static std::shared_ptr<spdlog::logger> s_CoreLogger;
static std::shared_ptr<spdlog::logger> s_ClientLogger;
static Ref<spdlog::logger> s_CoreLogger;
static Ref<spdlog::logger> s_ClientLogger;
};

}
@@ -22,7 +22,7 @@ namespace Hazel {
};

// Interface representing a desktop system based Window
class HAZEL_API Window
class Window
{
public:
using EventCallbackFn = std::function<void(Event&)>;
@@ -41,7 +41,7 @@ namespace Hazel {

virtual void* GetNativeWindow() const = 0;

static Window* Create(const WindowProps& props = WindowProps());
static Scope<Window> Create(const WindowProps& props = WindowProps());
};

}
@@ -1,10 +1,10 @@
#pragma once

#include "Event.h"
#include "Hazel/Events/Event.h"

namespace Hazel {

class HAZEL_API WindowResizeEvent : public Event
class WindowResizeEvent : public Event
{
public:
WindowResizeEvent(unsigned int width, unsigned int height)
@@ -26,37 +26,37 @@ namespace Hazel {
unsigned int m_Width, m_Height;
};

class HAZEL_API WindowCloseEvent : public Event
class WindowCloseEvent : public Event
{
public:
WindowCloseEvent() {}
WindowCloseEvent() = default;

EVENT_CLASS_TYPE(WindowClose)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
};

class HAZEL_API AppTickEvent : public Event
class AppTickEvent : public Event
{
public:
AppTickEvent() {}
AppTickEvent() = default;

EVENT_CLASS_TYPE(AppTick)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
};

class HAZEL_API AppUpdateEvent : public Event
class AppUpdateEvent : public Event
{
public:
AppUpdateEvent() {}
AppUpdateEvent() = default;

EVENT_CLASS_TYPE(AppUpdate)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
};

class HAZEL_API AppRenderEvent : public Event
class AppRenderEvent : public Event
{
public:
AppRenderEvent() {}
AppRenderEvent() = default;

EVENT_CLASS_TYPE(AppRender)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
@@ -1,6 +1,6 @@
#pragma once

#include "hzpch.h"

#include "Hazel/Core/Core.h"

namespace Hazel {
@@ -35,7 +35,7 @@ namespace Hazel {

#define EVENT_CLASS_CATEGORY(category) virtual int GetCategoryFlags() const override { return category; }

class HAZEL_API Event
class Event
{
public:
bool Handled = false;
@@ -1,10 +1,10 @@
#pragma once

#include "Event.h"
#include "Hazel/Events/Event.h"

namespace Hazel {

class HAZEL_API KeyEvent : public Event
class KeyEvent : public Event
{
public:
inline int GetKeyCode() const { return m_KeyCode; }
@@ -17,7 +17,7 @@ namespace Hazel {
int m_KeyCode;
};

class HAZEL_API KeyPressedEvent : public KeyEvent
class KeyPressedEvent : public KeyEvent
{
public:
KeyPressedEvent(int keycode, int repeatCount)
@@ -37,7 +37,7 @@ namespace Hazel {
int m_RepeatCount;
};

class HAZEL_API KeyReleasedEvent : public KeyEvent
class KeyReleasedEvent : public KeyEvent
{
public:
KeyReleasedEvent(int keycode)
@@ -53,7 +53,7 @@ namespace Hazel {
EVENT_CLASS_TYPE(KeyReleased)
};

class HAZEL_API KeyTypedEvent : public KeyEvent
class KeyTypedEvent : public KeyEvent
{
public:
KeyTypedEvent(int keycode)

0 comments on commit ccccfdc

Please sign in to comment.
You can’t perform that action at this time.