summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-14 12:43:25 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-14 12:55:01 +0300
commitfe7a1342dc71a412a177a69b022ac1d1cc1fbdc6 (patch)
treebb19ed9d1e21b4b8517d588bca0a18c1c0fcc359
parentc5fd70049a0ebdc14e49af3e5215521085a44b46 (diff)
downloadmanaplus-fe7a1342dc71a412a177a69b022ac1d1cc1fbdc6.tar.gz
manaplus-fe7a1342dc71a412a177a69b022ac1d1cc1fbdc6.tar.bz2
manaplus-fe7a1342dc71a412a177a69b022ac1d1cc1fbdc6.tar.xz
manaplus-fe7a1342dc71a412a177a69b022ac1d1cc1fbdc6.zip
Add support for GLX and wGL extensions.
-rw-r--r--src/graphics.cpp1
-rw-r--r--src/graphicsmanager.cpp90
-rw-r--r--src/graphicsmanager.h10
-rw-r--r--src/mgl.cpp6
-rw-r--r--src/mgl.h7
5 files changed, 113 insertions, 1 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 05083506b..b852ccb2b 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -169,6 +169,7 @@ bool Graphics::setOpenGLMode()
graphicsManager.setGLVersion();
graphicsManager.initOpenGLFunctions();
graphicsManager.updateExtensions();
+ graphicsManager.updatePlanformExtensions();
graphicsManager.updateTextureFormat();
updateMemoryInfo();
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 9529cda51..34b16989a 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -48,6 +48,8 @@
#include "test/testmain.h"
+#include <SDL_syswm.h>
+
#include "debug.h"
GraphicsManager graphicsManager;
@@ -83,6 +85,7 @@ bool GraphicsManager::detectGraphics()
setGLVersion();
initOpenGLFunctions();
updateExtensions();
+ updatePlanformExtensions();
std::string vendor = getGLString(GL_VENDOR);
std::string renderer = getGLString(GL_RENDERER);
logger->log("gl vendor: %s", vendor.c_str());
@@ -239,6 +242,83 @@ void GraphicsManager::updateExtensions()
}
}
+void GraphicsManager::updatePlanformExtensions()
+{
+ SDL_SysWMinfo info;
+ SDL_VERSION(&info.version);
+ if (SDL_GetWMInfo(&info))
+ {
+#ifdef WIN32
+ if (!mwglGetExtensionsString)
+ return;
+
+ HDC hdc = GetDC(info.window);
+ if (hdc > 0)
+ {
+ const char *extensions = mwglGetExtensionsString (hdc);
+ if (extensions)
+ {
+ logger->log("wGL extensions:");
+ logger->log1(extensions);
+ splitToStringSet(mPlatformExtensions, extensions, ' ');
+ }
+ }
+#elif defined USE_X11
+ Display *display = info.info.x11.display;
+ if (display)
+ {
+ Screen *screen = XDefaultScreenOfDisplay(display);
+ if (!screen)
+ return;
+
+ int screenNum = XScreenNumberOfScreen(screen);
+ const char *extensions = glXQueryExtensionsString(
+ display, screenNum);
+ if (extensions)
+ {
+ logger->log("glx extensions:");
+ logger->log1(extensions);
+ splitToStringSet(mPlatformExtensions, extensions, ' ');
+ }
+ glXQueryVersion(display, &mPlatformMajor, &mPlatformMinor);
+ if (checkPlatformVersion(1, 1))
+ {
+ const char *vendor1 = glXQueryServerString(
+ display, screenNum, GLX_VENDOR);
+ if (vendor1)
+ logger->log("glx server vendor: %s", vendor1);
+ const char *version1 = glXQueryServerString(
+ display, screenNum, GLX_VERSION);
+ if (version1)
+ logger->log("glx server version: %s", version1);
+ const char *extensions1 = glXQueryServerString(
+ display, screenNum, GLX_EXTENSIONS);
+ if (extensions1)
+ {
+ logger->log("glx server extensions:");
+ logger->log1(extensions1);
+ }
+
+ const char *vendor2 = glXGetClientString(display, GLX_VENDOR);
+ if (vendor2)
+ logger->log("glx client vendor: %s", vendor2);
+ const char *version2 = glXGetClientString(
+ display, GLX_VERSION);
+ if (version2)
+ logger->log("glx client version: %s", version2);
+ const char *extensions2 = glXGetClientString(
+ display, GLX_EXTENSIONS);
+ if (extensions2)
+ {
+ logger->log("glx client extensions:");
+ logger->log1(extensions2);
+ }
+ }
+ }
+#endif
+ }
+}
+
bool GraphicsManager::supportExtension(const std::string &ext)
{
return mExtensions.find(ext) != mExtensions.end();
@@ -385,6 +465,12 @@ bool GraphicsManager::checkGLVersion(int major, int minor) const
return mMajor > major || (mMajor == major && mMinor >= minor);
}
+bool GraphicsManager::checkPlatformVersion(int major, int minor) const
+{
+ return mPlatformMajor > major || (mPlatformMajor == major
+ && mPlatformMinor >= minor);
+}
+
void GraphicsManager::createFBO(int width, int height, FBOInfo *fbo)
{
#ifdef USE_OPENGL
@@ -497,4 +583,8 @@ void GraphicsManager::initOpenGLFunctions()
if (checkGLVersion(3, 0))
assignFunction(glGetStringi, "glGetStringi");
+
+#ifdef WIN32
+ assignFunction(wglGetExtensionsString, "wglGetExtensionsStringARB");
+#endif
}
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 6a41da035..9abc3bf23 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -55,6 +55,8 @@ class GraphicsManager
bool checkGLVersion(int major, int minor) const;
+ bool checkPlatformVersion(int major, int minor) const;
+
void createFBO(int width, int height, FBOInfo *fbo);
void deleteFBO(FBOInfo *fbo);
@@ -63,16 +65,24 @@ class GraphicsManager
void updateExtensions();
+ void updatePlanformExtensions();
+
Graphics *createGraphics();
private:
std::set<std::string> mExtensions;
+ std::set<std::string> mPlatformExtensions;
+
std::string mVersionString;
int mMinor;
int mMajor;
+
+ int mPlatformMinor;
+
+ int mPlatformMajor;
};
extern GraphicsManager graphicsManager;
diff --git a/src/mgl.cpp b/src/mgl.cpp
index 6dafb1258..6ed921b54 100644
--- a/src/mgl.cpp
+++ b/src/mgl.cpp
@@ -33,4 +33,8 @@ defName(glFramebufferTexture2D);
defName(glFramebufferRenderbuffer);
defName(glDeleteFramebuffers);
defName(glDeleteRenderbuffers);
-defName(glGetStringi); \ No newline at end of file
+defName(glGetStringi);
+
+#ifdef WIN32
+defName(wglGetExtensionsString);
+#endif
diff --git a/src/mgl.h b/src/mgl.h
index 8e7002d82..3c611e9ac 100644
--- a/src/mgl.h
+++ b/src/mgl.h
@@ -24,6 +24,7 @@
#define GL_GLEXT_PROTOTYPES 1
#include <SDL_opengl.h>
+#include <SDL_syswm.h>
#include <GL/glext.h>
#define GL_NUM_EXTENSIONS 0x821D
@@ -61,4 +62,10 @@ defNameE(glDeleteFramebuffers);
defNameE(glDeleteRenderbuffers);
defNameE(glGetStringi);
+#ifdef WIN32
+typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc);
+
+defNameE(wglGetExtensionsString);
+#endif
+
#endif