examples/gl/qt: silence compiler warnings
authorMatthew Waters <matthew@centricular.com>
Tue, 14 Jul 2020 04:06:58 +0000 (14:06 +1000)
committerMatthew Waters <matthew@centricular.com>
Tue, 14 Jul 2020 07:07:54 +0000 (17:07 +1000)
-Waggregate-return: used by some Qt clases extensively and not super
useful for this example. Supress it.

warning: "GL_GLEXT_VERSION" redefined: Perform the same workaround as
qmlglsink by defining the old gl/GL.h header guard if the new GL/gl.h
guard exists.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/752>

tests/examples/gl/qt/gl-compat-defines.h [new file with mode: 0644]
tests/examples/gl/qt/meson.build
tests/examples/gl/qt/mousevideooverlay/meson.build
tests/examples/gl/qt/mousevideooverlay/pipeline.cpp
tests/examples/gl/qt/mousevideooverlay/qrenderer.h
tests/examples/gl/qt/qglwidgetvideooverlay/meson.build
tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp
tests/examples/gl/qt/qglwidgetvideooverlay/qglrenderer.h
tests/examples/gl/qt/qglwtextureshare/meson.build
tests/examples/gl/qt/qglwtextureshare/pipeline.cpp
tests/examples/gl/qt/qglwtextureshare/qglrenderer.h

diff --git a/tests/examples/gl/qt/gl-compat-defines.h b/tests/examples/gl/qt/gl-compat-defines.h
new file mode 100644 (file)
index 0000000..4e22ba2
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * GStreamer
+ * Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gst/gl/gstglconfig.h>
+
+/* The glext.h guard was renamed in 2018, but some software which
+ * includes their own copy of the GL headers (such as qt) might have
+ * older version which use the old guard. This would result in the
+ * header being included again (and symbols redefined).
+ *
+ * To avoid this, we define the "old" guard if the "new" guard is
+ * defined.*/
+#if GST_GL_HAVE_OPENGL
+#ifdef __gl_glext_h_
+#ifndef __glext_h_
+#define __glext_h_ 1
+#endif
+#endif
+#endif
index 5c37fc5..523f8a1 100644 (file)
@@ -5,6 +5,8 @@ qt5opengl_dep = dependency('qt5', modules : ['OpenGL'], required : false)
 # FIXME: other platforms
 libgl = cc.find_library ('GL', required : false)
 
+qt_cxx_warn_less = cxx.get_supported_arguments(['-Wno-aggregate-return'])
+
 if qt5gui_dep.found()
   subdir('videooverlay')
   if libgl.found()
index 1788b96..a4f6071 100644 (file)
@@ -13,7 +13,7 @@ moc_headers = [
 
 moc_files = qt5_mod.preprocess(moc_headers : moc_headers)
 executable('mousevideoverlay', sources, moc_files,
-  cpp_args : [gst_plugins_base_args],
+  cpp_args : [gst_plugins_base_args] + qt_cxx_warn_less,
   include_directories: [configinc, libsinc],
   dependencies : [qt5core_dep, qt5gui_dep, gst_dep, video_dep, gstgl_dep, libgl],
   install: false)
index bca4862..a530d96 100644 (file)
@@ -21,6 +21,7 @@
 #include <gst/video/videooverlay.h>
 #include <gst/video/video.h>
 #include <GL/gl.h>
+#include "../gl-compat-defines.h"
 #include "pipeline.h"
 
 #define GST_MAP_GL (GST_MAP_FLAG_LAST << 1)
index 90e85ff..97e7fb4 100644 (file)
@@ -30,7 +30,7 @@ class QRenderer : public QWidget
     Q_OBJECT
 
 public:
-    QRenderer(const QString videoLocation, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+    QRenderer(const QString videoLocation, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
     ~QRenderer();
     void paintEvent(QPaintEvent* event);
     void mouseMoveEvent(QMouseEvent* event);
index 1f4896c..176c485 100644 (file)
@@ -13,7 +13,7 @@ moc_headers = [
 
 moc_files = qt5_mod.preprocess(moc_headers : moc_headers)
 executable('qglwidgetvideoverlay', sources, moc_files,
-  cpp_args : [gst_plugins_base_args],
+  cpp_args : [gst_plugins_base_args] + qt_cxx_warn_less,
   include_directories: [configinc, libsinc],
   dependencies : [qt5core_dep, qt5gui_dep, qt5opengl_dep, gst_dep, video_dep, gstgl_dep, libgl],
   install: false)
index 21e38f2..10951f8 100644 (file)
@@ -21,6 +21,7 @@
 #include <gst/video/videooverlay.h>
 #include <gst/video/video.h>
 #include <GL/gl.h>
+#include "../gl-compat-defines.h"
 #include "pipeline.h"
 
 #define GST_MAP_GL (GST_MAP_FLAG_LAST << 1)
index aaf0d02..d9ded29 100644 (file)
@@ -29,7 +29,7 @@ class QGLRenderer : public QGLWidget
     Q_OBJECT
 
 public:
-    QGLRenderer(const QString videoLocation, QWidget *parent = 0);
+    QGLRenderer(const QString videoLocation, QWidget *parent = nullptr);
     ~QGLRenderer();
     void paintEvent(QPaintEvent* event);
     void closeEvent (QCloseEvent* event);
index b4d9dbd..781bf3f 100644 (file)
@@ -23,7 +23,7 @@ endif
 
 moc_files = qt5_mod.preprocess(moc_headers : moc_headers)
 executable('qglwtextureshare', sources, moc_files,
-  cpp_args : [gst_plugins_base_args],
+  cpp_args : [gst_plugins_base_args] + qt_cxx_warn_less,
   include_directories: [configinc, libsinc],
   dependencies : [qt5core_dep, qt5gui_dep, qt5opengl_dep, qtwinsys_deps, gst_dep, video_dep, gstgl_dep, libgl],
   install: false)
index 4afa833..1698bf8 100644 (file)
@@ -19,9 +19,9 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "pipeline.h"
 #include <gst/gl/gl.h>
-
+#include "../gl-compat-defines.h"
+#include "pipeline.h"
 
 Pipeline::Pipeline (GstGLDisplay *display,
     GstGLContext * context, const QString & videoLocation, QObject * parent)
index 0bf354b..20da6f6 100644 (file)
@@ -34,7 +34,7 @@ class QGLRenderer : public QGLWidget
     Q_OBJECT
 
 public:
-    QGLRenderer(const QString &videoLocation, QWidget *parent = 0);
+    QGLRenderer(const QString &videoLocation, QWidget *parent = nullptr);
     ~QGLRenderer();
 
     void closeEvent(QCloseEvent* event);