Skip to content

Commit

Permalink
Added Arcane Namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tomheeleynz committed Jul 22, 2021
1 parent 36573b3 commit c48eec9
Show file tree
Hide file tree
Showing 55 changed files with 1,848 additions and 1,649 deletions.
120 changes: 61 additions & 59 deletions Arcane/src/Arcane/Core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,69 @@
#include "Renderer/Pipeline.h"
#include "Renderer/RenderPass.h"

Application* Application::s_Instance = nullptr;

Application::Application(ApplicationSpecifications& specifications)
{
WindowSpecifications windowSpecifications;
windowSpecifications.Height = specifications.WindowHeight;
windowSpecifications.Width = specifications.WindowWidth;
windowSpecifications.Title = specifications.Name;

s_Instance = this;

m_Window = new Window(windowSpecifications);
m_Window->Init();

Renderer::Init();

m_ImGuiLayer = ImGuiLayer::Create();
m_ImGuiLayer->OnAttach();
}

void Application::RenderImGui()
{
m_ImGuiLayer->Begin();

for (Layer* layer : m_LayerStack)
layer->OnImGuiRender();
}

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

Application& Application::Get()
{
return *s_Instance;
}

void Application::PushLayer(Layer* _layer)
{
_layer->OnAttach();
m_LayerStack.push_back(_layer);
}

Window& Application::GetWindow()
{
return *m_Window;
}

void Application::Run()
{
while (m_bIsRunning)
namespace Arcane {
Application* Application::s_Instance = nullptr;

Application::Application(ApplicationSpecifications& specifications)
{
for (Layer* layer : m_LayerStack) {
layer->OnUpdate(1.0f);
}
WindowSpecifications windowSpecifications;
windowSpecifications.Height = specifications.WindowHeight;
windowSpecifications.Width = specifications.WindowWidth;
windowSpecifications.Title = specifications.Name;

s_Instance = this;

m_Window = new Window(windowSpecifications);
m_Window->Init();

Renderer::Init();

m_ImGuiLayer = ImGuiLayer::Create();
m_ImGuiLayer->OnAttach();
}

void Application::RenderImGui()
{
m_ImGuiLayer->Begin();

for (Layer* layer : m_LayerStack)
layer->OnImGuiRender();
}

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

RenderImGui();
m_ImGuiLayer->End();
Application& Application::Get()
{
return *s_Instance;
}

m_Window->ProcessEvents();
m_Window->SwapBuffers();
void Application::PushLayer(Layer* _layer)
{
_layer->OnAttach();
m_LayerStack.push_back(_layer);
}

Window& Application::GetWindow()
{
return *m_Window;
}

void Application::Run()
{
while (m_bIsRunning)
{
for (Layer* layer : m_LayerStack) {
layer->OnUpdate(1.0f);
}

RenderImGui();
m_ImGuiLayer->End();

m_Window->ProcessEvents();
m_Window->SwapBuffers();
}
}
}
70 changes: 37 additions & 33 deletions Arcane/src/Arcane/Core/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,40 @@
#include "Window.h"
#include "ImGui/ImGuiLayer.h"

struct ApplicationSpecifications
{
std::string Name;
uint32_t WindowWidth;
uint32_t WindowHeight;
};

class Application
{
public:
Application(ApplicationSpecifications& specifications);
~Application();

void Run();

// Get Reference To Window
Window& GetWindow();

// Get Static Application Reference
static Application& Get();

// Push Layer
void PushLayer(Layer* _layer);

// ImGui
void RenderImGui();
private:
Window* m_Window;
static Application* s_Instance;
std::vector<Layer*> m_LayerStack;
bool m_bIsRunning = true;
ImGuiLayer* m_ImGuiLayer;
};

namespace Arcane {

struct ApplicationSpecifications
{
std::string Name;
uint32_t WindowWidth;
uint32_t WindowHeight;
};

class Application
{
public:
Application(ApplicationSpecifications& specifications);
~Application();

void Run();

// Get Reference To Window
Window& GetWindow();

// Get Static Application Reference
static Application& Get();

// Push Layer
void PushLayer(Layer* _layer);

// ImGui
void RenderImGui();
private:
Window* m_Window;
static Application* s_Instance;
std::vector<Layer*> m_LayerStack;
bool m_bIsRunning = true;
ImGuiLayer* m_ImGuiLayer;
};
}
22 changes: 12 additions & 10 deletions Arcane/src/Arcane/Core/Layer.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#pragma once

class Layer
{
public:
Layer() {};
namespace Arcane {
class Layer
{
public:
Layer() {};

virtual void OnAttach() {}
virtual void OnDetach() {}
virtual void OnAttach() {}
virtual void OnDetach() {}

virtual void OnUpdate(float deltaTime) {}
virtual void OnImGuiRender() {}
private:
virtual void OnUpdate(float deltaTime) {}
virtual void OnImGuiRender() {}
private:

};
};
}
68 changes: 35 additions & 33 deletions Arcane/src/Arcane/Core/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
#include "Window.h"
#include "Renderer/GraphicsContext.h"

Window::Window(WindowSpecifications& specifications)
{
// Window Data
m_Data.Title = specifications.Title;
m_Data.Width = specifications.Width;
m_Data.Height = specifications.Height;
}

void Window::Init()
{
glfwInit();

glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);

m_Window = glfwCreateWindow(m_Data.Width, m_Data.Height, m_Data.Title.c_str(), nullptr, nullptr);

m_Context = GraphicsContext::Create();
}

