summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/graphicsmanager.cpp12
-rw-r--r--src/render/mglcheck.h31
-rw-r--r--src/render/mobileopenglgraphics.cpp2
-rw-r--r--src/render/modernopenglgraphics.cpp2
-rw-r--r--src/render/normalopenglgraphics.cpp2
-rw-r--r--src/render/safeopenglgraphics.cpp2
-rw-r--r--src/resources/openglimagehelper.cpp5
-rw-r--r--src/utils/glxhelper.cpp7
10 files changed, 53 insertions, 12 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d20f5a973..b9337b715 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -851,6 +851,7 @@ SET(SRCS
resources/map/objectslayer.h
render/mgl.cpp
render/mgl.h
+ render/mglcheck.h
render/mgldefines.h
render/mglemu.cpp
render/mglemu.h
diff --git a/src/Makefile.am b/src/Makefile.am
index a86814fd3..231ab5951 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -972,6 +972,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/map/objectslayer.h \
render/mgl.cpp \
render/mgl.h \
+ render/mglcheck.h \
render/mgldefines.h \
render/mglemu.cpp \
render/mglemu.h \
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 258c0f9f5..3e9701115 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -43,6 +43,7 @@
#include "settings.h"
#include "render/graphics.h"
+#include "render/mglcheck.h"
#include "render/mgl.h"
#include "render/mglemu.h"
#include "render/mobileopenglgraphics.h"
@@ -135,7 +136,7 @@ GraphicsManager::GraphicsManager() :
GraphicsManager::~GraphicsManager()
{
#ifdef USE_OPENGL
- if (mglGenSamplers && mTextureSampler)
+ if (isGLNotNull(mglGenSamplers) && mTextureSampler)
mglDeleteSamplers(1, &mTextureSampler);
#endif
}
@@ -856,10 +857,15 @@ void GraphicsManager::initOpenGLFunctions()
assignFunction(glDeleteSamplers);
assignFunction(glBindSampler);
assignFunction(glSamplerParameteri);
- if (mglGenSamplers && config.getBoolValue("useTextureSampler"))
+ if (isGLNotNull(mglGenSamplers)
+ && config.getBoolValue("useTextureSampler"))
+ {
mUseTextureSampler &= true;
+ }
else
+ {
mUseTextureSampler = false;
+ }
}
else
{
@@ -965,7 +971,7 @@ void GraphicsManager::initOpenGLFunctions()
{
logger->log1("found GL_EXT_debug_label");
assignFunctionEXT(glLabelObject);
- if (!mglLabelObject)
+ if (isGLNull(mglLabelObject))
assignFunction2(glLabelObject, "glObjectLabel");
assignFunctionEXT(glGetObjectLabel);
}
diff --git a/src/render/mglcheck.h b/src/render/mglcheck.h
new file mode 100644
index 000000000..8355d8ab9
--- /dev/null
+++ b/src/render/mglcheck.h
@@ -0,0 +1,31 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RENDER_MGLCHECK_H
+#define RENDER_MGLCHECK_H
+
+#include "main.h"
+#ifdef USE_OPENGL
+
+#define isGLNull(func) (!(func))
+#define isGLNotNull(func) ((func) != nullptr)
+
+#endif // USE_OPENGL
+#endif // RENDER_MGLCHECK_H
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index b0e78c534..339632f34 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -857,7 +857,7 @@ void MobileOpenGLGraphics::updateScreen()
SDL_GL_SwapBuffers();
#endif
#ifdef DEBUG_OPENGL
- if (mglFrameTerminator)
+ if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
#endif
// may be need clear?
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index fc5e40062..5d87d415f 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -830,7 +830,7 @@ void ModernOpenGLGraphics::updateScreen()
SDL_GL_SwapBuffers();
#endif
#ifdef DEBUG_OPENGL
- if (mglFrameTerminator)
+ if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
#endif
// may be need clear?
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index f32003d49..81ed5ea71 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -1190,7 +1190,7 @@ void NormalOpenGLGraphics::updateScreen()
SDL_GL_SwapBuffers();
#endif
#ifdef DEBUG_OPENGL
- if (mglFrameTerminator)
+ if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
#endif
// may be need clear?
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 1f381b2b9..c40637f68 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -464,7 +464,7 @@ void SafeOpenGLGraphics::updateScreen()
SDL_GL_SwapBuffers();
#endif
#ifdef DEBUG_OPENGL
- if (mglFrameTerminator)
+ if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
#endif
BLOCK_END("Graphics::updateScreen")
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index 6187764e9..c830c6321 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -28,6 +28,7 @@
#include "logger.h"
#include "render/mgl.h"
+#include "render/mglcheck.h"
#include "render/mobileopenglgraphics.h"
#include "render/modernopenglgraphics.h"
#include "render/normalopenglgraphics.h"
@@ -276,7 +277,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
#ifdef DEBUG_OPENGL
// disabled for now, because debugger cant show it
-// if (mglLabelObject)
+// if (isGLNotNull(mglLabelObject))
// {
// const char *const text = "image text";
// mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
@@ -370,7 +371,7 @@ void OpenGLImageHelper::postInit()
void OpenGLImageHelper::invalidate(const GLuint textureId)
{
- if (mglInvalidateTexImage)
+ if (isGLNotNull(mglInvalidateTexImage))
{
logger->log("invalidate: %u", textureId);
mglInvalidateTexImage(textureId, 0);
diff --git a/src/utils/glxhelper.cpp b/src/utils/glxhelper.cpp
index e27124325..240e4b8d5 100644
--- a/src/utils/glxhelper.cpp
+++ b/src/utils/glxhelper.cpp
@@ -24,6 +24,7 @@
#include "logger.h"
+#include "render/mglcheck.h"
#include "render/mglx.h"
#include "render/mglxtypes.h"
@@ -46,9 +47,9 @@ void *GlxHelper::createContext(const unsigned long window,
XSync(display, false);
int (*handler) (Display *, XErrorEvent *) = XSetErrorHandler(ErrorHandler);
void *context = mglXGetCurrentContext();
- if (!mglXGetCurrentContext
- || !mglXCreateContextAttribs
- || !mglXChooseFBConfig)
+ if (isGLNull(mglXGetCurrentContext)
+ || isGLNull(mglXCreateContextAttribs)
+ || isGLNull(mglXChooseFBConfig))
{
logger->log("Cant change context, functions in driver "
"not implimented");