summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-01 17:51:43 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-01 17:51:43 +0300
commitc195c960fc2ce7a5a211c26310ae98bfe39ab777 (patch)
treeb958a2181f84ca0de25bdd25d3585ae2b919fc25
parent5adcad73b15aafa56ef77c794bf7ebfeff28049b (diff)
downloadplus-c195c960fc2ce7a5a211c26310ae98bfe39ab777.tar.gz
plus-c195c960fc2ce7a5a211c26310ae98bfe39ab777.tar.bz2
plus-c195c960fc2ce7a5a211c26310ae98bfe39ab777.tar.xz
plus-c195c960fc2ce7a5a211c26310ae98bfe39ab777.zip
Add OpenGL GL_ARB_sampler_objects extension binding.
-rw-r--r--src/graphicsmanager.cpp35
-rw-r--r--src/mgl.cpp4
-rw-r--r--src/mgl.h11
3 files changed, 37 insertions, 13 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index d10b5de9e..4b59c68f2 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -48,6 +48,16 @@
#include "debug.h"
+#ifdef WIN32
+#define getFunction(name) wglGetProcAddress(name)
+#else
+#define getFunction(name) glXGetProcAddress(\
+ reinterpret_cast<const GLubyte*>(name))
+#endif
+
+#define assignFunction(func, name) m##func \
+ = reinterpret_cast<func##_t>(getFunction(name))
+
GraphicsManager graphicsManager;
GraphicsManager::GraphicsManager() :
@@ -221,6 +231,9 @@ Graphics *GraphicsManager::createGraphics()
void GraphicsManager::updateExtensions()
{
#ifdef USE_OPENGL
+ if (checkGLVersion(3, 0))
+ assignFunction(glGetStringi, "glGetStringi");
+
mExtensions.clear();
logger->log1("opengl extensions: ");
if (checkGLVersion(3, 0))
@@ -549,16 +562,6 @@ void GraphicsManager::deleteFBO(FBOInfo *fbo)
#endif
}
-#ifdef WIN32
-#define getFunction(name) wglGetProcAddress(name)
-#else
-#define getFunction(name) glXGetProcAddress(\
- reinterpret_cast<const GLubyte*>(name))
-#endif
-
-#define assignFunction(func, name) m##func \
- = reinterpret_cast<func##_t>(getFunction(name))
-
void GraphicsManager::initOpenGLFunctions()
{
#ifdef USE_OPENGL
@@ -595,8 +598,14 @@ void GraphicsManager::initOpenGLFunctions()
config.setValue("usefbo", false);
}
- if (checkGLVersion(3, 0))
- assignFunction(glGetStringi, "glGetStringi");
+ // Texture sampler
+ if (checkGLVersion(1, 0) && supportExtension("GL_ARB_sampler_objects"))
+ {
+ assignFunction(glGenSamplers, "glGenSamplers");
+ assignFunction(glDeleteSamplers, "glDeleteSamplers");
+ assignFunction(glBindSampler, "glBindSampler");
+ assignFunction(glSamplerParameteri, "glSamplerParameteri");
+ }
#ifdef WIN32
assignFunction(wglGetExtensionsString, "wglGetExtensionsStringARB");
@@ -624,8 +633,8 @@ void GraphicsManager::initOpenGL()
{
#ifdef USE_OPENGL
setGLVersion();
- initOpenGLFunctions();
updateExtensions();
+ initOpenGLFunctions();
updatePlanformExtensions();
updateLimits();
#endif
diff --git a/src/mgl.cpp b/src/mgl.cpp
index 6ed921b54..58e832b33 100644
--- a/src/mgl.cpp
+++ b/src/mgl.cpp
@@ -34,6 +34,10 @@ defName(glFramebufferRenderbuffer);
defName(glDeleteFramebuffers);
defName(glDeleteRenderbuffers);
defName(glGetStringi);
+defName(glGenSamplers);
+defName(glDeleteSamplers);
+defName(glBindSampler);
+defName(glSamplerParameteri);
#ifdef WIN32
defName(wglGetExtensionsString);
diff --git a/src/mgl.h b/src/mgl.h
index 3c611e9ac..8526dbc67 100644
--- a/src/mgl.h
+++ b/src/mgl.h
@@ -51,6 +51,13 @@ typedef void (APIENTRY *glDeleteFramebuffers_t) (GLsizei, const GLuint *);
typedef void (APIENTRY *glDeleteRenderbuffers_t) (GLsizei, const GLuint *);
typedef const GLubyte *(APIENTRY *glGetStringi_t) (GLenum, GLuint);
+typedef void (APIENTRY *glGenSamplers_t) (GLsizei count, GLuint *samplers);
+typedef void (APIENTRY *glDeleteSamplers_t)
+ (GLsizei count, const GLuint * samplers);
+typedef void (APIENTRY *glBindSampler_t) (GLuint unit, GLuint sampler);
+typedef void (APIENTRY *glSamplerParameteri_t)
+ (GLuint sampler, GLenum pname, GLint param);
+
defNameE(glGenRenderbuffers);
defNameE(glBindRenderbuffer);
defNameE(glRenderbufferStorage);
@@ -61,6 +68,10 @@ defNameE(glFramebufferRenderbuffer);
defNameE(glDeleteFramebuffers);
defNameE(glDeleteRenderbuffers);
defNameE(glGetStringi);
+defNameE(glGenSamplers);
+defNameE(glDeleteSamplers);
+defNameE(glBindSampler);
+defNameE(glSamplerParameteri);
#ifdef WIN32
typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc);