parent
4ed4452dfb
commit
0e2805ed06
@ -2,6 +2,8 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/catch2-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/spdlog-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/lib/glfw" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/lib/glm" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/lib/tinyobjloader" vcs="Git" />
|
||||
|
||||
@ -49,7 +49,7 @@ FetchContent_Declare(
|
||||
|
||||
FetchContent_MakeAvailable(Catch2 spdlog)
|
||||
|
||||
target_link_libraries(LayoutEngineTests PRIVATE Catch2::Catch2WithMain spdlog::spdlog)
|
||||
target_link_libraries(LayoutEngineTests PRIVATE Catch2::Catch2WithMain spdlog::spdlog_header_only)
|
||||
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
@ -311,6 +311,8 @@ if(BUILD_GAME)
|
||||
src/engine/renderer/loader/async/AssetLoader.cpp
|
||||
src/engine/renderer/loader/async/AssetLoader.h
|
||||
src/engine/renderer/loader/async/AssetLoadingProgressEvent.h
|
||||
src/engine/core/scenes/Scene.cpp
|
||||
src/engine/core/scenes/Scene.h
|
||||
)
|
||||
target_compile_options(Dicewars_Siedler PRIVATE
|
||||
-Wall
|
||||
@ -334,7 +336,7 @@ if(BUILD_GAME)
|
||||
glad
|
||||
OpenGL::GL
|
||||
${FREETYPE_LIBRARIES}
|
||||
spdlog::spdlog
|
||||
spdlog::spdlog_header_only
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ RawModelData OBJLoader::loadModel(const std::string &modelPath) {
|
||||
return {"", subModels};
|
||||
}
|
||||
|
||||
TexturedModel OBJLoader::uploadToGPU(RawModelData &rawModelData) {
|
||||
TexturedModel OBJLoader::uploadToGPU(const RawModelData &rawModelData) {
|
||||
Loader loader = Loader::instance();
|
||||
|
||||
std::vector<SubModel> subModels;
|
||||
|
||||
@ -16,7 +16,7 @@ class OBJLoader {
|
||||
public:
|
||||
static std::shared_ptr<TexturedModel> loadModel(const std::string &modelPath, const std::string &texturePath, Loader &loader);
|
||||
static RawModelData loadModel(const std::string &modelPath);
|
||||
static TexturedModel uploadToGPU(RawModelData &rawModelData);
|
||||
static TexturedModel uploadToGPU(const RawModelData &rawModelData);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -86,9 +86,8 @@ TextureData TextureLoader::loadTextureData(const std::string &path, bool flipVer
|
||||
return textureData;
|
||||
}
|
||||
|
||||
Texture2D TextureLoader::uploadToGPU(RawTextureData &rawTextureData) {
|
||||
Texture2D TextureLoader::uploadToGPU(const RawTextureData &rawTextureData) {
|
||||
Texture2D texture;
|
||||
texture.pixels = rawTextureData.pixels.data();
|
||||
texture.width = rawTextureData.width;
|
||||
texture.height = rawTextureData.height;
|
||||
texture.channels = rawTextureData.channels;
|
||||
@ -119,7 +118,7 @@ Texture2D TextureLoader::uploadToGPU(RawTextureData &rawTextureData) {
|
||||
0,
|
||||
format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
texture.pixels
|
||||
rawTextureData.pixels.data()
|
||||
);
|
||||
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
@ -17,8 +17,8 @@ class TextureLoader {
|
||||
public:
|
||||
static Texture2D loadTexture(const std::string& path, bool flipVertically= true);
|
||||
static RawTextureData loadRawTextureData(const std::string &path, bool flipVertically = true);
|
||||
static TextureData loadTextureData(const std::string &path, bool flipVertically = true, TextureType textureType);
|
||||
static Texture2D uploadToGPU(RawTextureData &rawTextureData);
|
||||
static TextureData loadTextureData(const std::string &path, bool flipVertically = true, TextureType textureType = TextureType::Diffuse);
|
||||
static Texture2D uploadToGPU(const RawTextureData &rawTextureData);
|
||||
static Texture2D uploadToGPU(TextureData& textureData);
|
||||
static void free(Texture2D& texture);
|
||||
};
|
||||
|
||||
@ -147,14 +147,14 @@ nlohmann::json AssetLoader::loadJson(const std::string &path) {
|
||||
void AssetLoader::processUploadQueue(int maxPerFrame) {
|
||||
auto uploadQueue = determineUploadQueue(maxPerFrame);
|
||||
for (const auto& intermediateAsset : uploadQueue) {
|
||||
std::visit([]<typename T0>(T0& rawData) -> IntermediateAsset {
|
||||
std::visit([]<typename T0>(const T0& rawData) -> void {
|
||||
using T = std::decay_t<T0>;
|
||||
if constexpr (std::is_same_v<T, RawTextureData>) {
|
||||
return processIntermediateTextureAsset(rawData);
|
||||
processIntermediateTextureAsset(rawData);
|
||||
} else if constexpr (std::is_same_v<T, RawModelData>) {
|
||||
return processIntermediateModelAsset(rawData);
|
||||
processIntermediateModelAsset(rawData);
|
||||
} else {
|
||||
return processIntermediateStagedModelAsset(rawData);
|
||||
processIntermediateStagedModelAsset(rawData);
|
||||
}
|
||||
}, intermediateAsset);
|
||||
++loaded;
|
||||
@ -175,12 +175,12 @@ std::vector<IntermediateAsset> AssetLoader::determineUploadQueue(const int maxPe
|
||||
return results;
|
||||
}
|
||||
|
||||
void AssetLoader::processIntermediateTextureAsset(RawTextureData &textureData) {
|
||||
void AssetLoader::processIntermediateTextureAsset(const RawTextureData &textureData) {
|
||||
const Texture2D texture = TextureLoader::uploadToGPU(textureData);
|
||||
AssetManager::insertLoadedTexture(textureData.name, texture);
|
||||
}
|
||||
|
||||
void AssetLoader::processIntermediateModelAsset(RawModelData &modelData) {
|
||||
void AssetLoader::processIntermediateModelAsset(const RawModelData &modelData) {
|
||||
const TexturedModel texturedModel = OBJLoader::uploadToGPU(modelData);
|
||||
AssetManager::insertTexturedModel(modelData.name, texturedModel);
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ private:
|
||||
static nlohmann::json loadJson(const std::string& path);
|
||||
std::vector<IntermediateAsset> determineUploadQueue(int maxPerFrame);
|
||||
|
||||
static void processIntermediateTextureAsset(RawTextureData &textureData);
|
||||
static void processIntermediateModelAsset(RawModelData &modelData);
|
||||
static void processIntermediateTextureAsset(const RawTextureData &textureData);
|
||||
static void processIntermediateModelAsset(const RawModelData &modelData);
|
||||
static void processIntermediateStagedModelAsset(const RawStagedModelData &stagedModelData);
|
||||
|
||||
// Render-Thread schreibt, Loading Thread liest
|
||||
|
||||
@ -8,11 +8,5 @@
|
||||
#include "UILayer.h"
|
||||
|
||||
DicewarsApp::DicewarsApp() {
|
||||
gameMode = std::make_shared<GameMode>();
|
||||
GameLayer* gamelayer = new GameLayer();
|
||||
gamelayer->setGameMode(gameMode);
|
||||
pushLayer(gamelayer);
|
||||
UILayer* uiLayer = new UILayer();
|
||||
uiLayer->setGameMode(gameMode);
|
||||
pushLayer(uiLayer);
|
||||
|
||||
}
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
|
||||
class DicewarsApp: public Application
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<GameMode> gameMode;
|
||||
public:
|
||||
DicewarsApp();
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#include "engine/core/Application.h"
|
||||
#include "game/DicewarsApp.h"
|
||||
#include "spdlog/spdlog-inl.h"
|
||||
#include "spdlog/spdlog.h" // ← nur das
|
||||
// TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
|
||||
Application* CreateApplication()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user