//1// "$Id: glp.h,v 1.3 2005/05/31 11:28:13 vierinen Exp $"2//3// Header file for the GLP library, an OpenGL printing toolkit.4//5// The GLP library is distributed under the terms of the GNU Library6// General Public License which is described in the file "COPYING.LIB".7// If you use this library in your program, please include a line reading8// "OpenGL Printing Toolkit by Michael Sweet" in your version or copyright9// output.10//11// Revision History:12//13// $Log: glp.h,v $14// Revision 1.3 2005/05/31 11:28:13 vierinen15// ads16//17// Revision 1.2 2005/05/31 10:39:03 vierinen18// apple?19//20// Revision 1.1.1.1 2005/05/31 06:29:21 vierinen21// ads22//23// Revision 1.1 2003/02/06 09:37:54 jpr24// *** empty log message ***25//26// 2003/02/01 Juha Ruokolainen CSC27// Added protos for binary tree handling in GLPcontex28// Revision 1.2 1996/07/13 12:52:02 mike29// Changed the public methods to 'virtual'.30//31// Revision 1.1 1996/06/27 03:07:13 mike32// Initial revision33//3435#ifndef _GL_GLP_H_36# define _GL_GLP_H_37#include "../../config.h"3839#if defined(WIN32) ||defined(MINGW32)40#include <windows.h>41#include <direct.h>42#include <wingdi.h>43#include <windef.h>44#endif454647//48// Include necessary headers.49//50#include <GL/gl.h>51#include "../../config.h"52535455# include <iostream>56# include <fstream>575859//60// Printing options...61//6263# define GLP_FIT_TO_PAGE 1 // Fit the output to the page64# define GLP_AUTO_CROP 2 // Automatically crop to geometry65# define GLP_GREYSCALE 4 // Output greyscale rather than color66# define GLP_REVERSE 8 // Reverse grey shades67# define GLP_DRAW_BACKGROUND 16 // Draw the background color6869//70// OpenGL configuration options...71//7273# define GLP_RGBA 0 // RGBA mode window74# define GLP_COLORINDEX 1 // Color index mode window7576//77// Error codes...78//7980# define GLP_SUCCESS 0 // Success - no error occurred81# define GLP_OUT_OF_MEMORY -1 // Out of memory82# define GLP_NO_FEEDBACK -2 // No feedback data available83# define GLP_ILLEGAL_OPERATION -3 // Illegal operation of some kind848586//87// Various structures used for sorting feedback data prior to printing...88//8990typedef GLfloat GLPrgba[4]; // GLPrgba array structure for sanity91typedef GLfloat GLPxyz[3]; // GLPxyz array structure for sanity9293struct GLPvertex //// GLPvertex structure94{95GLPxyz xyz; // Location of vertex96GLPrgba rgba; // Color of vertex (alpha may be used later)97};9899struct GLPprimitive //// GLPprimitive structure100{101GLPprimitive *left, *right; // left right pointers of the depth sort tree102GLboolean shade; // GL_TRUE if this primitive should be shaded103GLfloat zmin, zmax; // Min and max depth values104int num_verts; // Number of vertices used105GLPvertex verts[3]; // Up to 3 vertices106};107108struct GLPbbox //// GLPbbox structure109{110GLPbbox *next, // Next bounding box in list111*prev; // Previous bounding box in list112GLPprimitive *primitives, // Primitives inside this box113*lastprim;114GLfloat min[3], // Minimum X, Y, Z coords115max[3]; // Maximum X, Y, Z coords116};117118//119// The GLPcontext class provides all the basic functionality to support120// OpenGL feedback-based printing to vector/polygon printing devices or121// file formats. For raster-only devices you are probably better off with122// an off-screen bitmap.123//124125class GLPcontext //// GLPcontext class126{127protected:128int options; // Printing options129GLPbbox *bboxes; // Primitive data130GLPprimitive *tree; // Primitive data131int feedsize; // Feedback buffer size132GLfloat *feedback; // Feedback data133int feedmode; // Feedback mode (RGBA or colormap)134int colorsize; // Colormap size135GLPrgba *colormap; // Colorindex mapping to RGBA vals136137void add_primitive(GLboolean depth, GLboolean shade,138int num_verts, GLPvertex *verts);139void sort_primitive(GLboolean depth, GLPbbox *bbox,140GLPprimitive *newprim);141void add_tree( GLPprimitive **tree, GLPprimitive *prim);142void add_subtree( GLPprimitive **tree, GLPprimitive *prim);143int get_vertex(GLPvertex *v, GLfloat *p);144void delete_all(void);145void delete_tree(GLPprimitive *tree);146147public:148virtual ~GLPcontext(void);149150virtual int StartPage(int mode = GLP_RGBA);151virtual int StartPage(int mode,152int size,153GLPrgba *rgba);154virtual int UpdatePage(GLboolean more);155virtual int EndPage(void);156157virtual void SetOptions(int print_options);158};159160#endif // !_GL_GLP_H_161162//163// End of "$Id: glp.h,v 1.3 2005/05/31 11:28:13 vierinen Exp $".164//165166167