commit 2e947574715a19246f5b16e00c4568210e7f5d31
parent f626ea0f7ea1ef09a5fa912825dcc1a16eb751df
Author: falkTX <falktx@falktx.com>
Date: Mon, 17 May 2021 22:25:17 +0100
Handle deprecated functions in core code
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
7 files changed, 80 insertions(+), 46 deletions(-)
diff --git a/Makefile.base.mk b/Makefile.base.mk
@@ -327,6 +327,10 @@ DGL_FLAGS += -DHAVE_VULKAN
VULKAN_FLAGS = $(shell $(PKG_CONFIG) --cflags vulkan)
VULKAN_LIBS = $(shell $(PKG_CONFIG) --libs vulkan)
+ifneq ($(WINDOWS),true)
+VULKAN_LIBS += -ldl
+endif
+
endif
# ---------------------------------------------------------------------------------------------------------------------
diff --git a/dgl/ImageWidgets.hpp b/dgl/ImageWidgets.hpp
@@ -21,6 +21,12 @@
#include "ImageBaseWidgets.hpp"
#include "SubWidget.hpp"
+// TODO switch to use templated image type after merging widget-related PRs
+#if defined(__GNUC__) && (__GNUC__ >= 6)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
@@ -241,4 +247,8 @@ private:
END_NAMESPACE_DGL
+#if defined(__GNUC__) && (__GNUC__ >= 6)
+# pragma GCC diagnostic pop
+#endif
+
#endif // DGL_IMAGE_WIDGETS_HPP_INCLUDED
diff --git a/dgl/OpenGL.hpp b/dgl/OpenGL.hpp
@@ -198,6 +198,8 @@ public:
// FIXME this should not be needed
inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format)
{ loadFromMemory(rawData, Size<uint>(w, h), format); };
+ inline void draw(const GraphicsContext& context)
+ { drawAt(context, Point<int>(0, 0)); };
inline void drawAt(const GraphicsContext& context, int x, int y)
{ drawAt(context, Point<int>(x, y)); };
diff --git a/dgl/src/ImageBaseWidgets.cpp b/dgl/src/ImageBaseWidgets.cpp
@@ -57,7 +57,7 @@ void ImageBaseAboutWindow<ImageType>::setImage(const ImageType& image)
template <class ImageType>
bool ImageBaseAboutWindow<ImageType>::onKeyboard(const KeyboardEvent& ev)
{
- if (ev.press && ev.key == kCharEscape)
+ if (ev.press && ev.key == kKeyEscape)
{
close();
return true;
diff --git a/dgl/src/ImageWidgets.cpp b/dgl/src/ImageWidgets.cpp
@@ -20,9 +20,15 @@
#include "Common.hpp"
#include "WidgetPrivateData.hpp"
-// FIXME make this code more generic and move GL specific bits to OpenGL.cpp
+// TODO make this code more generic and move GL specific bits to OpenGL.cpp
#include "../OpenGL.hpp"
+// TODO switch to use templated image type after merging widget-related PRs
+#if defined(__GNUC__) && (__GNUC__ >= 6)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
@@ -946,3 +952,7 @@ bool ImageSwitch::onMouse(const MouseEvent& ev)
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
+
+#if defined(__GNUC__) && (__GNUC__ >= 6)
+# pragma GCC diagnostic pop
+#endif
diff --git a/dgl/src/OpenGL.cpp b/dgl/src/OpenGL.cpp
@@ -63,6 +63,7 @@ void Line<T>::draw(const GraphicsContext&, const T width)
drawLine<T>(posStart, posEnd);
}
+// deprecated calls
template<typename T>
void Line<T>::draw()
{
@@ -122,6 +123,7 @@ void Circle<T>::drawOutline(const GraphicsContext&, const T lineWidth)
drawCircle<T>(fPos, fNumSegments, fSize, fSin, fCos, true);
}
+// deprecated calls
template<typename T>
void Circle<T>::draw()
{
@@ -178,6 +180,7 @@ void Triangle<T>::drawOutline(const GraphicsContext&, const T lineWidth)
drawTriangle<T>(pos1, pos2, pos3, true);
}
+// deprecated calls
template<typename T>
void Triangle<T>::draw()
{
@@ -244,6 +247,7 @@ void Rectangle<T>::drawOutline(const GraphicsContext&, const T lineWidth)
drawRectangle<T>(*this, true);
}
+// deprecated calls
template<typename T>
void Rectangle<T>::draw()
{
@@ -312,6 +316,47 @@ static void setupOpenGLImage(const OpenGLImage& image, GLuint textureId)
glDisable(GL_TEXTURE_2D);
}
+static void drawOpenGLImage(const OpenGLImage& image, const Point<int>& pos, const GLuint textureId, bool& setupCalled)
+{
+ if (textureId == 0 || image.isInvalid())
+ return;
+
+ if (! setupCalled)
+ {
+ setupOpenGLImage(image, textureId);
+ setupCalled = true;
+ }
+
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+
+ glBegin(GL_QUADS);
+
+ {
+ const int x = pos.getX();
+ const int y = pos.getY();
+ const int w = static_cast<int>(image.getWidth());
+ const int h = static_cast<int>(image.getHeight());
+
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex2d(x, y);
+
+ glTexCoord2f(1.0f, 0.0f);
+ glVertex2d(x+w, y);
+
+ glTexCoord2f(1.0f, 1.0f);
+ glVertex2d(x+w, y+h);
+
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex2d(x, y+h);
+ }
+
+ glEnd();
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glDisable(GL_TEXTURE_2D);
+}
+
OpenGLImage::OpenGLImage()
: ImageBase(),
textureId(0),
@@ -362,7 +407,7 @@ void OpenGLImage::loadFromMemory(const char* const rdata, const Size<uint>& s, c
void OpenGLImage::drawAt(const GraphicsContext&, const Point<int>& pos)
{
- drawAt(pos);
+ drawOpenGLImage(*this, pos, textureId, setupCalled);
}
OpenGLImage& OpenGLImage::operator=(const OpenGLImage& image) noexcept
@@ -374,55 +419,20 @@ OpenGLImage& OpenGLImage::operator=(const OpenGLImage& image) noexcept
return *this;
}
+// deprecated calls
void OpenGLImage::draw()
{
- drawAt(Point<int>(0, 0));
+ drawOpenGLImage(*this, Point<int>(0, 0), textureId, setupCalled);
}
void OpenGLImage::drawAt(const int x, const int y)
{
- drawAt(Point<int>(x, y));
+ drawOpenGLImage(*this, Point<int>(x, y), textureId, setupCalled);
}
void OpenGLImage::drawAt(const Point<int>& pos)
{
- if (textureId == 0 || isInvalid())
- return;
-
- if (! setupCalled)
- {
- setupOpenGLImage(*this, textureId);
- setupCalled = true;
- }
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, textureId);
-
- glBegin(GL_QUADS);
-
- {
- const int x = pos.getX();
- const int y = pos.getY();
- const int w = static_cast<int>(size.getWidth());
- const int h = static_cast<int>(size.getHeight());
-
- glTexCoord2f(0.0f, 0.0f);
- glVertex2d(x, y);
-
- glTexCoord2f(1.0f, 0.0f);
- glVertex2d(x+w, y);
-
- glTexCoord2f(1.0f, 1.0f);
- glVertex2d(x+w, y+h);
-
- glTexCoord2f(0.0f, 1.0f);
- glVertex2d(x, y+h);
- }
-
- glEnd();
-
- glBindTexture(GL_TEXTURE_2D, 0);
- glDisable(GL_TEXTURE_2D);
+ drawOpenGLImage(*this, pos, textureId, setupCalled);
}
// -----------------------------------------------------------------------
@@ -430,7 +440,8 @@ void OpenGLImage::drawAt(const Point<int>& pos)
template <>
void ImageBaseAboutWindow<OpenGLImage>::onDisplay()
{
- img.draw();
+ const GraphicsContext& context(getGraphicsContext());
+ img.draw(context);
}
template class ImageBaseAboutWindow<OpenGLImage>;
diff --git a/tests/Makefile b/tests/Makefile
@@ -4,9 +4,6 @@
# Created by falkTX
#
-# debug mode by default
-DEBUG=true
-
include ../Makefile.base.mk
# ---------------------------------------------------------------------------------------------------------------------