changeset 25864:baeb93e9febc

allow building without OpenGL to work again
author John W. Eaton <jwe@octave.org>
date Sat, 08 Sep 2018 09:54:07 -0400
parents 8a6bf76abf31
children 3b673361ae33
files libgui/graphics/module.mk libgui/graphics/qopengl-functions.h libgui/module.mk libinterp/corefcn/gl-render.cc libinterp/corefcn/gl-render.h libinterp/corefcn/oct-opengl.h libinterp/dldfcn/__init_fltk__.cc
diffstat 7 files changed, 72 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/module.mk	Sat Sep 08 08:03:36 2018 -0400
+++ b/libgui/graphics/module.mk	Sat Sep 08 09:54:07 2018 -0400
@@ -1,5 +1,7 @@
 if AMCOND_BUILD_QT_GRAPHICS
 
+LIBOCTGUI_GRAPHICS_LIB := %reldir%/libgui-graphics.la
+
 OCTAVE_GUI_GRAPHICS_MOC = \
   %reldir%/moc-annotation-dialog.cc \
   %reldir%/moc-Backend.cc \
@@ -147,7 +149,7 @@
   -Ilibinterp/corefcn -I$(srcdir)/libinterp/corefcn \
   -I$(srcdir)/libinterp/octave-value
 
-noinst_LTLIBRARIES += %reldir%/libgui-graphics.la
+noinst_LTLIBRARIES += $(LIBOCTGUI_GRAPHICS_LIB)
 
 libgui_EXTRA_DIST += \
   %reldir%/qthandles.qrc \
--- a/libgui/graphics/qopengl-functions.h	Sat Sep 08 08:03:36 2018 -0400
+++ b/libgui/graphics/qopengl-functions.h	Sat Sep 08 09:54:07 2018 -0400
@@ -75,7 +75,8 @@
       m_glfcns.glBindTexture (target, texture);
     }
 
-    void glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
+    void glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
+                   GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
     {
       m_glfcns.glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap);
     }
@@ -90,7 +91,8 @@
       m_glfcns.glCallList (list);
     }
 
-    void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+    void glClearColor (GLclampf red, GLclampf green, GLclampf blue,
+                       GLclampf alpha)
     {
       m_glfcns.glClearColor (red, green, blue, alpha);
     }
@@ -155,7 +157,8 @@
       m_glfcns.glDisable (cap);
     }
 
-    void glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+    void glDrawPixels (GLsizei width, GLsizei height, GLenum format,
+                       GLenum type, const GLvoid *pixels)
     {
       m_glfcns.glDrawPixels (width, height, format, type, pixels);
     }
@@ -295,7 +298,8 @@
       m_glfcns.glNormal3dv (v);
     }
 
-    void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)
+    void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
+                  GLdouble near_val, GLdouble far_val)
     {
       m_glfcns.glOrtho (left, right, bottom, top, near_val, far_val);
     }
@@ -355,7 +359,8 @@
       m_glfcns.glRasterPos3d (x, y, z);
     }
 
-    void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+    void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height,
+                       GLenum format, GLenum type, GLvoid *pixels)
     {
       m_glfcns.glReadPixels (x, y, width, height, format, type, pixels);
     }
@@ -395,9 +400,12 @@
       m_glfcns.glTexCoord2d (s, t);
     }
 
