[529] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | /* |
---|
| 27 | * GL2PS, an OpenGL to PostScript Printing Library |
---|
| 28 | * Copyright (C) 1999-2003 Christophe Geuzaine |
---|
| 29 | * |
---|
| 30 | * $Id: gl2ps.h,v 1.5 2006/06/29 21:23:11 gunter Exp $ |
---|
| 31 | * |
---|
| 32 | * E-mail: geuz@geuz.org |
---|
| 33 | * URL: http://www.geuz.org/gl2ps/ |
---|
| 34 | * |
---|
| 35 | * This library is free software; you can redistribute it and/or |
---|
| 36 | * modify it under the terms of the GNU Library General Public |
---|
| 37 | * License as published by the Free Software Foundation; either |
---|
| 38 | * version 2 of the License, or (at your option) any later version. |
---|
| 39 | * |
---|
| 40 | * This library is distributed in the hope that it will be useful, |
---|
| 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 43 | * Library General Public License for more details. |
---|
| 44 | * |
---|
| 45 | * You should have received a copy of the GNU Library General Public |
---|
| 46 | * License along with this library; if not, write to the Free |
---|
| 47 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 48 | * |
---|
| 49 | */ |
---|
| 50 | |
---|
| 51 | #ifndef __GL2PS_H__ |
---|
| 52 | #define __GL2PS_H__ |
---|
| 53 | |
---|
| 54 | #include <stdio.h> |
---|
| 55 | #include <stdlib.h> |
---|
| 56 | #include <cmath> |
---|
| 57 | |
---|
| 58 | /* To generate a Windows dll, you have to define GL2PSDLL at compile |
---|
| 59 | time */ |
---|
| 60 | |
---|
| 61 | #ifdef WIN32 |
---|
| 62 | # include <windows.h> |
---|
| 63 | # ifdef GL2PSDLL |
---|
| 64 | # ifdef GL2PSDLL_EXPORTS |
---|
| 65 | # define GL2PSDLL_API __declspec(dllexport) |
---|
| 66 | # else |
---|
| 67 | # define GL2PSDLL_API __declspec(dllimport) |
---|
| 68 | # endif |
---|
| 69 | # else |
---|
| 70 | # define GL2PSDLL_API |
---|
| 71 | # endif |
---|
| 72 | #else |
---|
| 73 | # define GL2PSDLL_API |
---|
| 74 | #endif |
---|
| 75 | |
---|
| 76 | #ifdef __APPLE__ |
---|
| 77 | # include <OpenGL/gl.h> |
---|
| 78 | #else |
---|
| 79 | # include <GL/gl.h> |
---|
| 80 | #endif |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | #define GL2PS_VERSION 0.8 |
---|
| 84 | #define GL2PS_NONE 0 |
---|
| 85 | |
---|
| 86 | /* Output file format */ |
---|
| 87 | |
---|
| 88 | #define GL2PS_PS 1 |
---|
| 89 | #define GL2PS_EPS 2 |
---|
| 90 | #define GL2PS_TEX 3 |
---|
| 91 | |
---|
| 92 | /* Sorting algorithms */ |
---|
| 93 | |
---|
| 94 | #define GL2PS_NO_SORT 1 |
---|
| 95 | #define GL2PS_SIMPLE_SORT 2 |
---|
| 96 | #define GL2PS_BSP_SORT 3 |
---|
| 97 | |
---|
| 98 | /* Options for gl2psBeginPage */ |
---|
| 99 | |
---|
| 100 | #define GL2PS_DRAW_BACKGROUND (1<<0) |
---|
| 101 | #define GL2PS_SIMPLE_LINE_OFFSET (1<<1) |
---|
| 102 | #define GL2PS_SILENT (1<<2) |
---|
| 103 | #define GL2PS_BEST_ROOT (1<<3) |
---|
| 104 | #define GL2PS_OCCLUSION_CULL (1<<4) |
---|
| 105 | #define GL2PS_NO_TEXT (1<<5) |
---|
| 106 | #define GL2PS_LANDSCAPE (1<<6) |
---|
| 107 | #define GL2PS_NO_PS3_SHADING (1<<7) |
---|
| 108 | #define GL2PS_NO_PIXMAP (1<<8) |
---|
| 109 | |
---|
| 110 | /* Arguments for gl2psEnable/gl2psDisable */ |
---|
| 111 | |
---|
| 112 | #define GL2PS_POLYGON_OFFSET_FILL 1 |
---|
| 113 | #define GL2PS_POLYGON_BOUNDARY 2 |
---|
| 114 | #define GL2PS_LINE_STIPPLE 3 |
---|
| 115 | |
---|
| 116 | /* Magic numbers */ |
---|
| 117 | |
---|
| 118 | #define GL2PS_EPSILON 5.e-3 |
---|
| 119 | #define GL2PS_DEPTH_FACT 1000.0 |
---|
| 120 | #define GL2PS_SIMPLE_OFFSET 0.05 |
---|
| 121 | #define GL2PS_SIMPLE_OFFSET_LARGE 1.0 |
---|
| 122 | #define GL2PS_ZERO(arg) (std::fabs(arg)<1.e-20) |
---|
| 123 | /*#define GL2PS_ZERO(arg) ((arg)==0.0)*/ |
---|
| 124 | |
---|
| 125 | /* Message levels and error codes */ |
---|
| 126 | |
---|
| 127 | #define GL2PS_SUCCESS 0 |
---|
| 128 | #define GL2PS_INFO 1 |
---|
| 129 | #define GL2PS_WARNING 2 |
---|
| 130 | #define GL2PS_ERROR 3 |
---|
| 131 | #define GL2PS_NO_FEEDBACK 4 |
---|
| 132 | #define GL2PS_OVERFLOW 5 |
---|
| 133 | #define GL2PS_UNINITIALIZED 6 |
---|
| 134 | |
---|
| 135 | /* Primitive types */ |
---|
| 136 | |
---|
| 137 | #define GL2PS_TEXT 1 |
---|
| 138 | #define GL2PS_POINT 2 |
---|
| 139 | #define GL2PS_LINE 3 |
---|
| 140 | #define GL2PS_QUADRANGLE 4 |
---|
| 141 | #define GL2PS_TRIANGLE 5 |
---|
| 142 | #define GL2PS_PIXMAP 6 |
---|
| 143 | |
---|
| 144 | /* BSP tree primitive comparison */ |
---|
| 145 | |
---|
| 146 | #define GL2PS_COINCIDENT 1 |
---|
| 147 | #define GL2PS_IN_FRONT_OF 2 |
---|
| 148 | #define GL2PS_IN_BACK_OF 3 |
---|
| 149 | #define GL2PS_SPANNING 4 |
---|
| 150 | |
---|
| 151 | /* 2D BSP tree primitive comparison */ |
---|
| 152 | |
---|
| 153 | #define GL2PS_POINT_COINCIDENT 0 |
---|
| 154 | #define GL2PS_POINT_INFRONT 1 |
---|
| 155 | #define GL2PS_POINT_BACK 2 |
---|
| 156 | |
---|
| 157 | /* Pass through options */ |
---|
| 158 | |
---|
| 159 | #define GL2PS_BEGIN_POLYGON_OFFSET_FILL 1 |
---|
| 160 | #define GL2PS_END_POLYGON_OFFSET_FILL 2 |
---|
| 161 | #define GL2PS_BEGIN_POLYGON_BOUNDARY 3 |
---|
| 162 | #define GL2PS_END_POLYGON_BOUNDARY 4 |
---|
| 163 | #define GL2PS_BEGIN_LINE_STIPPLE 5 |
---|
| 164 | #define GL2PS_END_LINE_STIPPLE 6 |
---|
| 165 | #define GL2PS_SET_POINT_SIZE 7 |
---|
| 166 | #define GL2PS_SET_LINE_WIDTH 8 |
---|
| 167 | |
---|
| 168 | typedef GLfloat GL2PSrgba[4]; |
---|
| 169 | typedef GLfloat GL2PSxyz[3]; |
---|
| 170 | typedef GLfloat GL2PSplane[4]; |
---|
| 171 | |
---|
| 172 | typedef struct _GL2PSbsptree2d GL2PSbsptree2d; |
---|
| 173 | |
---|
| 174 | struct _GL2PSbsptree2d { |
---|
| 175 | GL2PSplane plane; |
---|
| 176 | GL2PSbsptree2d *front, *back; |
---|
| 177 | }; |
---|
| 178 | |
---|
| 179 | typedef struct { |
---|
| 180 | GLint nmax, size, incr, n; |
---|
| 181 | char *array; |
---|
| 182 | } GL2PSlist; |
---|
| 183 | |
---|
| 184 | typedef struct _GL2PSbsptree GL2PSbsptree; |
---|
| 185 | |
---|
| 186 | struct _GL2PSbsptree { |
---|
| 187 | GL2PSplane plane; |
---|
| 188 | GL2PSlist *primitives; |
---|
| 189 | GL2PSbsptree *front, *back; |
---|
| 190 | }; |
---|
| 191 | |
---|
| 192 | typedef struct { |
---|
| 193 | GL2PSxyz xyz; |
---|
| 194 | GL2PSrgba rgba; |
---|
| 195 | } GL2PSvertex; |
---|
| 196 | |
---|
| 197 | typedef struct { |
---|
| 198 | GLshort fontsize; |
---|
| 199 | char *str, *fontname; |
---|
| 200 | } GL2PSstring; |
---|
| 201 | |
---|
| 202 | typedef struct { |
---|
| 203 | GLsizei width, height; |
---|
| 204 | GLenum format, type; |
---|
| 205 | GLfloat *pixels; |
---|
| 206 | } GL2PSimage; |
---|
| 207 | |
---|
| 208 | typedef struct { |
---|
| 209 | GLshort type, numverts; |
---|
| 210 | char boundary, dash, culled; |
---|
| 211 | GLfloat width, depth; |
---|
| 212 | GL2PSvertex *verts; |
---|
| 213 | GL2PSstring *text; |
---|
| 214 | GL2PSimage *image; |
---|
| 215 | } GL2PSprimitive; |
---|
| 216 | |
---|
| 217 | typedef struct { |
---|
| 218 | GLint format, sort, options, colorsize, colormode, buffersize, maxbestroot; |
---|
| 219 | const char *title, *producer, *filename; |
---|
| 220 | GLboolean shade, boundary; |
---|
| 221 | GLfloat *feedback, offset[2]; |
---|
| 222 | GLint viewport[4]; |
---|
| 223 | GL2PSrgba *colormap, lastrgba, threshold; |
---|
| 224 | float lastlinewidth; |
---|
| 225 | GL2PSlist *primitives; |
---|
| 226 | GL2PSbsptree2d *imagetree; |
---|
| 227 | FILE *stream; |
---|
| 228 | } GL2PScontext; |
---|
| 229 | |
---|
| 230 | /* public functions */ |
---|
| 231 | |
---|
| 232 | #ifdef __cplusplus |
---|
| 233 | extern "C" { |
---|
| 234 | #endif |
---|
| 235 | |
---|
| 236 | GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, |
---|
| 237 | GLint viewport[4], GLint format, GLint sort, |
---|
| 238 | GLint options, GLint colormode, |
---|
| 239 | GLint colorsize, GL2PSrgba *colormap, |
---|
| 240 | GLint nr, GLint ng, GLint nb, GLint buffersize, |
---|
| 241 | FILE *stream, const char *filename); |
---|
| 242 | GL2PSDLL_API GLint gl2psEndPage(void); |
---|
| 243 | GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4]); |
---|
| 244 | GL2PSDLL_API GLint gl2psEndViewport(void); |
---|
| 245 | GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname, GLshort fontsize); |
---|
| 246 | GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, |
---|
| 247 | GLint xorig, GLint yorig, |
---|
| 248 | GLenum format, GLenum type, const void *pixels); |
---|
| 249 | GL2PSDLL_API GLint gl2psEnable(GLint mode); |
---|
| 250 | GL2PSDLL_API GLint gl2psDisable(GLint mode); |
---|
| 251 | GL2PSDLL_API GLint gl2psPointSize(GLfloat value); |
---|
| 252 | GL2PSDLL_API GLint gl2psLineWidth(GLfloat value); |
---|
| 253 | |
---|
| 254 | #ifdef __cplusplus |
---|
| 255 | } |
---|
| 256 | #endif |
---|
| 257 | |
---|
| 258 | #endif /* __GL2PS_H__ */ |
---|