Skip to content

Commit

Permalink
No more shaders and fonts reload on world open
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Dec 24, 2023
1 parent 25b1afb commit 572734d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/assets/AssetsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ void AssetsLoader::createDefaults(AssetsLoader& loader) {
loader.addLoader(ASSET_ATLAS, assetload::atlas);
}

void AssetsLoader::addDefaults(AssetsLoader& loader) {
loader.add(ASSET_SHADER, SHADERS_FOLDER"/main", "main");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/lines", "lines");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui", "ui");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui3d", "ui3d");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/background", "background");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/skybox_gen", "skybox_gen");

loader.add(ASSET_ATLAS, TEXTURES_FOLDER"/blocks", "blocks");
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/menubg.png", "menubg");

loader.add(ASSET_FONT, FONTS_FOLDER"/font", "normal");
void AssetsLoader::addDefaults(AssetsLoader& loader, bool allAssets) {
if (allAssets) {
loader.add(ASSET_SHADER, SHADERS_FOLDER"/main", "main");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/lines", "lines");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui", "ui");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui3d", "ui3d");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/background", "background");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/skybox_gen", "skybox_gen");
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/menubg.png", "menubg");
loader.add(ASSET_FONT, FONTS_FOLDER"/font", "normal");
}
loader.add(ASSET_ATLAS, TEXTURES_FOLDER"/blocks", "blocks");
}

const ResPaths* AssetsLoader::getPaths() const {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/AssetsLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AssetsLoader {
bool loadNext();

static void createDefaults(AssetsLoader& loader);
static void addDefaults(AssetsLoader& loader);
static void addDefaults(AssetsLoader& loader, bool allAssets);

const ResPaths* getPaths() const;
};
Expand Down
4 changes: 2 additions & 2 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Engine::Engine(EngineSettings& settings, EnginePaths* paths)
assets.reset(new Assets());
AssetsLoader loader(assets.get(), resPaths.get());
AssetsLoader::createDefaults(loader);
AssetsLoader::addDefaults(loader);
AssetsLoader::addDefaults(loader, true);

Shader::preprocessor->setPaths(resPaths.get());
while (loader.hasNext()) {
Expand Down Expand Up @@ -189,7 +189,7 @@ void Engine::loadContent() {
std::cout << "-- loading assets" << std::endl;
AssetsLoader loader(new_assets.get(), resPaths.get());
AssetsLoader::createDefaults(loader);
AssetsLoader::addDefaults(loader);
AssetsLoader::addDefaults(loader, false);
while (loader.hasNext()) {
if (!loader.loadNext()) {
new_assets.reset();
Expand Down

0 comments on commit 572734d

Please sign in to comment.