-    void glTexImage2D (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+    void glTexImage2D (GLenum target, GLint level, GLint internalFormat,
+                       GLsizei width, GLsizei height, GLint border,
+                       GLenum format, GLenum type, const GLvoid *pixels)
     {
-      m_glfcns.glTexImage2D (target, level, internalFormat, width, height, border, format, type, pixels);
+      m_glfcns.glTexImage2D (target, level, internalFormat, width, height,
+                             border, format, type, pixels);
     }
 
     void glTexParameteri (GLenum target, GLenum pname, GLint param)
--- a/libgui/module.mk	Sat Sep 08 08:03:36 2018 -0400
+++ b/libgui/module.mk	Sat Sep 08 09:54:07 2018 -0400
@@ -53,7 +53,7 @@
 %canon_reldir%_liboctgui_la_LIBADD = \
   %reldir%/qterminal/libqterminal.la \
   %reldir%/src/libgui-src.la \
-  %reldir%/graphics/libgui-graphics.la \
+  $(LIBOCTGUI_GRAPHICS_LIB) \
   libinterp/liboctinterp.la \
   liboctave/liboctave.la \
   $(LIBOCTGUI_LINK_DEPS)
--- a/libinterp/corefcn/gl-render.cc	Sat Sep 08 08:03:36 2018 -0400
+++ b/libinterp/corefcn/gl-render.cc	Sat Sep 08 09:54:07 2018 -0400
@@ -4368,30 +4368,23 @@
 #endif
   }
 
+#if defined (HAVE_OPENGL)
+
   std::string
   opengl_renderer::get_string (GLenum id) const
   {
-#if defined (HAVE_OPENGL)
-
     // This is kind of ugly, but glGetString returns a pointer to GLubyte
     // and there is no std::string constructor that matches.  Is there a
     // better way?
 
     std::ostringstream buf;
+
     buf << m_glfcns.glGetString (id);
+
     return std::string (buf.str ());
-
-#else
-
-    octave_unused_parameter (id);
-
-    // This shouldn't happen because construction of opengl_renderer
-    // objects is supposed to be impossible if OpenGL is not available.
-
-    panic_impossible ();
+  }
 
 #endif
-  }
 
   void
   opengl_renderer::set_normal (int bfl_mode, const NDArray& n, int j, int i)
--- a/libinterp/corefcn/gl-render.h	Sat Sep 08 08:03:36 2018 -0400
+++ b/libinterp/corefcn/gl-render.h	Sat Sep 08 09:54:07 2018 -0400
@@ -166,7 +166,9 @@
 
     void init_maxlights (void);
 
+#if defined (HAVE_OPENGL)
     std::string get_string (GLenum id) const;
+#endif
 
     bool is_nan_or_inf (double x, double y, double z) const
     {
--- a/libinterp/corefcn/oct-opengl.h	Sat Sep 08 08:03:36 2018 -0400
+++ b/libinterp/corefcn/oct-opengl.h	Sat Sep 08 09:54:07 2018 -0400
@@ -27,8 +27,6 @@
 
 #if defined (HAVE_OPENGL)
 
-#  include <functional>
-
 #  if defined (HAVE_GL_GL_H)
 #    include <GL/gl.h>
 #  elif defined (HAVE_OPENGL_GL_H) || defined (HAVE_FRAMEWORK_OPENGL)
@@ -47,6 +45,8 @@
 #    include <OpenGL/glext.h>
 #  endif
 
+#endif
+
 namespace octave
 {
   class opengl_functions
@@ -61,6 +61,12 @@
 
     virtual ~opengl_functions (void) = default;
 
+#if defined (HAVE_OPENGL)
+
+    // If OpenGL is not available, opengl_functions will be a dummy
+    // class that does nothing.  This makes the implementation of
+    // other things that rely on this class slightly simpler.
+
     virtual void glAlphaFunc (GLenum func, GLclampf ref)
     {
       ::glAlphaFunc (func, ref);
@@ -76,7 +82,9 @@
       ::glBindTexture (target, texture);
     }
 
-    virtual void glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
+    virtual void glBitmap (GLsizei width, GLsizei height, GLfloat xorig,
+                           GLfloat yorig, GLfloat xmove, GLfloat ymove,
+                           const GLubyte *bitmap)
     {
       ::glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap);
     }
@@ -91,7 +99,8 @@
       ::glCallList (list);
     }
 
-    virtual void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+    virtual void glClearColor (GLclampf red, GLclampf green, GLclampf blue,
+                               GLclampf alpha)
     {
       ::glClearColor (red, green, blue, alpha);
     }
@@ -121,12 +130,14 @@
       ::glColor3fv (v);
     }
 
