fix: alot of stuff changed. Mostly bugfixxes / architechture changes
This commit is contained in:
+38
-14
@@ -35,28 +35,52 @@ target_link_libraries(lightkeeper PRIVATE destrum::destrum)
|
||||
|
||||
set(ASSETS_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/assets_src")
|
||||
set(ASSETS_RUNTIME_DIR "${CMAKE_CURRENT_LIST_DIR}/assets_runtime")
|
||||
set(OUTPUT_GAME_ASSETS_DIR "${CMAKE_CURRENT_BINARY_DIR}/assets/game")
|
||||
set(OUTPUT_GAME_ASSETS_DIR "$<TARGET_FILE_DIR:lightkeeper>/assets/game")
|
||||
|
||||
if (WIN32)
|
||||
set(GAME_ASSET_INSTALL_COMMANDS
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${ASSETS_RUNTIME_DIR}" "${OUTPUT_GAME_ASSETS_DIR}")
|
||||
else()
|
||||
set(GAME_ASSET_INSTALL_COMMANDS
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
"${ASSETS_RUNTIME_DIR}" "${OUTPUT_GAME_ASSETS_DIR}")
|
||||
endif()
|
||||
|
||||
add_custom_command(TARGET lightkeeper POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/assets"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTPUT_GAME_ASSETS_DIR}/.."
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_CURRENT_BINARY_DIR}/assets/game"
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink "${ASSETS_RUNTIME_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/assets/game"
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf "${OUTPUT_GAME_ASSETS_DIR}"
|
||||
${GAME_ASSET_INSTALL_COMMANDS}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE GAME_ASSET_SOURCES CONFIGURE_DEPENDS
|
||||
"${ASSETS_SRC_DIR}/*")
|
||||
|
||||
add_custom_target(_internal_clean_game_assets
|
||||
COMMAND TheChef
|
||||
--input "${ASSETS_SRC_DIR}"
|
||||
--output "${ASSETS_RUNTIME_DIR}"
|
||||
--clean
|
||||
COMMAND TheChef
|
||||
--input "${ASSETS_SRC_DIR}"
|
||||
--output "${ASSETS_RUNTIME_DIR}"
|
||||
--clean
|
||||
DEPENDS TheChef
|
||||
)
|
||||
|
||||
add_custom_target(_internal_cook_game_assets ALL
|
||||
COMMAND TheChef
|
||||
--input "${ASSETS_SRC_DIR}"
|
||||
--output "${ASSETS_RUNTIME_DIR}"
|
||||
DEPENDS TheChef
|
||||
add_custom_target(_internal_cook_game_assets
|
||||
COMMAND TheChef
|
||||
--input "${ASSETS_SRC_DIR}"
|
||||
--output "${ASSETS_RUNTIME_DIR}"
|
||||
--clean
|
||||
COMMAND TheChef
|
||||
--input "${ASSETS_SRC_DIR}"
|
||||
--output "${ASSETS_RUNTIME_DIR}"
|
||||
DEPENDS TheChef ${GAME_ASSET_SOURCES}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
destrum_cook_engine_assets(lightkeeper "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
add_dependencies(lightkeeper _internal_cook_game_assets)
|
||||
|
||||
destrum_cook_engine_assets(lightkeeper "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
install(TARGETS lightkeeper RUNTIME DESTINATION bin)
|
||||
install(DIRECTORY "${ASSETS_RUNTIME_DIR}/" DESTINATION "bin/assets/game")
|
||||
|
||||
@@ -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