diff --git a/Makefile.base.mk b/Makefile.base.mk index 0ce426fc..5320c54f 100644 --- 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 index 245daea9..8a2fe040 100644 --- 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 index 8c0d87d0..f7dc1e4e 100644 --- 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(w, h), format); }; + inline void draw(const GraphicsContext& context) + { drawAt(context, Point(0, 0)); }; inline void drawAt(const GraphicsContext& context, int x, int y) { drawAt(context, Point(x, y)); }; diff --git a/dgl/src/ImageBaseWidgets.cpp b/dgl/src/ImageBaseWidgets.cpp index e01e2b10..45aca12f 100644 --- a/dgl/src/ImageBaseWidgets.cpp +++ b/dgl/src/ImageBaseWidgets.cpp @@ -57,7 +57,7 @@ void ImageBaseAboutWindow::setImage(const ImageType& image) template bool ImageBaseAboutWindow::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 index 371c9cca..37061969 100644 --- 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 index 6e733bc9..4b23758b 100644 --- a/dgl/src/OpenGL.cpp +++ b/dgl/src/OpenGL.cpp @@ -63,6 +63,7 @@ void Line::draw(const GraphicsContext&, const T width) drawLine(posStart, posEnd); } +// deprecated calls template void Line::draw() { @@ -122,6 +123,7 @@ void Circle::drawOutline(const GraphicsContext&, const T lineWidth) drawCircle(fPos, fNumSegments, fSize, fSin, fCos, true); } +// deprecated calls template void Circle::draw() { @@ -178,6 +180,7 @@ void Triangle::drawOutline(const GraphicsContext&, const T lineWidth) drawTriangle(pos1, pos2, pos3, true); } +// deprecated calls template void Triangle::draw() { @@ -244,6 +247,7 @@ void Rectangle::drawOutline(const GraphicsContext&, const T lineWidth) drawRectangle(*this, true); } +// deprecated calls template void Rectangle::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& 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(image.getWidth()); + const int h = static_cast(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& s, c void OpenGLImage::drawAt(const GraphicsContext&, const Point& 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(0, 0)); + drawOpenGLImage(*this, Point(0, 0), textureId, setupCalled); } void OpenGLImage::drawAt(const int x, const int y) { - drawAt(Point(x, y)); + drawOpenGLImage(*this, Point(x, y), textureId, setupCalled); } void OpenGLImage::drawAt(const Point& 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(size.getWidth()); - const int h = static_cast(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& pos) template <> void ImageBaseAboutWindow::onDisplay() { - img.draw(); + const GraphicsContext& context(getGraphicsContext()); + img.draw(context); } template class ImageBaseAboutWindow; diff --git a/tests/Makefile b/tests/Makefile index e1d3e8c3..24c9385b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,9 +4,6 @@ # Created by falkTX # -# debug mode by default -DEBUG=true - include ../Makefile.base.mk # ---------------------------------------------------------------------------------------------------------------------