-    virtual void glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
+    virtual void glColor4d (GLdouble red, GLdouble green, GLdouble blue,
+                            GLdouble alpha)
     {
       ::glColor4d (red, green, blue, alpha);
     }
 
-    virtual void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+    virtual void glColor4f (GLfloat red, GLfloat green, GLfloat blue,
+                            GLfloat alpha)
     {
       ::glColor4f (red, green, blue, alpha);
     }
@@ -156,7 +167,8 @@
       ::glDisable (cap);
     }
 
-    virtual void glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+    virtual void glDrawPixels (GLsizei width, GLsizei height, GLenum format,
+                               GLenum type, const GLvoid *pixels)
     {
       ::glDrawPixels (width, height, format, type, pixels);
     }
@@ -296,7 +308,8 @@
       ::glNormal3dv (v);
     }
 
-    virtual void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)
+    virtual void glOrtho (GLdouble left, GLdouble right, GLdouble bottom,
+                          GLdouble top, GLdouble near_val, GLdouble far_val)
     {
       ::glOrtho (left, right, bottom, top, near_val, far_val);
     }
@@ -356,7 +369,8 @@
       ::glRasterPos3d (x, y, z);
     }
 
-    virtual void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+    virtual void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height,
+                               GLenum format, GLenum type, GLvoid *pixels)
     {
       ::glReadPixels (x, y, width, height, format, type, pixels);
     }
@@ -396,9 +410,11 @@
       ::glTexCoord2d (s, t);
     }
 
-    virtual void glTexImage2D (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+    virtual void glTexImage2D (GLenum target, GLint level, GLint internalFormat,
+                               GLsizei width, GLsizei height, GLint border,
+                               GLenum format, GLenum type, const GLvoid *pixels)
     {
-      ::glTexImage2D (target, level, internalFormat, width, height, border, format, type, pixels);
+      ::glTexImage2D (target, level, internalFormat, width, height, border,
     }
 
     virtual void glTexParameteri (GLenum target, GLenum pname, GLint param)
@@ -435,9 +451,10 @@
     {
       ::glViewport (x, y, width, height);
     }
+
+#endif
   };
 }
 
-#endif
 
 #endif
--- a/libinterp/dldfcn/__init_fltk__.cc	Sat Sep 08 08:03:36 2018 -0400
+++ b/libinterp/dldfcn/__init_fltk__.cc	Sat Sep 08 09:54:07 2018 -0400
@@ -127,10 +127,14 @@
       m_glfcns (), m_renderer (m_glfcns), m_in_zoom (false), m_zoom_box ()
   {
 #if defined (HAVE_OPENGL)
+
     // Ask for double buffering and a depth buffer.
     mode (FL_DEPTH | FL_DOUBLE | FL_MULTISAMPLE);
+
 #else
+
     err_disabled_feature ("OpenGL_fltk", "OpenGL");
+
 #endif
   }
 
@@ -167,10 +171,17 @@
     Fl_Gl_Window::resize (xx, yy, ww, hh);
 
 #else
+
+    octave_unused_parameter (xx);
+    octave_unused_parameter (yy);
+    octave_unused_parameter (ww);
+    octave_unused_parameter (hh);
+
     // This shouldn't happen because construction of Opengl_fltk
     // objects is supposed to be impossible if OpenGL is not available.
 
     panic_impossible ();
+
 #endif
   }
 
@@ -216,10 +227,12 @@
       overlay ();
 
 #else
+
     // This shouldn't happen because construction of Opengl_fltk
     // objects is supposed to be impossible if OpenGL is not available.
 
     panic_impossible ();
+
 #endif
   }
 
@@ -259,10 +272,14 @@
     return Fl_Gl_Window::handle (event);
 
 #else
+
+    octave_unused_parameter (event);
+
     // This shouldn't happen because construction of Opengl_fltk
     // objects is supposed to be impossible if OpenGL is not available.
 
     panic_impossible ();
+
 #endif
   }
 };