summaryrefslogtreecommitdiff
path: root/src/graphicsmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-01 23:32:51 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-01 23:45:06 +0300
commit7fa069aec585316c34ada298ec557c7e800bf8f3 (patch)
tree64cb7078677a695eb9cc429e4546114d06ff6d37 /src/graphicsmanager.cpp
parentc195c960fc2ce7a5a211c26310ae98bfe39ab777 (diff)
downloadmanaplus-7fa069aec585316c34ada298ec557c7e800bf8f3.tar.gz
manaplus-7fa069aec585316c34ada298ec557c7e800bf8f3.tar.bz2
manaplus-7fa069aec585316c34ada298ec557c7e800bf8f3.tar.xz
manaplus-7fa069aec585316c34ada298ec557c7e800bf8f3.zip
Using GL_ARB_sampler_objects.
Diffstat (limited to 'src/graphicsmanager.cpp')
-rw-r--r--src/graphicsmanager.cpp62
1 files changed, 58 insertions, 4 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 4b59c68f2..604f0eb3f 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -20,12 +20,10 @@
#include "graphicsmanager.h"
+#ifdef USE_OPENGL
#ifndef WIN32
-#define GL_GLEXT_PROTOTYPES 1
#include "GL/glx.h"
-// hack to hide warnings
-#undef GL_GLEXT_VERSION
-#undef GL_GLEXT_PROTOTYPES
+#endif
#endif
#include "configuration.h"
@@ -66,12 +64,20 @@ GraphicsManager::GraphicsManager() :
mPlatformMinor(0),
mPlatformMajor(0),
mMaxVertices(500),
+#ifdef USE_OPENGL
+ mUseTextureSampler(true),
+ mTextureSampler(0),
+#endif
mUseAtlases(false)
{
}
GraphicsManager::~GraphicsManager()
{
+#ifdef USE_OPENGL
+ if (mglGenSamplers && mTextureSampler)
+ mglDeleteSamplers(1, &mTextureSampler);
+#endif
}
int GraphicsManager::startDetection()
@@ -187,17 +193,20 @@ void GraphicsManager::initGraphics(bool noOpenGL)
imageHelper = new SDLImageHelper;
sdlImageHelper = imageHelper;
mainGraphics = new Graphics;
+ mUseTextureSampler = false;
break;
case 1:
default:
imageHelper = new OpenGLImageHelper;
sdlImageHelper = new SDLImageHelper;
mainGraphics = new NormalOpenGLGraphics;
+ mUseTextureSampler = true;
break;
case 2:
imageHelper = new OpenGLImageHelper;
sdlImageHelper = new SDLImageHelper;
mainGraphics = new SafeOpenGLGraphics;
+ mUseTextureSampler = false;
break;
};
mUseAtlases = imageHelper->useOpenGL()
@@ -605,6 +614,14 @@ void GraphicsManager::initOpenGLFunctions()
assignFunction(glDeleteSamplers, "glDeleteSamplers");
assignFunction(glBindSampler, "glBindSampler");
assignFunction(glSamplerParameteri, "glSamplerParameteri");
+ if (mglGenSamplers && config.getBoolValue("useTextureSampler"))
+ mUseTextureSampler &= true;
+ else
+ mUseTextureSampler = false;
+ }
+ else
+ {
+ mUseTextureSampler = false;
}
#ifdef WIN32
@@ -636,6 +653,43 @@ void GraphicsManager::initOpenGL()
updateExtensions();
initOpenGLFunctions();
updatePlanformExtensions();
+ createTextureSampler();
updateLimits();
#endif
}
+
+void GraphicsManager::createTextureSampler()
+{
+ OpenGLImageHelper::setUseTextureSampler(mUseTextureSampler);
+ if (mUseTextureSampler)
+ {
+ logger->log("using texture sampler");
+ getLastError();
+ mglGenSamplers(1, &mTextureSampler);
+ if (getLastError() != GL_NO_ERROR)
+ {
+ mUseTextureSampler = false;
+ logger->log("texture sampler error");
+ return;
+ }
+ OpenGLImageHelper::initTextureSampler(mTextureSampler);
+ mglBindSampler(0, mTextureSampler);
+ if (getLastError() != GL_NO_ERROR)
+ {
+ mUseTextureSampler = false;
+ logger->log("texture sampler error");
+ }
+ }
+}
+
+unsigned int GraphicsManager::getLastError()
+{
+ GLenum tmp = glGetError();
+ GLenum error = GL_NO_ERROR;
+ while (tmp != GL_NO_ERROR)
+ {
+ error = tmp;
+ tmp = glGetError();
+ }
+ return error;
+}