comparison scripts/plot/util/__check_rendering_capability__.m @ 30198:a87e5f9d5446

improve graphics toolkit rendering failure error message * __check_rendering_capability__.m: New function. * getframe.m, __opengl_print__.m: Use it. * scripts/plot/util/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Tue, 21 Sep 2021 12:30:32 -0400
parents
children 796f54d4ddbf
comparison
equal deleted inserted replaced
30197:f692ecc135d6 30198:a87e5f9d5446
1 ########################################################################
2 ##
3 ## Copyright (C) 2021 The Octave Project Developers
4 ##
5 ## See the file COPYRIGHT.md in the top-level directory of this
6 ## distribution or <https://octave.org/copyright/>.
7 ##
8 ## This file is part of Octave.
9 ##
10 ## Octave is free software: you can redistribute it and/or modify it
11 ## under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
14 ##
15 ## Octave is distributed in the hope that it will be useful, but
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
19 ##
20 ## You should have received a copy of the GNU General Public License
21 ## along with Octave; see the file COPYING. If not, see
22 ## <https://www.gnu.org/licenses/>.
23 ##
24 ########################################################################
25
26 ## -*- texinfo -*-
27 ## @deftypefn {} {} __check_rendering_capability__ (@var{who}, @var{fig})
28 ## Undocumented internal function.
29 ## @end deftypefn
30
31 function __check_rendering_capability__ (who, fig)
32
33 if (strcmp (get (fig, "visible"), "on"))
34 return;
35 endif
36
37 toolkit = get (fig, "__graphics_toolkit__");
38 display = getenv ("DISPLAY");
39
40 if (! strcmp (toolkit, "qt"))
41 error ("%s: rendering with %s toolkit requires visible figure (DISPLAY='%s')",
42 who, toolkit, display);
43 endif
44
45 gl_window = get (fig, "__gl_window__");
46 qt_offscreen = __have_feature__ ("QT_OFFSCREEN");
47
48 if (strcmp (gl_window, "on") || qt_offscreen)
49 return;
50 endif
51
52 error ("%s: offscreen rendering with %s toolkit requires __gl_window__='on' or QT_OFFSCREEN feature (__gl_window__='%s'; QT_OFFSCREEN=%d, DISPLAY='%s')",
53 who, toolkit, gl_window, qt_offscreen, display);
54
55 endfunction