summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp2
-rw-r--r--src/defaults.cpp6
-rw-r--r--src/graphicsmanager.cpp2
-rw-r--r--src/render/graphics.h3
-rw-r--r--src/render/modernopenglgraphics.cpp14
-rw-r--r--src/render/modernopenglgraphics.h4
-rw-r--r--src/render/shaders/shadersmanager.cpp7
-rw-r--r--src/render/shaders/shadersmanager.h2
8 files changed, 38 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 8ddb5dcdd..f202f1982 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -364,6 +364,8 @@ void Client::gameInit()
WindowManager::initTitle();
+ mainGraphics->postInit();
+
theme = new Theme;
Theme::selectSkin();
touchManager.init();
diff --git a/src/defaults.cpp b/src/defaults.cpp
index dfef414fb..50d15c4df 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -460,7 +460,11 @@ DefaultsData* getPathsDefaults()
AddDEF("sprites", "graphics/sprites/");
AddDEF("spriteErrorFile", "error.xml");
AddDEF("guiIcons", "graphics/guiicons/");
+ AddDEF("shaders", "graphics/shaders/");
+ AddDEF("help", "help/");
+ AddDEF("simpleVertexShader", "simple_vertex.glsl");
+ AddDEF("simpleFragmentShader", "simple_frag.glsl");
AddDEF("particles", "graphics/particles/");
AddDEF("portalEffectFile", "warparea.particle.xml");
AddDEF("effectId", -1);
@@ -480,8 +484,6 @@ DefaultsData* getPathsDefaults()
AddDEF("wallpapers", "graphics/images/");
AddDEF("wallpaperFile", "login_wallpaper.png");
- AddDEF("help", "help/");
-
AddDEF("statusEffectsFile", "status-effects.xml");
AddDEF("statusEffectsPatchFile", "status-effects_patch.xml");
AddDEF("statusEffectsPatchDir", "status-effects.d");
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 4fa4744a6..ed9768473 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -63,6 +63,8 @@
#include "resources/surfaceimagehelper.h"
#endif
+#include "render/shaders/shadersmanager.h"
+
#include "utils/delete2.h"
#include "utils/sdlhelper.h"
#include "utils/stringutils.h"
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 08bb7facf..a61c47437 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -450,6 +450,9 @@ class Graphics notfinal
virtual void deleteArrays()
{ }
+ virtual void postInit()
+ { }
+
int mWidth;
int mHeight;
int mActualWidth;
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 2b771a2bb..566dec714 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -33,6 +33,9 @@
#include "render/mgl.h"
+#include "render/shaders/shaderprogram.h"
+#include "render/shaders/shadersmanager.h"
+
#include "resources/image.h"
#include "resources/imagerect.h"
#include "resources/openglimagehelper.h"
@@ -52,6 +55,7 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() :
mShortVertArray(nullptr),
mFloatTexArrayCached(nullptr),
mShortVertArrayCached(nullptr),
+ mSimpleProgram(nullptr),
mAlphaCached(1.0F),
mVpCached(0),
mTexture(false),
@@ -97,6 +101,16 @@ void ModernOpenGLGraphics::initArrays(const int vertCount)
mShortVertArrayCached = new GLshort[sz];
}
+void ModernOpenGLGraphics::postInit()
+{
+ logger->log("Compiling shaders");
+ mSimpleProgram = shaders.getSimpleProgram();
+ if (mSimpleProgram)
+ logger->log("Shaders compilation done.");
+ else
+ logger->error("Shaders compilation error.");
+}
+
void ModernOpenGLGraphics::deleteArrays()
{
deleteArraysInternal();
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index 09edcbd92..75165031f 100644
--- a/src/render/modernopenglgraphics.h
+++ b/src/render/modernopenglgraphics.h
@@ -46,6 +46,7 @@
#include <set>
class NormalOpenGLGraphicsVertexes;
+class ShaderProgram;
class ModernOpenGLGraphics final : public Graphics
{
@@ -56,6 +57,8 @@ class ModernOpenGLGraphics final : public Graphics
~ModernOpenGLGraphics();
+ void postInit() override final;
+
#include "render/graphicsdef.hpp"
#include "render/openglgraphicsdef.hpp"
@@ -67,6 +70,7 @@ class ModernOpenGLGraphics final : public Graphics
GLshort *mShortVertArray;
GLfloat *mFloatTexArrayCached;
GLshort *mShortVertArrayCached;
+ ShaderProgram *mSimpleProgram;
float mAlphaCached;
int mVpCached;
bool mTexture;
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
index e6b5c7181..f9c305d79 100644
--- a/src/render/shaders/shadersmanager.cpp
+++ b/src/render/shaders/shadersmanager.cpp
@@ -22,6 +22,7 @@
#ifdef USE_OPENGL
+#include "configuration.h"
#include "logger.h"
#include "settings.h"
@@ -111,4 +112,10 @@ ShaderProgram *ShadersManager::createProgram(const std::string &vertex,
return nullptr;
}
+ShaderProgram *ShadersManager::getSimpleProgram()
+{
+ const std::string dir = paths.getStringValue("shaders");
+ return createProgram(dir + paths.getStringValue("simpleVertexShader"),
+ dir + paths.getStringValue("simpleFragmentShader"));
+}
#endif
diff --git a/src/render/shaders/shadersmanager.h b/src/render/shaders/shadersmanager.h
index ba7d26438..50e714aba 100644
--- a/src/render/shaders/shadersmanager.h
+++ b/src/render/shaders/shadersmanager.h
@@ -39,6 +39,8 @@ class ShadersManager final
ShaderProgram *createProgram(const std::string &vertex,
const std::string &fragment)
A_WARN_UNUSED;
+
+ ShaderProgram *getSimpleProgram();
};
extern ShadersManager shaders;