changeset 20638:d30fc2c11455

Fix missing legend background in gl2ps outputs (bug #44765) * gl2ps-render.h (glps_renderer): new private attribute "naxes" used to count drawn axes * gl2ps-renderer.h (glps_renderer::draw_axes): new overloaded method. Use gl2psBegin(End) viewport to Finalize/Initialize a new viewport each time an axes is drawn. This is supposed to mimic "glClear (... GL_DEPTH_BUFFER_BIT)" in opengl_renderer::draw_axes
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sun, 11 Oct 2015 13:13:33 +0200
parents 756b052037fb
children a260a6acb70f
files libinterp/corefcn/gl2ps-renderer.h
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-renderer.h	Sun Oct 11 20:39:11 2015 +0200
+++ b/libinterp/corefcn/gl2ps-renderer.h	Sun Oct 11 13:13:33 2015 +0200
@@ -36,7 +36,8 @@
 {
 public:
   glps_renderer (FILE *_fp, const std::string& _term)
-    : opengl_renderer () , fp (_fp), term (_term), fontsize (), fontname () { }
+    : opengl_renderer () , fp (_fp), term (_term), fontsize (), 
+    fontname (), naxes (0) { }
 
   ~glps_renderer (void) { }
 
@@ -50,6 +51,24 @@
 
   void set_font (const base_properties& props);
 
+  void draw_axes (const axes::properties& props)
+  {
+    // Finish previous sorting tree here, the last one will be closed 
+    // by gl2psEndPage ()
+    if (naxes++)
+      gl2psEndViewport ();
+      
+    // Initialize a sorting tree in gl2ps for each axes
+    GLint vp[4];
+    glGetIntegerv (GL_VIEWPORT, vp);
+    gl2psBeginViewport (vp);
+
+    // Draw and  glFinish () or there may primitives missing in the
+    // gl2ps output.
+    opengl_renderer::draw_axes (props);
+    glFinish ();
+  }
+
   void draw_text (const text::properties& props);
   void draw_pixels (GLsizei w, GLsizei h, GLenum format,
                     GLenum type, const GLvoid *data);
@@ -89,6 +108,7 @@
   caseless_str term;
   double fontsize;
   std::string fontname;
+  int naxes;
 };
 
 #endif  // HAVE_GL2PS_H