Refactor
This commit is contained in:
@@ -54,13 +54,12 @@ Scene::Scene(std::vector<ShaderProgram *> shaderPrograms)
|
||||
|
||||
// TODO: use geometry shader instead of model and load skybox before models.
|
||||
Skybox::Prototype skyboxPrototype = modelParser.getSkyboxPrototype();
|
||||
std::thread skyboxThread([=]() {
|
||||
m_skybox = new Skybox(skyboxPrototype,
|
||||
std::static_pointer_cast<Model>(ResourceHandler::instance().resource("cube")).get(),
|
||||
Controller::getShaderProgramByName("skyboxProgram", shaderPrograms));
|
||||
m_skybox =
|
||||
new Skybox(skyboxPrototype, std::static_pointer_cast<Model>(ResourceHandler::instance().resource("cube")).get(),
|
||||
Controller::getShaderProgramByName("skyboxProgram", shaderPrograms));
|
||||
|
||||
Log::logger().info("Loaded skybox: {}", skyboxPrototype.texturePath);
|
||||
});
|
||||
Log::logger().info("Loaded skybox: {}", skyboxPrototype.texturePath);
|
||||
m_skybox->initializeOnGPU();
|
||||
|
||||
std::vector<ModelEntity::Prototype> entityPrototypes = modelParser.getEntityPrototypes();
|
||||
|
||||
@@ -127,9 +126,6 @@ Scene::Scene(std::vector<ShaderProgram *> shaderPrograms)
|
||||
}
|
||||
}
|
||||
m_lights = lights;
|
||||
|
||||
skyboxThread.join();
|
||||
m_skybox->initializeOnGPU();
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
||||
@@ -30,7 +30,7 @@ struct TextureCubeMapDescriptor
|
||||
class AbstractCubeMap : public AbstractTexture
|
||||
{
|
||||
public:
|
||||
AbstractCubeMap(const std::string path) : AbstractTexture(path)
|
||||
AbstractCubeMap(const std::string &path) : AbstractTexture(path)
|
||||
{}
|
||||
|
||||
void bind(ShaderProgram *shaderProgram) const;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
ResourceId Resource::s_idCounter = 0;
|
||||
|
||||
Resource::Resource(const std::string &path) : m_id(s_idCounter++), m_path(path)
|
||||
Resource::Resource(const std::filesystem::path &path) : m_id(s_idCounter++), m_path(path)
|
||||
{
|
||||
Log::logger().info("Resource \"{}\" with id {} created", m_path, m_id);
|
||||
Log::logger().info("Resource \"{}\" with id {} created", m_path.string(), m_id);
|
||||
}
|
||||
|
||||
ResourceId Resource::id() const
|
||||
@@ -18,7 +18,7 @@ bool Resource::isInitialized() const
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
const std::string &Resource::resourcePath() const
|
||||
const std::filesystem::path &Resource::resourcePath() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <glad/glad.h>
|
||||
#include <string>
|
||||
|
||||
@@ -9,14 +10,14 @@ using ResourceId = uint64_t;
|
||||
class Resource
|
||||
{
|
||||
public:
|
||||
Resource(const std::string &path);
|
||||
Resource(const std::filesystem::path &path);
|
||||
Resource(const Resource &other) = delete;
|
||||
Resource(Resource &&other) = delete;
|
||||
Resource &operator=(const Resource &other) = delete;
|
||||
Resource &operator=(Resource &&other) = delete;
|
||||
|
||||
ResourceId id() const;
|
||||
const std::string &resourcePath() const;
|
||||
const std::filesystem::path &resourcePath() const;
|
||||
|
||||
protected:
|
||||
bool isInitialized() const;
|
||||
@@ -28,7 +29,7 @@ private:
|
||||
ResourceId m_id;
|
||||
static ResourceId s_idCounter;
|
||||
|
||||
std::string m_path;
|
||||
std::filesystem::path m_path;
|
||||
|
||||
friend class ResourceHandler;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ Texture::Texture(const TextureDescriptor &descriptor)
|
||||
m_textureBuffer = stbi_load(resourcePath().c_str(), &m_textureWidth, &m_textureHeight, &m_numComponents, 0);
|
||||
|
||||
if (!m_textureBuffer)
|
||||
Log::logger().warn("Texture {} could not be loaded", resourcePath());
|
||||
Log::logger().warn("Texture {} could not be loaded", resourcePath().string());
|
||||
}
|
||||
|
||||
void Texture::initialize()
|
||||
|
||||
Reference in New Issue
Block a user