diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-26 16:11:17 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-26 16:11:17 +0200 |
commit | 8ac4fe6d5ba5091923c7fdf1fa88724d827706fa (patch) | |
tree | a4ce203f671f9b8311d09dd36f1f80ae65799a56 /src/graphics | |
parent | 2017-05-21 (diff) | |
download | AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.gz AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.bz2 AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.lz AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.xz AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.tar.zst AltCraft-8ac4fe6d5ba5091923c7fdf1fa88724d827706fa.zip |
Diffstat (limited to 'src/graphics')
-rw-r--r-- | src/graphics/AssetManager_old.cpp (renamed from src/graphics/AssetManager.cpp) | 16 | ||||
-rw-r--r-- | src/graphics/AssetManager_old.hpp (renamed from src/graphics/AssetManager.hpp) | 15 | ||||
-rw-r--r-- | src/graphics/Display.cpp | 6 | ||||
-rw-r--r-- | src/graphics/Shader.cpp | 11 | ||||
-rw-r--r-- | src/graphics/Shader.hpp | 1 | ||||
-rw-r--r-- | src/graphics/Texture.cpp | 10 |
6 files changed, 30 insertions, 29 deletions
diff --git a/src/graphics/AssetManager.cpp b/src/graphics/AssetManager_old.cpp index 93462c3..ef856ca 100644 --- a/src/graphics/AssetManager.cpp +++ b/src/graphics/AssetManager_old.cpp @@ -1,16 +1,16 @@ -#include "AssetManager.hpp" +#include "AssetManager_old.hpp" const std::string pathToAssets = "./assets/"; const std::string pathToObjects = pathToAssets + "objects/"; const std::string pathToIndexFile = pathToAssets + "indexes/1.11.json"; -const std::string pathToAssetsMc = "./assetsMc/"; +const std::string pathToAssetsMc = "./assets/"; const std::map<Asset::AssetType, std::string> assetTypeFileExtensions{ std::make_pair(Asset::AssetType::Texture, ".png"), std::make_pair(Asset::AssetType::Lang, ".lang"), std::make_pair(Asset::AssetType::Sound, ".ogg"), }; -AssetManager::AssetManager() { +AssetManager_old::AssetManager_old() { return; std::ifstream indexFile(pathToIndexFile); if (!indexFile) { @@ -35,17 +35,17 @@ AssetManager::AssetManager() { } } -AssetManager::~AssetManager() { +AssetManager_old::~AssetManager_old() { } -Asset &AssetManager::GetAsset(std::string AssetName) { +Asset &AssetManager_old::GetAsset(std::string AssetName) { if (instance().assets.find(AssetName) == instance().assets.end() || !instance().assets[AssetName].isParsed()) LoadAsset(AssetName); return instance().assets[AssetName]; } -void AssetManager::LoadAsset(std::string AssetName) { +void AssetManager_old::LoadAsset(std::string AssetName) { if (instance().assets.find(AssetName) != instance().assets.end() && instance().assets[AssetName].isParsed()) return; std::string AssetFileName = GetPathToAsset(AssetName); @@ -58,7 +58,7 @@ void AssetManager::LoadAsset(std::string AssetName) { } } -std::string AssetManager::GetPathToAsset(std::string AssetName) { +std::string AssetManager_old::GetPathToAsset(std::string AssetName) { if (instance().assets.find(AssetName) != instance().assets.end()){ auto it = instance().assets.find(AssetName); return pathToObjects + std::string(instance().assets[AssetName].hash.c_str(), 2) + "/" + @@ -73,7 +73,7 @@ std::string AssetManager::GetPathToAsset(std::string AssetName) { assetTypeFileExtensions.at(instance().assets[AssetName].type); } -std::string AssetManager::GetAssetNameByBlockId(unsigned short id) { +std::string AssetManager_old::GetAssetNameByBlockId(unsigned short id) { std::string assetBase = "minecraft/textures/blocks/"; std::string textureName; switch (id){ diff --git a/src/graphics/AssetManager.hpp b/src/graphics/AssetManager_old.hpp index e723398..23a11a7 100644 --- a/src/graphics/AssetManager.hpp +++ b/src/graphics/AssetManager_old.hpp @@ -3,6 +3,7 @@ #include <fstream> #include <string> #include <map> +#include <experimental/filesystem> #include <nlohmann/json.hpp> #include "Texture.hpp" @@ -24,19 +25,19 @@ struct Asset { ~Asset(); }; -class AssetManager { - AssetManager(); +class AssetManager_old { + AssetManager_old(); - ~AssetManager(); + ~AssetManager_old(); - AssetManager(const AssetManager &); + AssetManager_old(const AssetManager_old &); - AssetManager &operator=(const AssetManager &); + AssetManager_old &operator=(const AssetManager_old &); std::map<std::string, Asset> assets; - static AssetManager &instance() { - static AssetManager assetManager; + static AssetManager_old &instance() { + static AssetManager_old assetManager; return assetManager; } diff --git a/src/graphics/Display.cpp b/src/graphics/Display.cpp index 1a44fbc..63498fa 100644 --- a/src/graphics/Display.cpp +++ b/src/graphics/Display.cpp @@ -1,6 +1,6 @@ #include <iomanip> #include "Display.hpp" -#include "AssetManager.hpp" +#include "AssetManager_old.hpp" /*GLfloat vertices[] = { -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, @@ -329,10 +329,10 @@ void Display::MainLoop() { glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); glUniform1i(blockLoc, block.id); - std::string textureName = AssetManager::GetAssetNameByBlockId(block.id); + std::string textureName = AssetManager_old::GetAssetNameByBlockId(block.id); if (textureName.find("air") != std::string::npos) continue; - Texture &texture1 = *(AssetManager::GetAsset(textureName).data.texture); + Texture &texture1 = *(AssetManager_old::GetAsset(textureName).data.texture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture1.texture); diff --git a/src/graphics/Shader.cpp b/src/graphics/Shader.cpp index c84e169..9bb08ba 100644 --- a/src/graphics/Shader.cpp +++ b/src/graphics/Shader.cpp @@ -1,3 +1,4 @@ +#include <easylogging++.h> #include "Shader.hpp" Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { @@ -27,7 +28,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { fragmentCode = fShaderStream.str(); } catch (std::ifstream::failure e) { - std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl; + LOG(ERROR) << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ"; } const GLchar *vShaderCode = vertexCode.c_str(); const GLchar *fShaderCode = fragmentCode.c_str(); @@ -46,7 +47,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { glGetShaderiv(vertex, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(vertex, 512, NULL, infoLog); - std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; + LOG(ERROR) << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog; }; // Вершинный шейдер @@ -57,7 +58,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { glGetShaderiv(fragment, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(fragment, 512, NULL, infoLog); - std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl; + LOG(ERROR) << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog; }; // Шейдерная программа @@ -69,7 +70,7 @@ Shader::Shader(const GLchar *vertexPath, const GLchar *fragmentPath) { glGetProgramiv(this->Program, GL_LINK_STATUS, &success); if (!success) { glGetProgramInfoLog(this->Program, 512, NULL, infoLog); - std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl; + LOG(ERROR) << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog; } // Удаляем шейдеры, поскольку они уже в программу и нам больше не нужны. @@ -86,5 +87,5 @@ void Shader::Reload() { const GLchar *fragmentPath = fragment; this->~Shader(); new(this) Shader(vertexPath, fragmentPath); - std::cout<<"Shader is realoded!"<<std::endl; + LOG(INFO) << "Shader is realoded!"; } diff --git a/src/graphics/Shader.hpp b/src/graphics/Shader.hpp index 90db5f7..66d687c 100644 --- a/src/graphics/Shader.hpp +++ b/src/graphics/Shader.hpp @@ -2,7 +2,6 @@ #include <string> #include <fstream> #include <sstream> -#include <iostream> #include <GL/glew.h> diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp index 0104530..bd5c53f 100644 --- a/src/graphics/Texture.cpp +++ b/src/graphics/Texture.cpp @@ -1,5 +1,5 @@ -#include <iostream> #include <SFML/Graphics.hpp> +#include <easylogging++.h> #include "Texture.hpp" Texture::Texture(std::string filename, GLenum textureWrapping, GLenum textureFiltering) { @@ -10,17 +10,17 @@ Texture::Texture(std::string filename, GLenum textureWrapping, GLenum textureFil glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureWrapping); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureWrapping); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,textureFiltering); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureFiltering); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); //Image load sf::Image image; if (!image.loadFromFile(filename)) { - std::cout << "Can't open image " << filename << std::endl; + LOG(ERROR) << "Can't open image " << filename; throw 201; } - if (image.getPixelsPtr()==nullptr){ - std::cout<<"Image data is corrupted!"<<std::endl; + if (image.getPixelsPtr() == nullptr) { + LOG(ERROR) << "Image data is corrupted!"; throw 202; } image.flipVertically(); |