00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef __GL2PS_H__
00052 #define __GL2PS_H__
00053
00054 #include <stdio.h>
00055 #include <stdlib.h>
00056 #include <cmath>
00057
00058
00059
00060
00061 #ifdef WIN32
00062 # include <windows.h>
00063 # ifdef GL2PSDLL
00064 # ifdef GL2PSDLL_EXPORTS
00065 # define GL2PSDLL_API __declspec(dllexport)
00066 # else
00067 # define GL2PSDLL_API __declspec(dllimport)
00068 # endif
00069 # else
00070 # define GL2PSDLL_API
00071 # endif
00072 #else
00073 # define GL2PSDLL_API
00074 #endif
00075
00076 #ifdef __APPLE__
00077 # include <OpenGL/gl.h>
00078 #else
00079 # include <GL/gl.h>
00080 #endif
00081
00082
00083 #define GL2PS_VERSION 0.8
00084 #define GL2PS_NONE 0
00085
00086
00087
00088 #define GL2PS_PS 1
00089 #define GL2PS_EPS 2
00090 #define GL2PS_TEX 3
00091
00092
00093
00094 #define GL2PS_NO_SORT 1
00095 #define GL2PS_SIMPLE_SORT 2
00096 #define GL2PS_BSP_SORT 3
00097
00098
00099
00100 #define GL2PS_DRAW_BACKGROUND (1<<0)
00101 #define GL2PS_SIMPLE_LINE_OFFSET (1<<1)
00102 #define GL2PS_SILENT (1<<2)
00103 #define GL2PS_BEST_ROOT (1<<3)
00104 #define GL2PS_OCCLUSION_CULL (1<<4)
00105 #define GL2PS_NO_TEXT (1<<5)
00106 #define GL2PS_LANDSCAPE (1<<6)
00107 #define GL2PS_NO_PS3_SHADING (1<<7)
00108 #define GL2PS_NO_PIXMAP (1<<8)
00109
00110
00111
00112 #define GL2PS_POLYGON_OFFSET_FILL 1
00113 #define GL2PS_POLYGON_BOUNDARY 2
00114 #define GL2PS_LINE_STIPPLE 3
00115
00116
00117
00118 #define GL2PS_EPSILON 5.e-3
00119 #define GL2PS_DEPTH_FACT 1000.0
00120 #define GL2PS_SIMPLE_OFFSET 0.05
00121 #define GL2PS_SIMPLE_OFFSET_LARGE 1.0
00122 #define GL2PS_ZERO(arg) (std::fabs(arg)<1.e-20)
00123
00124
00125
00126
00127 #define GL2PS_SUCCESS 0
00128 #define GL2PS_INFO 1
00129 #define GL2PS_WARNING 2
00130 #define GL2PS_ERROR 3
00131 #define GL2PS_NO_FEEDBACK 4
00132 #define GL2PS_OVERFLOW 5
00133 #define GL2PS_UNINITIALIZED 6
00134
00135
00136
00137 #define GL2PS_TEXT 1
00138 #define GL2PS_POINT 2
00139 #define GL2PS_LINE 3
00140 #define GL2PS_QUADRANGLE 4
00141 #define GL2PS_TRIANGLE 5
00142 #define GL2PS_PIXMAP 6
00143
00144
00145
00146 #define GL2PS_COINCIDENT 1
00147 #define GL2PS_IN_FRONT_OF 2
00148 #define GL2PS_IN_BACK_OF 3
00149 #define GL2PS_SPANNING 4
00150
00151
00152
00153 #define GL2PS_POINT_COINCIDENT 0
00154 #define GL2PS_POINT_INFRONT 1
00155 #define GL2PS_POINT_BACK 2
00156
00157
00158
00159 #define GL2PS_BEGIN_POLYGON_OFFSET_FILL 1
00160 #define GL2PS_END_POLYGON_OFFSET_FILL 2
00161 #define GL2PS_BEGIN_POLYGON_BOUNDARY 3
00162 #define GL2PS_END_POLYGON_BOUNDARY 4
00163 #define GL2PS_BEGIN_LINE_STIPPLE 5
00164 #define GL2PS_END_LINE_STIPPLE 6
00165 #define GL2PS_SET_POINT_SIZE 7
00166 #define GL2PS_SET_LINE_WIDTH 8
00167
00168 typedef GLfloat GL2PSrgba[4];
00169 typedef GLfloat GL2PSxyz[3];
00170 typedef GLfloat GL2PSplane[4];
00171
00172 typedef struct _GL2PSbsptree2d GL2PSbsptree2d;
00173
00174 struct _GL2PSbsptree2d {
00175 GL2PSplane plane;
00176 GL2PSbsptree2d *front, *back;
00177 };
00178
00179 typedef struct {
00180 GLint nmax, size, incr, n;
00181 char *array;
00182 } GL2PSlist;
00183
00184 typedef struct _GL2PSbsptree GL2PSbsptree;
00185
00186 struct _GL2PSbsptree {
00187 GL2PSplane plane;
00188 GL2PSlist *primitives;
00189 GL2PSbsptree *front, *back;
00190 };
00191
00192 typedef struct {
00193 GL2PSxyz xyz;
00194 GL2PSrgba rgba;
00195 } GL2PSvertex;
00196
00197 typedef struct {
00198 GLshort fontsize;
00199 char *str, *fontname;
00200 } GL2PSstring;
00201
00202 typedef struct {
00203 GLsizei width, height;
00204 GLenum format, type;
00205 GLfloat *pixels;
00206 } GL2PSimage;
00207
00208 typedef struct {
00209 GLshort type, numverts;
00210 char boundary, dash, culled;
00211 GLfloat width, depth;
00212 GL2PSvertex *verts;
00213 GL2PSstring *text;
00214 GL2PSimage *image;
00215 } GL2PSprimitive;
00216
00217 typedef struct {
00218 GLint format, sort, options, colorsize, colormode, buffersize, maxbestroot;
00219 const char *title, *producer, *filename;
00220 GLboolean shade, boundary;
00221 GLfloat *feedback, offset[2];
00222 GLint viewport[4];
00223 GL2PSrgba *colormap, lastrgba, threshold;
00224 float lastlinewidth;
00225 GL2PSlist *primitives;
00226 GL2PSbsptree2d *imagetree;
00227 FILE *stream;
00228 } GL2PScontext;
00229
00230
00231
00232 #ifdef __cplusplus
00233 extern "C" {
00234 #endif
00235
00236 GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer,
00237 GLint viewport[4], GLint format, GLint sort,
00238 GLint options, GLint colormode,
00239 GLint colorsize, GL2PSrgba *colormap,
00240 GLint nr, GLint ng, GLint nb, GLint buffersize,
00241 FILE *stream, const char *filename);
00242 GL2PSDLL_API GLint gl2psEndPage(void);
00243 GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4]);
00244 GL2PSDLL_API GLint gl2psEndViewport(void);
00245 GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname, GLshort fontsize);
00246 GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height,
00247 GLint xorig, GLint yorig,
00248 GLenum format, GLenum type, const void *pixels);
00249 GL2PSDLL_API GLint gl2psEnable(GLint mode);
00250 GL2PSDLL_API GLint gl2psDisable(GLint mode);
00251 GL2PSDLL_API GLint gl2psPointSize(GLfloat value);
00252 GL2PSDLL_API GLint gl2psLineWidth(GLfloat value);
00253
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257
00258 #endif