add simple runtime; fix the issue of crashing when creating file and folder; some tweaks
This commit is contained in:
11
PrismRuntime/CMakeLists.txt
Normal file
11
PrismRuntime/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
project(PrismRuntime)
|
||||
|
||||
file(GLOB_RECURSE SRC_SOURCE ./PrismRuntime/**.cpp)
|
||||
|
||||
add_executable(${PROJECT_NAME} WIN32 ${SRC_SOURCE})
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE PRISM_GUI)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Prism-static)
|
||||
|
||||
|
||||
add_executable(${PROJECT_NAME}-Console ${SRC_SOURCE})
|
||||
target_link_libraries(${PROJECT_NAME}-Console PRIVATE Prism-static)
|
||||
63
PrismRuntime/PrismRuntime/PrismRuntime.cpp
Normal file
63
PrismRuntime/PrismRuntime/PrismRuntime.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Created by Atdunbg on 2026/3/23.
|
||||
//
|
||||
|
||||
#include "PrismRuntime.h"
|
||||
|
||||
#include "Prism/Renderer/Renderer.h"
|
||||
#include "Prism/Renderer/SceneRenderer.h"
|
||||
#include "Prism/Scene/SceneSerializer.h"
|
||||
|
||||
|
||||
void PrismRuntime::OnAttach()
|
||||
{
|
||||
PM_CLIENT_INFO("App init");
|
||||
|
||||
AppInstance = &Prism::Application::Get();
|
||||
|
||||
PM_CLIENT_INFO("Create Scene");
|
||||
const Prism::Ref<Prism::Scene> newScene = Prism::Ref<Prism::Scene>::Create("runtime Scene", false, true);
|
||||
Prism::SceneSerializer serializer(newScene);
|
||||
|
||||
const char* scenePath = "assets/scenes/FPS.scene";
|
||||
PM_CLIENT_INFO("loading Scene: ", scenePath);
|
||||
serializer.Deserialize(scenePath);
|
||||
|
||||
m_CurrentScene = newScene;
|
||||
|
||||
const glm::ivec2 windowSize = AppInstance->GetWindow().GetSize();
|
||||
if (m_CurrentScene && windowSize.x > 0 && windowSize.y > 0)
|
||||
{
|
||||
Prism::SceneRenderer::SetViewportSize(windowSize.x, windowSize.y);
|
||||
m_CurrentScene->SetViewportSize(windowSize);
|
||||
}
|
||||
|
||||
PM_CLIENT_INFO("Scene Start");
|
||||
m_CurrentScene->OnRuntimeStart();
|
||||
}
|
||||
|
||||
void PrismRuntime::OnDetach()
|
||||
{
|
||||
PM_CLIENT_INFO("Scene Shutdown");
|
||||
m_CurrentScene->OnShutdown();
|
||||
}
|
||||
|
||||
void PrismRuntime::OnUpdate(const Prism::TimeStep deltaTime)
|
||||
{
|
||||
m_CurrentScene->OnUpdate(deltaTime);
|
||||
m_CurrentScene->OnRenderRuntime(deltaTime);
|
||||
|
||||
const glm::vec2 windowSize = AppInstance->GetWindow().GetSize();
|
||||
if (m_CurrentScene && windowSize.x > 0 && windowSize.y > 0)
|
||||
{
|
||||
m_CurrentScene->SetViewportSize(windowSize);
|
||||
}
|
||||
}
|
||||
|
||||
void PrismRuntime::OnEvent(Prism::Event& e)
|
||||
{
|
||||
}
|
||||
|
||||
void PrismRuntime::OnImGuiRender()
|
||||
{
|
||||
}
|
||||
30
PrismRuntime/PrismRuntime/PrismRuntime.h
Normal file
30
PrismRuntime/PrismRuntime/PrismRuntime.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by Atdunbg on 2026/3/23.
|
||||
//
|
||||
|
||||
#ifndef PRISM_PRISMRUNTIME_H
|
||||
#define PRISM_PRISMRUNTIME_H
|
||||
#include "Prism/Core/Application.h"
|
||||
#include "Prism/Core/Layer.h"
|
||||
#include "Prism/Scene/Scene.h"
|
||||
|
||||
|
||||
class PrismRuntime : public Prism::Layer
|
||||
{
|
||||
public:
|
||||
void OnAttach() override;
|
||||
void OnDetach() override;
|
||||
|
||||
void OnUpdate(Prism::TimeStep deltaTime) override;
|
||||
void OnEvent(Prism::Event& e) override;
|
||||
void OnImGuiRender() override;
|
||||
|
||||
|
||||
private:
|
||||
Prism::Ref<Prism::Scene> m_CurrentScene;
|
||||
|
||||
Prism::Application* AppInstance = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif //PRISM_PRISMRUNTIME_H
|
||||
25
PrismRuntime/PrismRuntime/PrismRuntimeApp.cpp
Normal file
25
PrismRuntime/PrismRuntime/PrismRuntimeApp.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Atdunbg on 2026/3/23.
|
||||
//
|
||||
#include "Prism.h"
|
||||
#include "PrismRuntime.h"
|
||||
#include "Prism/Core/EntryPoint.h"
|
||||
|
||||
class PrismRuntimeApp : public Prism::Application
|
||||
{
|
||||
public:
|
||||
explicit PrismRuntimeApp(const Prism::ApplicationProps& props)
|
||||
: Application(props)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void OnInit() override
|
||||
{
|
||||
PushLayer(new PrismRuntime());
|
||||
}
|
||||
};
|
||||
|
||||
Prism::Application* Prism::CreateApplication(const CommandArgs args)
|
||||
{
|
||||
return new PrismRuntimeApp({"Game", 1920, 1080, args});
|
||||
}
|
||||
Reference in New Issue
Block a user