fix: alot of stuff changed. Mostly bugfixxes / architechture changes
This commit is contained in:
@@ -30,6 +30,12 @@ LightKeeper::LightKeeper() : App()
|
||||
|
||||
LightKeeper::~LightKeeper()
|
||||
{
|
||||
if (!cleanedUp) {
|
||||
try {
|
||||
cleanup();
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LightKeeper::customInit()
|
||||
@@ -442,8 +448,11 @@ void LightKeeper::customInit()
|
||||
|
||||
void LightKeeper::customUpdate(float dt)
|
||||
{
|
||||
// LightKeeper owns a camera that hides App::camera; update this instance
|
||||
// after SDL events have been consumed.
|
||||
camera.Update(dt);
|
||||
SceneManager::GetInstance().Update();
|
||||
SceneManager::GetInstance().Update(dt);
|
||||
SceneManager::GetInstance().LateUpdate(dt);
|
||||
|
||||
if (InputManager::GetInstance().WasKeyPressed(SDL_SCANCODE_1))
|
||||
{
|
||||
@@ -462,17 +471,22 @@ void LightKeeper::customUpdate(float dt)
|
||||
meshRenderComp->SetMaterialID(sphereMaterial);
|
||||
meshRenderComp->SetMeshID(sphereMesh);
|
||||
|
||||
sphere->GetTransform().SetWorldPosition(0, 100, 0);
|
||||
sphere->GetTransform().SetWorldPosition((std::rand() % 2) - 0.5f, 100, (std::rand() % 2) - 0.5f);
|
||||
sphere->GetTransform().SetWorldScale(glm::vec3{0.015f});
|
||||
|
||||
|
||||
SceneManager::GetInstance().GetCurrentScene().GetPhysics().RegisterGameObject(*sphere);
|
||||
SceneManager::GetInstance().GetCurrentScene().GetPhysics().RefreshGameObject(*sphere);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void LightKeeper::customDraw()
|
||||
{
|
||||
const auto cmd = gfxDevice.beginFrame();
|
||||
if (cmd == VK_NULL_HANDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
renderer.beginDrawing(gfxDevice);
|
||||
|
||||
const RenderContext ctx{
|
||||
@@ -490,7 +504,6 @@ void LightKeeper::customDraw()
|
||||
SceneManager::GetInstance().Render(ctx);
|
||||
renderer.endDrawing();
|
||||
|
||||
const auto cmd = gfxDevice.beginFrame();
|
||||
const auto& drawImage = renderer.getDrawImage();
|
||||
|
||||
renderer.draw(
|
||||
@@ -508,14 +521,17 @@ void LightKeeper::customDraw()
|
||||
|
||||
void LightKeeper::customCleanup()
|
||||
{
|
||||
auto device = gfxDevice.getDevice().device;
|
||||
// auto device = gfxDevice.getDevice().device;
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
// vkDeviceWaitIdle(device);
|
||||
|
||||
gfxDevice.waitIdle();
|
||||
|
||||
SceneManager::GetInstance().Destroy();
|
||||
|
||||
if (skyboxCubemap)
|
||||
{
|
||||
skyboxCubemap->cleanup(gfxDevice);
|
||||
skyboxCubemap.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "Lightkeeper.h"
|
||||
@@ -9,8 +11,13 @@ int main(int argc, char* argv[]) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", SDL_GetError(), nullptr);
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
std::filesystem::path exeDir = SDL_GetBasePath();
|
||||
try {
|
||||
char* basePath = SDL_GetBasePath();
|
||||
if (basePath == nullptr) {
|
||||
throw std::runtime_error(std::string{"SDL_GetBasePath failed: "} + SDL_GetError());
|
||||
}
|
||||
const std::filesystem::path exeDir = basePath;
|
||||
SDL_free(basePath);
|
||||
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
|
||||
@@ -24,6 +31,10 @@ int main(int argc, char* argv[]) {
|
||||
});
|
||||
app.run();
|
||||
app.cleanup();
|
||||
} catch (const std::exception& exception) {
|
||||
spdlog::critical("Lightkeeper terminated with an error: {}", exception.what());
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
Reference in New Issue
Block a user