diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-12-10 02:59:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-12-10 15:12:12 +0300 |
commit | 740b10240414ae3b7c37ee21fd131ffdb296b2b9 (patch) | |
tree | b1c03b4c9eeb8790033c79cece88162597711fbb /src/render/shaders/shadersmanager.cpp | |
parent | 54d0234c8334bcd61ffb655a57e6147fd279b9e1 (diff) | |
download | manaplus-740b10240414ae3b7c37ee21fd131ffdb296b2b9.tar.gz manaplus-740b10240414ae3b7c37ee21fd131ffdb296b2b9.tar.bz2 manaplus-740b10240414ae3b7c37ee21fd131ffdb296b2b9.tar.xz manaplus-740b10240414ae3b7c37ee21fd131ffdb296b2b9.zip |
Add function for load OpenGL ES 2 shaders.
Diffstat (limited to 'src/render/shaders/shadersmanager.cpp')
-rw-r--r-- | src/render/shaders/shadersmanager.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp index 345093074..c79abe2cc 100644 --- a/src/render/shaders/shadersmanager.cpp +++ b/src/render/shaders/shadersmanager.cpp @@ -63,7 +63,8 @@ Shader *ShadersManager::createShader(const unsigned int type, } ShaderProgram *ShadersManager::createProgram(const std::string &vertex, - const std::string &fragment) + const std::string &fragment, + const bool isNewShader) { Shader *const vertexShader = static_cast<Shader*>( resourceManager->getShader(GL_VERTEX_SHADER, vertex)); @@ -89,7 +90,10 @@ ShaderProgram *ShadersManager::createProgram(const std::string &vertex, mglAttachShader(programId, vertexShader->getShaderId()); mglAttachShader(programId, fragmentShader->getShaderId()); - mglBindFragDataLocation(programId, 0, "outColor"); + if (isNewShader) + mglBindFragDataLocation(programId, 0, "outColor"); + else + mglBindAttribLocation(programId, 0, "position"); mglLinkProgram(programId); GLint isLinked = 0; mglGetProgramiv(programId, GL_LINK_STATUS, &isLinked); @@ -122,7 +126,16 @@ ShaderProgram *ShadersManager::getSimpleProgram() { const std::string dir = paths.getStringValue("shaders"); return createProgram(dir + paths.getStringValue("simpleVertexShader"), - dir + paths.getStringValue("simpleFragmentShader")); + 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 |