void Window::ProcessEvents()
{
glfwPollEvents();
}

void Window::SwapBuffers()
{
m_Context->SwapBuffers();
}

void* Window::GetNativeWindow()
{
return (void*)m_Window;
}
namespace Arcane {
Window::Window(WindowSpecifications& specifications)
{
// Window Data
m_Data.Title = specifications.Title;
m_Data.Width = specifications.Width;
m_Data.Height = specifications.Height;
}

void Window::Init()
{
glfwInit();

glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);

m_Window = glfwCreateWindow(m_Data.Width, m_Data.Height, m_Data.Title.c_str(), nullptr, nullptr);

m_Context = GraphicsContext::Create();
}

void Window::ProcessEvents()
{
glfwPollEvents();
}

void Window::SwapBuffers()
{
m_Context->SwapBuffers();
}

void* Window::GetNativeWindow()
{
return (void*)m_Window;
}
}
55 changes: 29 additions & 26 deletions Arcane/src/Arcane/Core/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@
#include <GLFW/glfw3.h>
#include <string>

struct WindowSpecifications
namespace Arcane
{
std::string Title;
uint32_t Width;
uint32_t Height;
};

class GraphicsContext;

class Window
{
public:
Window(WindowSpecifications& specifications);

void ProcessEvents();
void SwapBuffers();

void* GetNativeWindow();
void Init();

GraphicsContext* GetContext() { return m_Context; }
private:
struct WindowData
struct WindowSpecifications
{
std::string Title;
uint32_t Width;
uint32_t Height;
};

WindowData m_Data;
GLFWwindow* m_Window;
class GraphicsContext;

GraphicsContext* m_Context;
};
class Window
{
public:
Window(WindowSpecifications& specifications);

void ProcessEvents();
void SwapBuffers();

void* GetNativeWindow();
void Init();

GraphicsContext* GetContext() { return m_Context; }
private:
struct WindowData
{
std::string Title;
uint32_t Width;
uint32_t Height;
};

WindowData m_Data;
GLFWwindow* m_Window;

GraphicsContext* m_Context;
};
}
14 changes: 8 additions & 6 deletions Arcane/src/Arcane/ImGui/ImGuiLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
// -- Vulkan
#include "Platform/Vulkan/VulkanImGuiLayer.h"

ImGuiLayer* ImGuiLayer::Create()
{
switch (RendererAPI::Current())
namespace Arcane {
ImGuiLayer* ImGuiLayer::Create()
{
case RendererAPIType::Vulkan: return new VulkanImGuiLayer();
case RendererAPIType::None: return nullptr;
default: return nullptr;
switch (RendererAPI::Current())
{
case RendererAPIType::Vulkan: return new VulkanImGuiLayer();
case RendererAPIType::None: return nullptr;
default: return nullptr;
}
}
}

0 comments on commit c48eec9

Please sign in to comment.