diff src/gl2ps-renderer.cc @ 9950:7dedfd70dd9f

image printing for fltk backend
author Shai Ayal <shaiay@users.sourceforge.net>
date Wed, 09 Dec 2009 15:49:00 -0500
parents 92d8f35ff217
children cd96d29c5efa
line wrap: on
line diff
--- a/src/gl2ps-renderer.cc	Wed Dec 09 12:37:50 2009 -0500
+++ b/src/gl2ps-renderer.cc	Wed Dec 09 15:49:00 2009 -0500
@@ -145,6 +145,30 @@
   // FIXME -- add support for bold and italic
 }
 
+template <typename T>
+static void
+draw_pixels (GLsizei w, GLsizei h, GLenum format, const T *data)
+{
+  OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
+
+  for (int i = 0; i < 3*w*h; i++)
+    a[i] = data[i];
+    
+  gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a);
+}
+
+void 
+glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format,
+                            GLenum type, const GLvoid *data)
+{
+  if (type == GL_UNSIGNED_SHORT) 
+    ::draw_pixels (w, h, format, static_cast<const GLushort *> (data));
+  else if (type == GL_UNSIGNED_BYTE) 
+    ::draw_pixels (w, h, format, static_cast<const GLubyte *> (data));
+  else
+    gl2psDrawPixels (w, h, 0, 0, format, type, data);
+}
+
 #endif
 
 /*