Mercurial > octave-nkf
comparison libinterp/corefcn/gl2ps-renderer.cc @ 19727:05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
* gl2ps-renderer.cc: Throw error from call to gl2psBeginPage and
gl2psEndPage. Replace glFlush with glFinish which waits until
all objects were flushed. Use GL2PS_USE_CURRENT_VIEWPORT
author | Andreas Weber <andy.weber.aw@gmail.com> |
---|---|
date | Tue, 10 Feb 2015 23:19:44 +0100 |
parents | 16f21db320b5 |
children | 4197fc428c7d |
comparison
equal
deleted
inserted
replaced
19726:b30cd22e6471 | 19727:05b40890bbb2 |
---|---|
48 { | 48 { |
49 in_draw = true; | 49 in_draw = true; |
50 | 50 |
51 GLint buffsize = 0; | 51 GLint buffsize = 0; |
52 GLint state = GL2PS_OVERFLOW; | 52 GLint state = GL2PS_OVERFLOW; |
53 GLint viewport[4]; | |
54 | |
55 glGetIntegerv (GL_VIEWPORT, viewport); | |
56 | |
57 GLint gl2ps_term; | 53 GLint gl2ps_term; |
58 if (term.find ("eps") != std::string::npos) gl2ps_term = GL2PS_EPS; | 54 if (term.find ("eps") != std::string::npos) gl2ps_term = GL2PS_EPS; |
59 else if (term.find ("pdf") != std::string::npos) gl2ps_term = GL2PS_PDF; | 55 else if (term.find ("pdf") != std::string::npos) gl2ps_term = GL2PS_PDF; |
60 else if (term.find ("ps") != std::string::npos) gl2ps_term = GL2PS_PS; | 56 else if (term.find ("ps") != std::string::npos) gl2ps_term = GL2PS_PS; |
61 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG; | 57 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG; |
98 } | 94 } |
99 else | 95 else |
100 include_graph = "foobar-inc"; | 96 include_graph = "foobar-inc"; |
101 buffsize += 1024*1024; | 97 buffsize += 1024*1024; |
102 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr | 98 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr |
103 GLint ret = gl2psBeginPage ("glps_renderer figure", "Octave", viewport, | 99 GLint ret = gl2psBeginPage ("glps_renderer figure", "Octave", NULL, |
104 gl2ps_term, gl2ps_sort, | 100 gl2ps_term, gl2ps_sort, |
105 ( GL2PS_NO_BLENDING | 101 ( GL2PS_NO_BLENDING |
106 | GL2PS_OCCLUSION_CULL | 102 | GL2PS_OCCLUSION_CULL |
107 | GL2PS_BEST_ROOT | 103 | GL2PS_BEST_ROOT |
108 | gl2ps_text | 104 | gl2ps_text |
109 | GL2PS_NO_PS3_SHADING), | 105 | GL2PS_NO_PS3_SHADING |
106 | GL2PS_USE_CURRENT_VIEWPORT), | |
110 GL_RGBA, 0, NULL, 0, 0, 0, | 107 GL_RGBA, 0, NULL, 0, 0, 0, |
111 buffsize, fp, include_graph.c_str ()); | 108 buffsize, fp, include_graph.c_str ()); |
112 if (ret == GL2PS_ERROR) | 109 if (ret == GL2PS_ERROR) |
113 error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR"); | 110 { |
111 in_draw = 0; | |
112 old_print_cmd.clear (); | |
113 error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR"); | |
114 return; | |
115 } | |
114 old_print_cmd = print_cmd; | 116 old_print_cmd = print_cmd; |
115 opengl_renderer::draw (go); | 117 opengl_renderer::draw (go); |
116 | 118 |
117 // Force execution of GL commands in finite time. | 119 // Without glFinish () there may primitives be missing in the gl2ps output. |
118 // Without glFlush () there may primitives be missing in the gl2ps output. | 120 glFinish (); |
119 glFlush (); | |
120 | 121 |
121 state = gl2psEndPage (); | 122 state = gl2psEndPage (); |
123 | |
124 if (state == GL2PS_NO_FEEDBACK) | |
125 { | |
126 warning ("gl2ps-renderer::draw: empty feedback buffer and/or nothing else to print"); | |
127 } | |
128 else if (state == GL2PS_ERROR) | |
129 { | |
130 in_draw = 0; | |
131 old_print_cmd.clear (); | |
132 error ("gl2ps-renderer::draw: gl2psEndPage returned GL2PS_ERROR"); | |
133 return; | |
134 } | |
135 // Don't check state for GL2PS_UNINITIALIZED (should never happen) | |
136 // GL2PS_OVERFLOW (see while loop) or GL2PS_SUCCESS | |
122 } | 137 } |
123 | 138 |
124 in_draw = 0; | 139 in_draw = 0; |
125 } | 140 } |
126 else | 141 else |