Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TheCherno/Hazel
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCherno committed Nov 14, 2019
2 parents fdafade + 6e84e8d commit f6d5c00
Show file tree
Hide file tree
Showing 51 changed files with 222 additions and 202 deletions.
6 changes: 0 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions Hazel/src/Hazel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 12 additions & 10 deletions Hazel/src/Hazel/Core/Application.cpp
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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(); )
{
Expand Down Expand Up @@ -96,4 +98,4 @@ namespace Hazel {
return false;
}

}
}
6 changes: 3 additions & 3 deletions Hazel/src/Hazel/Core/Application.h
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -17,7 +17,7 @@ namespace Hazel {
{
public:
Application();
virtual ~Application() = default;
virtual ~Application();

void Run();

Expand Down
16 changes: 0 additions & 16 deletions Hazel/src/Hazel/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Hazel/src/Hazel/Core/EntryPoint.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "Hazel/Core/Core.h"

#ifdef HZ_PLATFORM_WINDOWS

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

#endif
#endif
2 changes: 1 addition & 1 deletion Hazel/src/Hazel/Core/Input.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Hazel {

class HAZEL_API Input
class Input
{
protected:
Input() = default;
Expand Down
2 changes: 1 addition & 1 deletion Hazel/src/Hazel/Core/Layer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "hzpch.h"
#include "Layer.h"
#include "Hazel/Core/Layer.h"

namespace Hazel {

Expand Down
2 changes: 1 addition & 1 deletion Hazel/src/Hazel/Core/Layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Hazel {

class HAZEL_API Layer
class Layer
{
public:
Layer(const std::string& name = "Layer");
Expand Down
6 changes: 1 addition & 5 deletions Hazel/src/Hazel/Core/LayerStack.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Hazel/src/Hazel/Core/LayerStack.h
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
8 changes: 4 additions & 4 deletions Hazel/src/Hazel/Core/Log.cpp
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down
17 changes: 9 additions & 8 deletions Hazel/src/Hazel/Core/Log.h
Original file line number Diff line number Diff line change
@@ -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;
};

}
Expand Down
4 changes: 2 additions & 2 deletions Hazel/src/Hazel/Core/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&)>;
Expand All @@ -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());
};

}
20 changes: 10 additions & 10 deletions Hazel/src/Hazel/Events/ApplicationEvent.h
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Hazel/src/Hazel/Events/Event.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "hzpch.h"

#include "Hazel/Core/Core.h"

namespace Hazel {
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions Hazel/src/Hazel/Events/KeyEvent.h
Original file line number Diff line number Diff line change
@@ -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; }
Expand All @@ -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)
Expand All @@ -37,7 +37,7 @@ namespace Hazel {
int m_RepeatCount;
};

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

class HAZEL_API KeyTypedEvent : public KeyEvent
class KeyTypedEvent : public KeyEvent
{
public:
KeyTypedEvent(int keycode)
Expand Down
Loading

0 comments on commit f6d5c00

Please sign in to comment.