diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-10-10 22:14:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-10-10 22:15:57 +0300 |
commit | aa3f63fd497558a02feb3ddbc44f31eac091f39b (patch) | |
tree | 0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/render/shaders | |
parent | 7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff) | |
download | mv-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz mv-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2 mv-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz mv-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip |
Remove most unused files.
Diffstat (limited to 'src/render/shaders')
-rw-r--r-- | src/render/shaders/shader.cpp | 41 | ||||
-rw-r--r-- | src/render/shaders/shader.h | 45 | ||||
-rw-r--r-- | src/render/shaders/shaderprogram.cpp | 54 | ||||
-rw-r--r-- | src/render/shaders/shaderprogram.h | 51 | ||||
-rw-r--r-- | src/render/shaders/shadersmanager.cpp | 146 | ||||
-rw-r--r-- | src/render/shaders/shadersmanager.h | 57 |
6 files changed, 0 insertions, 394 deletions
diff --git a/src/render/shaders/shader.cpp b/src/render/shaders/shader.cpp deleted file mode 100644 index f3cb54833..000000000 --- a/src/render/shaders/shader.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2014-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef USE_OPENGL - -#include "render/shaders/shader.h" - -#include "render/opengl/mgl.h" - -#include "debug.h" - -Shader::Shader(const unsigned int id) : - Resource(), - mShaderId(id) -{ -} - -Shader::~Shader() -{ - if (mShaderId != 0u) - mglDeleteShader(mShaderId); -} - -#endif // USE_OPENGL diff --git a/src/render/shaders/shader.h b/src/render/shaders/shader.h deleted file mode 100644 index f11d9d44e..000000000 --- a/src/render/shaders/shader.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2014-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef RENDER_SHADERS_SHADER_H -#define RENDER_SHADERS_SHADER_H - -#ifdef USE_OPENGL - -#include "resources/resource.h" - -class Shader final : public Resource -{ - public: - explicit Shader(const unsigned int id); - - ~Shader(); - - A_DELETE_COPY(Shader) - - unsigned int getShaderId() const noexcept2 - { return mShaderId; } - - protected: - unsigned int mShaderId; -}; - -#endif // USE_OPENGL -#endif // RENDER_SHADERS_SHADER_H diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp deleted file mode 100644 index 52cb025d7..000000000 --- a/src/render/shaders/shaderprogram.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2014-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef USE_OPENGL - -#include "render/shaders/shaderprogram.h" - -#include "render/opengl/mgl.h" -#ifdef __native_client__ -#include "render/opengl/naclglfunctions.h" -#endif // __native_client__ - -#include "render/shaders/shader.h" - -#include "debug.h" - -ShaderProgram::ShaderProgram(const unsigned int id, - Shader *const vertex, - Shader *const fragment) : - Resource(), - mProgramId(id), - mVertex(vertex), - mFragment(fragment) -{ -} - -ShaderProgram::~ShaderProgram() -{ - if (mProgramId != 0u) - mglDeleteProgram(mProgramId); - if (mVertex != nullptr) - mVertex->decRef(); - if (mFragment != nullptr) - mFragment->decRef(); -} - -#endif // USE_OPENGL diff --git a/src/render/shaders/shaderprogram.h b/src/render/shaders/shaderprogram.h deleted file mode 100644 index b8d8e4bc3..000000000 --- a/src/render/shaders/shaderprogram.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2014-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef RENDER_SHADERS_SHADERPROGRAM_H -#define RENDER_SHADERS_SHADERPROGRAM_H - -#ifdef USE_OPENGL - -#include "resources/resource.h" - -class Shader; - -class ShaderProgram final : public Resource -{ - public: - ShaderProgram(const unsigned int id, - Shader *const vertex, - Shader *const fragment); - - ~ShaderProgram(); - - A_DELETE_COPY(ShaderProgram) - - unsigned int getProgramId() const noexcept2 - { return mProgramId; } - - protected: - unsigned int mProgramId; - Shader *mVertex; - Shader *mFragment; -}; - -#endif // USE_OPENGL -#endif // RENDER_SHADERS_SHADERPROGRAM_H diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp deleted file mode 100644 index 8c4cd79e6..000000000 --- a/src/render/shaders/shadersmanager.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2014-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "render/shaders/shadersmanager.h" - -#ifdef USE_OPENGL - -#include "configuration.h" -#include "logger.h" - -#include "fs/virtfs/tools.h" - -#include "utils/cast.h" - -#include "render/opengl/mgl.h" -#ifdef __native_client__ -#include "render/opengl/naclglfunctions.h" -#endif // __native_client__ - -#include "render/shaders/shader.h" -#include "render/shaders/shaderprogram.h" - -#include "resources/loaders/shaderloader.h" - -#include "debug.h" - -ShadersManager shaders; - -Shader *ShadersManager::createShader(const unsigned int type, - const std::string &fileName) -{ - const std::string str = VirtFs::loadTextFileString(fileName); - const char *ptrStr = str.c_str(); - GLuint shaderId = mglCreateShader(type); - mglShaderSource(shaderId, 1, &ptrStr, nullptr); - mglCompileShader(shaderId); - - GLint isCompiled = 0; - mglGetShaderiv(shaderId, GL_COMPILE_STATUS, &isCompiled); - if (isCompiled == GL_TRUE) - return new Shader(shaderId); - GLint len = 0; - mglGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &len); - char *buf = new char[CAST_SIZE(len) + 1]; - mglGetShaderInfoLog(shaderId, len, &len, buf); - buf[len] = 0; - logger->log("Shader '%s' compilation error: %s", fileName.c_str(), buf); - delete [] buf; - mglDeleteShader(shaderId); - return nullptr; -} - -ShaderProgram *ShadersManager::createProgram(const std::string &vertex, - const std::string &fragment, - const bool isNewShader) -{ - Shader *const vertexShader = static_cast<Shader*>( - Loader::getShader(GL_VERTEX_SHADER, vertex)); - if (vertexShader == nullptr) - return nullptr; - - Shader *const fragmentShader = static_cast<Shader*>( - Loader::getShader(GL_FRAGMENT_SHADER, fragment)); - - if (fragmentShader == nullptr) - { - vertexShader->decRef(); - return nullptr; - } - - GLuint programId = mglCreateProgram(); - if (programId == 0u) - { - vertexShader->decRef(); - fragmentShader->decRef(); - return nullptr; - } - - mglAttachShader(programId, vertexShader->getShaderId()); - mglAttachShader(programId, fragmentShader->getShaderId()); - if (isNewShader) - mglBindFragDataLocation(programId, 0, "outColor"); - else - mglBindAttribLocation(programId, 0, "position"); - mglLinkProgram(programId); - GLint isLinked = 0; - mglGetProgramiv(programId, GL_LINK_STATUS, &isLinked); - if (isLinked == GL_TRUE) - { - mglValidateProgram(programId); - GLint isValidated = 0; - mglGetProgramiv(programId, GL_VALIDATE_STATUS, &isValidated); - if (isValidated == GL_TRUE) - return new ShaderProgram(programId, vertexShader, fragmentShader); - mglDeleteProgram(programId); - return nullptr; - } - - GLint len = 0; - mglGetProgramiv(programId, GL_INFO_LOG_LENGTH, &len); - char *buf = new char[CAST_SIZE(len) + 1]; - mglGetProgramInfoLog(programId, len, &len, buf); - buf[len] = 0; - logger->log("Program '%s, %s' compilation error: %s", - vertexShader->mIdPath.c_str(), - fragmentShader->mIdPath.c_str(), - buf); - delete [] buf; - mglDeleteProgram(programId); - return nullptr; -} - -ShaderProgram *ShadersManager::getSimpleProgram() -{ - const std::string dir = paths.getStringValue("shaders"); - return createProgram(dir + paths.getStringValue("simpleVertexShader"), - dir + paths.getStringValue("simpleFragmentShader"), - true); -} - -ShaderProgram *ShadersManager::getGles2Program() -{ - const std::string dir = paths.getStringValue("shaders"); - return createProgram(dir + paths.getStringValue("gles2VertexShader"), - dir + paths.getStringValue("gles2FragmentShader"), - false); -} - -#endif // USE_OPENGL diff --git a/src/render/shaders/shadersmanager.h b/src/render/shaders/shadersmanager.h deleted file mode 100644 index 8e45290c4..000000000 --- a/src/render/shaders/shadersmanager.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2014-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef RENDER_SHADERS_SHADERSMANAGER_H -#define RENDER_SHADERS_SHADERSMANAGER_H - -#ifdef USE_OPENGL - -#include <string> - -#include "localconsts.h" - -class Shader; -class ShaderProgram; - -class ShadersManager final -{ - public: - ShadersManager() - { } - - A_DELETE_COPY(ShadersManager) - - Shader *createShader(const unsigned int type, - const std::string &fileName) A_WARN_UNUSED; - - ShaderProgram *createProgram(const std::string &vertex, - const std::string &fragment, - const bool isNewShader) - A_WARN_UNUSED; - - ShaderProgram *getSimpleProgram(); - - ShaderProgram *getGles2Program(); -}; - -extern ShadersManager shaders; - -#endif // USE_OPENGL -#endif // RENDER_SHADERS_SHADERSMANAGER_H |