add ApplicationSpecification
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
|
||||
#include "Hazel/Core/Application.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <Hazel/Debug/Instrumentor.h>
|
||||
#include <SDL3/SDL.h>
|
||||
@ -14,17 +15,19 @@ namespace Hazel {
|
||||
Application* Application::s_Instance = nullptr;
|
||||
|
||||
|
||||
Application::Application(const std::string& name, int width, int height)
|
||||
Application::Application(const ApplicationSpecification& specification)
|
||||
: m_Specification(specification)
|
||||
{
|
||||
HZ_PROFILE_FUNCTION();
|
||||
|
||||
if (s_Instance != nullptr)
|
||||
{
|
||||
HZ_CORE_ERROR("Application already exists!");
|
||||
}
|
||||
s_Instance = this;
|
||||
|
||||
m_Window = Window::Create(WindowProps(name, width, height));
|
||||
if (!m_Specification.workingDirectory.empty())
|
||||
std::filesystem::current_path(m_Specification.workingDirectory);
|
||||
|
||||
m_Window = Window::Create(WindowProps(m_Specification.name));
|
||||
m_Window->SetEventCallback(std::bind(&Application::OnEvent, this, std::placeholders::_1));
|
||||
m_Window->SetWindowResizeEventCallback(std::bind(&Application::OnWindowResize, this, std::placeholders::_1));
|
||||
|
||||
|
||||
@ -5,15 +5,37 @@
|
||||
#include "Core.h"
|
||||
#include "Layer.h"
|
||||
#include "LayerStack.h"
|
||||
#include "Log.h"
|
||||
#include "Hazel/Core/TimeStep.h"
|
||||
#include "Hazel/ImGui/ImGuiLayer.h"
|
||||
|
||||
namespace Hazel {
|
||||
|
||||
struct ApplicationCommandLineArgs
|
||||
{
|
||||
int count = 0;
|
||||
char** args = nullptr;
|
||||
|
||||
const char* operator[](int index)
|
||||
{
|
||||
if (index >= count)
|
||||
HZ_CORE_ERROR("args error");
|
||||
return args[count];
|
||||
}
|
||||
};
|
||||
|
||||
struct ApplicationSpecification
|
||||
{
|
||||
std::string name = "Application";
|
||||
std::string workingDirectory;
|
||||
ApplicationCommandLineArgs commandLineArgs;
|
||||
|
||||
};
|
||||
|
||||
class HAZEL_API Application
|
||||
{
|
||||
public:
|
||||
Application(const std::string& name = "Hazel App", int width = 1280, int height = 720);
|
||||
Application(const ApplicationSpecification& specification);
|
||||
virtual ~Application();
|
||||
|
||||
void Run();
|
||||
@ -30,7 +52,10 @@ namespace Hazel {
|
||||
inline Window& GetWindow() const { return *m_Window; }
|
||||
inline static Application& Get() { return *s_Instance; }
|
||||
|
||||
const ApplicationSpecification& GetSpecification() const { return m_Specification; }
|
||||
|
||||
private:
|
||||
ApplicationSpecification m_Specification;
|
||||
Scope<Window> m_Window;
|
||||
ImGuiLayer* m_imguiLayer;
|
||||
bool m_Running = true;
|
||||
@ -46,6 +71,6 @@ namespace Hazel {
|
||||
};
|
||||
|
||||
// to be defined int CLIENT
|
||||
Application* CreateApplication();
|
||||
Application* CreateApplication(ApplicationCommandLineArgs args);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user