# HG changeset patch # User John W. Eaton # Date 1507915329 14400 # Node ID 59cdf06c940eda47566ee305321f85531e0ca0f0 # Parent af577de75e687eecebefc3192b2bf8dd299d470c use QOpenGLWidget if it is available * acinclude.m4 (OCTAVE_CHECK_QT_OPENGL_OK): Check for QOpenGlWidget. * GLCanvas.h, GLCanvas.cc (GLCanvas): Use QOpenGLWidget if it is available. Error both QOpenGLWidget and QGLWidget are missing. diff -r af577de75e68 -r 59cdf06c940e libgui/graphics/GLCanvas.cc --- a/libgui/graphics/GLCanvas.cc Fri Oct 13 15:57:42 2017 +0200 +++ b/libgui/graphics/GLCanvas.cc Fri Oct 13 13:22:09 2017 -0400 @@ -32,18 +32,22 @@ namespace QtHandles { +#if defined (HAVE_QOPENGLWIDGET) +# define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS +#else +# if defined (Q_OS_WIN32) +# define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS \ + QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel \ + | QGL::IndirectRendering), +# else +# define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS \ + QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel), +# endif +#endif GLCanvas::GLCanvas (QWidget *xparent, const graphics_handle& gh) -#if defined (Q_OS_WIN32) - : QGLWidget (QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel | - QGL::IndirectRendering), - xparent), + : OCTAVE_QT_OPENGL_WIDGET (OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS xparent), Canvas (gh) -#else - : QGLWidget (QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel), - xparent), - Canvas (gh) -#endif { setFocusPolicy (Qt::ClickFocus); setFocus (); @@ -204,14 +208,14 @@ GLCanvas::keyPressEvent (QKeyEvent *xevent) { if (! canvasKeyPressEvent (xevent)) - QGLWidget::keyPressEvent (xevent); + OCTAVE_QT_OPENGL_WIDGET::keyPressEvent (xevent); } void GLCanvas::keyReleaseEvent (QKeyEvent *xevent) { if (! canvasKeyReleaseEvent (xevent)) - QGLWidget::keyReleaseEvent (xevent); + OCTAVE_QT_OPENGL_WIDGET::keyReleaseEvent (xevent); } } diff -r af577de75e68 -r 59cdf06c940e libgui/graphics/GLCanvas.h --- a/libgui/graphics/GLCanvas.h Fri Oct 13 15:57:42 2017 +0200 +++ b/libgui/graphics/GLCanvas.h Fri Oct 13 13:22:09 2017 -0400 @@ -23,14 +23,21 @@ #if ! defined (octave_GLCanvas_h) #define octave_GLCanvas_h 1 -#include +#if defined (HAVE_QOPENGLWIDGET) +# include +# define OCTAVE_QT_OPENGL_WIDGET QOpenGLWidget +#elif defined (HAVE_QGLWIDGET) +# include +# define OCTAVE_QT_OPENGL_WIDGET QGLWidget +#else +# error "configuration error: must have or ." +#endif #include "Canvas.h" namespace QtHandles { - - class GLCanvas : public QGLWidget, public Canvas + class GLCanvas : public OCTAVE_QT_OPENGL_WIDGET, public Canvas { public: GLCanvas (QWidget *parent, const graphics_handle& handle); diff -r af577de75e68 -r 59cdf06c940e m4/acinclude.m4 --- a/m4/acinclude.m4 Fri Oct 13 15:57:42 2017 +0200 +++ b/m4/acinclude.m4 Fri Oct 13 13:22:09 2017 -0400 @@ -1342,25 +1342,33 @@ ac_octave_save_CXXFLAGS="$CXXFLAGS" CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" CXXFLAGS="$CXXPICFLAG $CXXFLAGS" + AC_CHECK_HEADERS([QOpenGLWidget QGLWidget]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_WINDOWS_H - # include + # include #endif #if defined (HAVE_GL_GL_H) - # include + # include #elif defined (HAVE_OPENGL_GL_H) - # include + # include #endif #if defined (HAVE_GL_GLU_H) - # include + # include #elif defined HAVE_OPENGL_GLU_H || defined HAVE_FRAMEWORK_OPENGL - # include + # include #endif - #include - class gl_widget : public QGLWidget + #if defined (HAVE_QOPENGLWIDGET) + # include + # define OCTAVE_QT_OPENGL_WIDGET QOpenGLWidget + #elif defined (HAVE_QGLWIDGET) + # include + # define OCTAVE_QT_OPENGL_WIDGET QGLWidget + #endif + class gl_widget : public OCTAVE_QT_OPENGL_WIDGET { public: - gl_widget (QWidget *parent = 0) : QGLWidget (parent) {} + gl_widget (QWidget *parent = 0) + : OCTAVE_QT_OPENGL_WIDGET (parent) { } ~gl_widget () {} }; ]], [[