summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-08 18:38:07 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-08 18:38:07 +0300
commit7a0ce777e5d7e3c5ba562ea1c811c0c3cb17a976 (patch)
tree04528345be1561b7970b4c1f1c6e1693e5e2f84e /src/render
parente7f05704102d204ce73f97bca5f62312adcd1c2b (diff)
downloadManaVerse-7a0ce777e5d7e3c5ba562ea1c811c0c3cb17a976.tar.gz
ManaVerse-7a0ce777e5d7e3c5ba562ea1c811c0c3cb17a976.tar.bz2
ManaVerse-7a0ce777e5d7e3c5ba562ea1c811c0c3cb17a976.tar.xz
ManaVerse-7a0ce777e5d7e3c5ba562ea1c811c0c3cb17a976.zip
Add simple shader creation.
Diffstat (limited to 'src/render')
-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
5 files changed, 30 insertions, 0 deletions
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;