summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-11 23:11:07 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-12 01:13:04 +0300
commitfacd5fbaa7724ecb56f30fbbefcab9a426d4966b (patch)
tree32896d0d1276417a97f506f3eac856d10e17b186
parent8127238e3e06ff9d7952dde9f931c41c0947ba9c (diff)
downloadplus-facd5fbaa7724ecb56f30fbbefcab9a426d4966b.tar.gz
plus-facd5fbaa7724ecb56f30fbbefcab9a426d4966b.tar.bz2
plus-facd5fbaa7724ecb56f30fbbefcab9a426d4966b.tar.xz
plus-facd5fbaa7724ecb56f30fbbefcab9a426d4966b.zip
Fix FBO under windows.
-rw-r--r--src/graphicsmanager.cpp18
-rw-r--r--src/gui/setup_other.cpp2
-rw-r--r--src/mgl.cpp2
-rw-r--r--src/mgl.h9
-rw-r--r--src/normalopenglgraphics.cpp4
-rw-r--r--src/safeopenglgraphics.cpp4
6 files changed, 25 insertions, 14 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 79830294e..d0464ae45 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -21,10 +21,16 @@
#include "graphicsmanager.h"
#define GL_GLEXT_PROTOTYPES 1
+#ifndef WIN32
#include "GL/glx.h"
// hack to hide warnings
#undef GL_GLEXT_VERSION
#undef GL_GLEXT_PROTOTYPES
+//#else
+//#include "GL/glext.h"
+//#undef GL_GLEXT_VERSION
+//#undef WIN32_LEAN_AND_MEAN
+#endif
#include "configuration.h"
#include "graphics.h"
@@ -388,16 +394,16 @@ void GraphicsManager::deleteFBO(FBOInfo *fbo)
if (!fbo)
return;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ mglBindFramebuffer(GL_FRAMEBUFFER, 0);
if (fbo->fboId)
{
- glDeleteFramebuffersEXT(1, &fbo->fboId);
+ mglDeleteFramebuffers(1, &fbo->fboId);
fbo->fboId = 0;
}
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+ mglBindRenderbuffer(GL_RENDERBUFFER, 0);
if (fbo->rboId)
{
- glDeleteRenderbuffersEXT(1, &fbo->rboId);
+ mglDeleteRenderbuffers(1, &fbo->rboId);
fbo->rboId = 0;
}
if (fbo->textureId)
@@ -428,6 +434,8 @@ void GraphicsManager::initOpenGLFunctions()
mglBindFramebuffer = (glBindFramebuffer_t)getFunction("glBindFramebuffer");
mglFramebufferTexture2D = (glFramebufferTexture2D_t)getFunction("glFramebufferTexture2D");
mglFramebufferRenderbuffer = (glFramebufferRenderbuffer_t)getFunction("glFramebufferRenderbuffer");
+ mglDeleteFramebuffers = (glDeleteFramebuffers_t)getFunction("glDeleteFramebuffers");
+ mglDeleteRenderbuffers = (glDeleteRenderbuffers_t)getFunction("glDeleteRenderbuffers");
}
else if (supportExtension("GL_EXT_framebuffer_object"))
{ // old frame buffer extension
@@ -438,6 +446,8 @@ void GraphicsManager::initOpenGLFunctions()
mglBindFramebuffer = (glBindFramebuffer_t)getFunction("glBindFramebufferEXT");
mglFramebufferTexture2D = (glFramebufferTexture2D_t)getFunction("glFramebufferTexture2DEXT");
mglFramebufferRenderbuffer = (glFramebufferRenderbuffer_t)getFunction("glFramebufferRenderbufferEXT");
+ mglDeleteFramebuffers = (glDeleteFramebuffers_t)getFunction("glDeleteFramebuffersEXT");
+ mglDeleteRenderbuffers = (glDeleteRenderbuffers_t)getFunction("glDeleteRenderbuffersEXT");
}
else
{ // no frame buffer support
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index b88d82efa..bfc3059c7 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -227,10 +227,8 @@ Setup_Other::Setup_Other()
new SetupItemCheckBox(_("Hide shield sprite"), "", "hideShield",
this, "hideShieldEvent");
-#if !defined(_WIN32)
new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
"", "usefbo", this, "usefboEvent");
-#endif
new SetupItemIntTextField(_("Network delay between sub servers"),
"", "networksleep", this, "networksleepEvent", 0, 10000);
diff --git a/src/mgl.cpp b/src/mgl.cpp
index 856a3575c..a73536dac 100644
--- a/src/mgl.cpp
+++ b/src/mgl.cpp
@@ -31,3 +31,5 @@ defName(glGenFramebuffers);
defName(glBindFramebuffer);
defName(glFramebufferTexture2D);
defName(glFramebufferRenderbuffer);
+defName(glDeleteFramebuffers);
+defName(glDeleteRenderbuffers);
diff --git a/src/mgl.h b/src/mgl.h
index 3721c6a9f..ae2f8583c 100644
--- a/src/mgl.h
+++ b/src/mgl.h
@@ -26,6 +26,11 @@
#include <SDL_opengl.h>
#include <GL/glext.h>
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+
#define defNameE(name) extern name##_t m##name
typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *);
@@ -40,6 +45,8 @@ typedef void (APIENTRY *glFramebufferTexture2D_t)(GLenum target,
GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (APIENTRY *glFramebufferRenderbuffer_t)(GLenum target,
GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRY *glDeleteFramebuffers_t) (GLsizei, const GLuint *);
+typedef void (APIENTRY *glDeleteRenderbuffers_t) (GLsizei, const GLuint *);
defNameE(glGenRenderbuffers);
defNameE(glBindRenderbuffer);
@@ -48,5 +55,7 @@ defNameE(glGenFramebuffers);
defNameE(glBindFramebuffer);
defNameE(glFramebufferTexture2D);
defNameE(glFramebufferRenderbuffer);
+defNameE(glDeleteFramebuffers);
+defNameE(glDeleteRenderbuffers);
#endif
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index ae28e2030..75eafc732 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -1003,10 +1003,8 @@ void NormalOpenGLGraphics::_endDraw()
void NormalOpenGLGraphics::prepareScreenshot()
{
-#if !defined(_WIN32)
if (config.getBoolValue("usefbo"))
graphicsManager.createFBO(mTarget->w, mTarget->h, &mFbo);
-#endif
}
SDL_Surface* NormalOpenGLGraphics::getScreenshot()
@@ -1049,10 +1047,8 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot()
free(buf);
-#if !defined(_WIN32)
if (config.getBoolValue("usefbo"))
graphicsManager.deleteFBO(&mFbo);
-#endif
glPixelStorei(GL_PACK_ALIGNMENT, pack);
diff --git a/src/safeopenglgraphics.cpp b/src/safeopenglgraphics.cpp
index adc49795c..1cc9bc3d8 100644
--- a/src/safeopenglgraphics.cpp
+++ b/src/safeopenglgraphics.cpp
@@ -425,10 +425,8 @@ void SafeOpenGLGraphics::_endDraw()
void SafeOpenGLGraphics::prepareScreenshot()
{
-#if !defined(_WIN32)
if (config.getBoolValue("usefbo"))
graphicsManager.createFBO(mTarget->w, mTarget->h, &mFbo);
-#endif
}
SDL_Surface* SafeOpenGLGraphics::getScreenshot()
@@ -471,10 +469,8 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot()
free(buf);
-#if !defined(_WIN32)
if (config.getBoolValue("usefbo"))
graphicsManager.deleteFBO(&mFbo);
-#endif
glPixelStorei(GL_PACK_ALIGNMENT, pack);