Skip to content
Snippets Groups Projects
Commit 059773b4 authored by Nils Petter Skålerud's avatar Nils Petter Skålerud
Browse files

Removed submodule KTXLib from the project. Will try another KTX importer instead.

Continued work on getting texture loading working.

Signed-off-by: default avatarNils Petter Skålerud <np_skalerud@hotmail.com>
parent 613c8688
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,3 @@ ...@@ -10,7 +10,3 @@
path = external/nlohmann-json path = external/nlohmann-json
url = https://github.com/nlohmann/json.git url = https://github.com/nlohmann/json.git
branch = origin/master branch = origin/master
[submodule "ktxlib"]
path = external/ktxlib
url = https://github.com/KhronosGroup/KTX-Software.git
branch = origin/master
File added
Subproject commit 94170beb4189d6fdacf49fb900d4393a9ad0dd05
...@@ -14,12 +14,12 @@ struct AssetManagerInfo ...@@ -14,12 +14,12 @@ struct AssetManagerInfo
std::string_view relativePath; std::string_view relativePath;
}; };
static const std::map<Engine::AssetManager::Sprite, AssetManagerInfo> textureInfos static const std::map<size_t, AssetManagerInfo> textureInfos
{ {
{ Engine::AssetManager::Sprite::None, {"None" , ""} }, { size_t(Engine::AssetManager::Sprite::None), {"None" , ""} },
{ Engine::AssetManager::Sprite::Default, {"Default", "defaultTexture.png"} }, { size_t(Engine::AssetManager::Sprite::Default), {"Default", "defaultTexture.png"} },
{ Engine::AssetManager::Sprite::Test, {"Test", "test.png"} }, { size_t(Engine::AssetManager::Sprite::Test), {"Test", "test.png"} },
{ Engine::AssetManager::Sprite::Circle, {"Circle", "circle.png"} }, { size_t(Engine::AssetManager::Sprite::Circle), {"Circle", "circle.png"} },
}; };
static const std::map<size_t, AssetManagerInfo> meshInfos static const std::map<size_t, AssetManagerInfo> meshInfos
...@@ -43,7 +43,16 @@ namespace Engine ...@@ -43,7 +43,16 @@ namespace Engine
return std::string(meshFolderPath) + std::string(iterator->second.relativePath); return std::string(meshFolderPath) + std::string(iterator->second.relativePath);
} }
std::optional<Renderer::MeshDocument> AssetManager::LoadMesh(size_t i) std::string GetTexturePath(size_t i)
{
auto iterator = textureInfos.find(i);
if (iterator == textureInfos.end())
return {};
else
return std::string(textureFolderPath) + std::string(iterator->second.relativePath);
}
std::optional<Renderer::MeshDocument> LoadMesh(size_t i)
{ {
auto path = GetMeshPath(i); auto path = GetMeshPath(i);
if (path == "") if (path == "")
...@@ -69,6 +78,11 @@ namespace Engine ...@@ -69,6 +78,11 @@ namespace Engine
return { Renderer::MeshDocument(std::move(newInfo)) }; return { Renderer::MeshDocument(std::move(newInfo)) };
} }
std::optional<Renderer::TextureDocument> LoadTexture(size_t i)
{
return {};
}
} }
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <optional> #include <optional>
#include "../Renderer/MeshDocument.hpp" #include "../Renderer/MeshDocument.hpp"
#include "../Renderer/TextureDocument.hpp"
namespace Engine namespace Engine
{ {
...@@ -18,8 +19,10 @@ namespace Engine ...@@ -18,8 +19,10 @@ namespace Engine
constexpr std::string_view meshFolderPath = "Data/Meshes/"; constexpr std::string_view meshFolderPath = "Data/Meshes/";
std::string GetMeshPath(size_t i); std::string GetMeshPath(size_t i);
std::string GetTexturePath(size_t i);
std::optional<Renderer::MeshDocument> LoadMesh(size_t i); std::optional<Renderer::MeshDocument> LoadMesh(size_t i);
std::optional<Renderer::TextureDocument> LoadTexture(size_t i);
} }
namespace AssMan = AssetManager; namespace AssMan = AssetManager;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <array> #include <array>
#include <vector> #include <vector>
#include <optional> #include <optional>
#include <string>
namespace Engine namespace Engine
{ {
......
...@@ -2,12 +2,25 @@ ...@@ -2,12 +2,25 @@
#include "TextureDocument.hpp" #include "TextureDocument.hpp"
#include <string>
#include <optional>
#include "ktx.h"
namespace Engine namespace Engine
{ {
namespace AssetManager namespace AssetManager
{ {
std::optional<TextureDocument> LoadTextureDocument(std::string path) std::optional<TextureDocument> LoadTextureDocument(std::string path)
{ {
if (path == "")
return {};
ktxTexture* texture;
KTX_error_code result = ktxTexture_CreateFromNamedFile(path.c_str(), KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &texture);
return {}; return {};
} }
} }
......
...@@ -69,6 +69,7 @@ namespace Engine ...@@ -69,6 +69,7 @@ namespace Engine
rendererInitInfo.surfaceHandle = Application::Core::GetMainWindowHandle(); rendererInitInfo.surfaceHandle = Application::Core::GetMainWindowHandle();
rendererInitInfo.assetLoadCreateInfo.meshLoader = &AssMan::LoadMesh; rendererInitInfo.assetLoadCreateInfo.meshLoader = &AssMan::LoadMesh;
rendererInitInfo.assetLoadCreateInfo.textureLoader = &AssMan::LoadTexture;
rendererInitInfo.openGLInitInfo.glSwapBuffers = &Application::Core::GL_SwapWindow; rendererInitInfo.openGLInitInfo.glSwapBuffers = &Application::Core::GL_SwapWindow;
Renderer::Core::Initialize(rendererInitInfo); Renderer::Core::Initialize(rendererInitInfo);
......
...@@ -71,7 +71,7 @@ namespace Engine ...@@ -71,7 +71,7 @@ namespace Engine
struct Renderer::InitInfo struct Renderer::InitInfo
{ {
API preferredAPI = API::None; API preferredAPI = API::None;
Utility::ImgDim surfaceDimensions; Utility::ImgDim surfaceDimensions{};
void* surfaceHandle = nullptr; void* surfaceHandle = nullptr;
AssetLoadCreateInfo assetLoadCreateInfo; AssetLoadCreateInfo assetLoadCreateInfo;
......
...@@ -16,7 +16,7 @@ namespace Engine ...@@ -16,7 +16,7 @@ namespace Engine
private: private:
Format format; Format format;
std::array<uint32_t, 2> dimensions; std::array<uint32_t, 2> dimensions;
std::array<uint8_t> byteArray; std::vector<uint8_t> byteArray;
}; };
enum class TextureDocument::Format enum class TextureDocument::Format
......
//#include "SDL2/SDL.h" //#include "SDL2/SDL.h"
#include "Engine/Engine.hpp" //#include "Engine/Engine.hpp"
#include "Engine/AssetManager/TextureDocument.hpp"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
Engine::Core::Run(); auto test = Engine::AssMan::LoadTextureDocument("Data/Textures/test.ktx");
return 0; return 0;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment