changeset 22221:fddc5604d1fa

__opengl_info__.m: Tide code and fix to work with fltk toolkit. * __opengl_info__.m: Remove type specifier "Function File" from @deftypefn macro. Use '##' as prefix for full-line comments. Eliminate extra checks for "isempty (info)" in for loop. Loop directly over available graphics handles rather than over index to graphics handle list. Draw an axes object on blank figure in order to force FLTK toolkit to populate OpenGL fields. Use drawnow() rather than a 1 second waitfor() delay in order to force graphics system to populate OpenGL fields.
author Rik <rik@octave.org>
date Mon, 08 Aug 2016 12:03:06 -0700
parents a8a9c275e12d
children 8a50ab960ae6
files scripts/plot/util/__opengl_info__.m
diffstat 1 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/__opengl_info__.m	Mon Aug 08 07:36:37 2016 +0200
+++ b/scripts/plot/util/__opengl_info__.m	Mon Aug 08 12:03:06 2016 -0700
@@ -14,8 +14,8 @@
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} __opengl_info__
-## @deftypefnx {Function File} {@var{retval} =} __opengl_info__ ()
+## @deftypefn  {} {} __opengl_info__
+## @deftypefnx {} {@var{retval} =} __opengl_info__ ()
 ##
 ## Get OpenGL driver information.
 ##
@@ -24,13 +24,17 @@
 ## in a structure.
 ##
 ## Fields in the structure are:
+##
 ## @table @asis
 ## @item version
 ## OpenGL Driver version string
+##
 ## @item vendor
 ## OpenGL Driver vendor string
+##
 ## @item renderer
 ## OpenGL renderer string
+##
 ## @item extensions
 ## List of enabled extensions for the OpenGL driver.
 ## @end table
@@ -43,14 +47,16 @@
 
 function retval = __opengl_info__ ()
 
-  # currently we only handle a single argument
+  ## currently we only handle a single argument
   if (nargin != 0)
     print_usage ();
   endif
 
   [info, msg] = gl_info ();
 
-  if (isempty (msg))
+  if (! isempty (msg))
+    warning (msg);
+  else
     if (nargout == 0)
       printf ("version    = %s\n", info.version);
       printf ("vendor     = %s\n", info.vendor);
@@ -60,14 +66,13 @@
     else
       retval = info;
     endif
-  else
-    warning (msg);
   endif
 
 endfunction
 
 function info = fig_gl_info (h)
   info = [];
+
   if (ishandle (h) && strcmp (get (h, "renderer"), "opengl"))
     vers = get (h, "__gl_version__");
     vend = get (h, "__gl_vendor__");
@@ -87,23 +92,21 @@
   msg = "";
 
   ## If we have any open figures, take a look for any OpenGL info.
-
   figs = findall (0, "type", "figure");
 
-  for i = 1:numel (figs)
-    if (isempty (info))
-      info = fig_gl_info (figs(i));
-      if (! isempty (info))
-        break
-      endif
+  for hf = figs.'
+    info = fig_gl_info (hf);
+    if (! isempty (info))
+      break;
     endif
   endfor
 
-  ## If no info yet, try open a figure brifly to get the info.
-
+  ## If no info yet, try open a figure to get the info.
   if (isempty (info))
+    ## Need to create a figure, place an OpenGL object, and force drawing.
     h = figure ("position", [0,0,1,1], "toolbar", "none", "menubar", "none");
-    waitfor (h, "timeout", 1);
+    hax = axes ();
+    drawnow ();
     info = fig_gl_info (h);
     close (h);
   endif
@@ -119,3 +122,4 @@
 %! a = __opengl_info__ ();
 %! assert (! isempty (a))
 %! assert (isfield (a, "version"))
+