40 #include <sys/types.h>
45 #if defined(GL2PS_HAVE_ZLIB)
49 #if defined(GL2PS_HAVE_LIBPNG)
54 #define M_PI 3.1415926535897932384626433832795
67 #define GL2PS_EPSILON 5.0e-3F
68 #define GL2PS_ZSCALE 1000.0F
69 #define GL2PS_ZOFFSET 5.0e-2F
70 #define GL2PS_ZOFFSET_LARGE 20.0F
71 #define GL2PS_ZERO(arg) (fabs(arg) < 1.e-20)
75 #define GL2PS_NO_TYPE -1
79 #define GL2PS_QUADRANGLE 4
80 #define GL2PS_TRIANGLE 5
81 #define GL2PS_PIXMAP 6
82 #define GL2PS_IMAGEMAP 7
83 #define GL2PS_IMAGEMAP_WRITTEN 8
84 #define GL2PS_IMAGEMAP_VISIBLE 9
85 #define GL2PS_SPECIAL 10
89 #define GL2PS_COINCIDENT 1
90 #define GL2PS_IN_FRONT_OF 2
91 #define GL2PS_IN_BACK_OF 3
92 #define GL2PS_SPANNING 4
96 #define GL2PS_POINT_COINCIDENT 0
97 #define GL2PS_POINT_INFRONT 1
98 #define GL2PS_POINT_BACK 2
102 #define GL2PS_BEGIN_OFFSET_TOKEN 1
103 #define GL2PS_END_OFFSET_TOKEN 2
104 #define GL2PS_BEGIN_BOUNDARY_TOKEN 3
105 #define GL2PS_END_BOUNDARY_TOKEN 4
106 #define GL2PS_BEGIN_STIPPLE_TOKEN 5
107 #define GL2PS_END_STIPPLE_TOKEN 6
108 #define GL2PS_POINT_SIZE_TOKEN 7
109 #define GL2PS_LINE_WIDTH_TOKEN 8
110 #define GL2PS_BEGIN_BLEND_TOKEN 9
111 #define GL2PS_END_BLEND_TOKEN 10
112 #define GL2PS_SRC_BLEND_TOKEN 11
113 #define GL2PS_DST_BLEND_TOKEN 12
114 #define GL2PS_IMAGEMAP_TOKEN 13
115 #define GL2PS_DRAW_PIXELS_TOKEN 14
116 #define GL2PS_TEXT_TOKEN 15
200 #if defined(GL2PS_HAVE_ZLIB)
201 Bytef *dest, *src, *start;
202 uLongf destLen, srcLen;
216 GLint format,
sort, options, colorsize, colormode, buffersize;
219 GLfloat *feedback, offset[2], lastlinewidth;
220 GLint viewport[4], blendfunc[2], lastfactor;
255 void (*printHeader)(void);
256 void (*printFooter)(void);
257 void (*beginViewport)(GLint viewport[4]);
258 GLint (*endViewport)(void);
259 void (*printPrimitive)(
void *data);
260 void (*printFinalPrimitive)(void);
280 static void gl2psMsg(GLint level,
const char *fmt, ...)
286 case GL2PS_INFO : fprintf(stderr,
"GL2PS info: ");
break;
287 case GL2PS_WARNING : fprintf(stderr,
"GL2PS warning: ");
break;
288 case GL2PS_ERROR : fprintf(stderr,
"GL2PS error: ");
break;
291 vfprintf(stderr, fmt, args);
293 fprintf(stderr,
"\n");
302 if(!size)
return NULL;
314 if(!size)
return NULL;
315 ptr = realloc(orig, size);
333 int size =
sizeof(
unsigned long);
334 for(i = 1; i <= bytes; ++i){
335 fputc(0xff & (data >> (size - i) * 8), gl2ps->
stream);
342 #if defined(GL2PS_HAVE_ZLIB)
344 static void gl2psSetupCompress(
void)
354 static void gl2psFreeCompress(
void)
367 static int gl2psAllocCompress(
unsigned int srcsize)
383 static void *gl2psReallocCompress(
unsigned int srcsize)
388 if(srcsize < gl2ps->compress->srcLen)
402 static int gl2psWriteBigEndianCompress(
unsigned long data,
int bytes)
405 int size =
sizeof(
unsigned long);
406 for(i = 1; i <= bytes; ++i){
407 *gl2ps->
compress->src = (Bytef)(0xff & (data >> (size-i) * 8));
413 static int gl2psDeflate(
void)
428 #if defined(GL2PS_HAVE_ZLIB)
429 unsigned int oldsize = 0;
430 static char buf[1000];
433 ret = vsprintf(buf, fmt, args);
436 gl2ps->
compress->start = (Bytef*)gl2psReallocCompress(oldsize + ret);
437 memcpy(gl2ps->
compress->start+oldsize, buf, ret);
443 ret = vfprintf(gl2ps->
stream, fmt, args);
445 #if defined(GL2PS_HAVE_ZLIB)
453 #if defined(GL2PS_HAVE_ZLIB)
454 char tmp[10] = {
'\x1f',
'\x8b',
462 gl2psSetupCompress();
464 fwrite(tmp, 10, 1, gl2ps->
stream);
471 #if defined(GL2PS_HAVE_ZLIB)
477 if(Z_OK != gl2psDeflate()){
483 if(gl2ps->
compress->dest[1] & (1<<5)){
491 for(n = 0; n < 4; ++n){
492 tmp[n] = (char)(crc & 0xff);
496 for(n = 4; n < 8; ++n){
497 tmp[n] = (char)(len & 0xff);
500 fwrite(tmp, 8, 1, gl2ps->
stream);
536 if(incr <= 0) incr = 1;
568 memcpy(&list->
array[(list->
n - 1) * list->
size], data, list->
size);
584 if((index < 0) || (index >= list->
n)){
592 int (*fcmp)(
const void *a,
const void *b))
596 qsort(list->
array, list->
n, list->
size, fcmp);
617 #if defined(GL2PS_HAVE_LIBPNG)
619 static void gl2psListRead(
GL2PSlist *list,
int index,
void *data)
621 if((index < 0) || (index >= list->
n))
626 static void gl2psEncodeBase64Block(
unsigned char in[3],
unsigned char out[4],
int len)
628 static const char cb64[] =
629 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
631 out[0] = cb64[ in[0] >> 2 ];
632 out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
633 out[2] = (len > 1) ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] :
'=';
634 out[3] = (len > 2) ? cb64[ in[2] & 0x3f ] :
'=';
637 static void gl2psListEncodeBase64(
GL2PSlist *list)
639 unsigned char *buffer, in[3], out[4];
640 int i, n, index, len;
642 n = list->
n * list->
size;
643 buffer = (
unsigned char*)
gl2psMalloc(n *
sizeof(
unsigned char));
644 memcpy(buffer, list->
array, n *
sizeof(
unsigned char));
650 for(i = 0; i < 3; i++) {
652 in[i] = buffer[index];
661 gl2psEncodeBase64Block(in, out, len);
662 for(i = 0; i < 4; i++)
686 for(i = 1; i < prim->
numverts; i++){
699 if(n < 2)
return GL_TRUE;
701 for(i = 1; i < n; i++){
702 if(fabs(rgba[0][0] - rgba[i][0]) > threshold[0] ||
703 fabs(rgba[0][1] - rgba[i][1]) > threshold[1] ||
704 fabs(rgba[0][2] - rgba[i][2]) > threshold[2])
714 for(i = 0; i < 3; ++i){
720 GLfloat *red, GLfloat *green, GLfloat *blue)
723 GLsizei width = im->
width;
724 GLsizei height = im->
height;
725 GLfloat *pixels = im->
pixels;
731 pimag = pixels + 4 * (width * (height - 1 - y) + x);
735 pimag = pixels + 3 * (width * (height - 1 - y) + x);
738 *red = *pimag; pimag++;
739 *green = *pimag; pimag++;
740 *blue = *pimag; pimag++;
742 return (im->
format == GL_RGBA) ? *pimag : 1.0F;
761 size = image->
height * image->
width * 4 *
sizeof(GLfloat);
765 size = image->
height * image->
width * 3 *
sizeof(GLfloat);
783 #if defined(GL2PS_HAVE_LIBPNG)
785 #if !defined(png_jmpbuf)
786 # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
789 static void gl2psUserWritePNG(png_structp png_ptr, png_bytep data, png_size_t length)
793 for(i = 0; i < length; i++)
797 static void gl2psUserFlushPNG(png_structp png_ptr)
806 unsigned char *row_data;
810 if(!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)))
813 if(!(info_ptr = png_create_info_struct(png_ptr))){
814 png_destroy_write_struct(&png_ptr, NULL);
818 if(setjmp(png_jmpbuf(png_ptr))) {
819 png_destroy_write_struct(&png_ptr, &info_ptr);
823 png_set_write_fn(png_ptr, (
void *)png, gl2psUserWritePNG, gl2psUserFlushPNG);
824 png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
825 png_set_IHDR(png_ptr, info_ptr, pixmap->
width, pixmap->
height, 8,
826 PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
827 PNG_FILTER_TYPE_BASE);
828 png_write_info(png_ptr, info_ptr);
830 row_data = (
unsigned char*)
gl2psMalloc(3 * pixmap->
width *
sizeof(
unsigned char));
831 for(row = 0; row < pixmap->
height; row++){
832 for(col = 0; col < pixmap->
width; col++){
834 row_data[3*col] = (
unsigned char)(255. * dr);
835 row_data[3*col+1] = (
unsigned char)(255. * dg);
836 row_data[3*col+2] = (
unsigned char)(255. * db);
838 png_write_row(png_ptr, (png_bytep)row_data);
842 png_write_end(png_ptr, info_ptr);
843 png_destroy_write_struct(&png_ptr, &info_ptr);
850 static GLint
gl2psAddText(GLint type,
const char *str,
const char *fontname,
851 GLshort fontsize, GLint alignment, GLfloat angle)
861 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
864 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
867 prim->
type = (GLshort)type;
879 glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->
verts[0].
rgba);
899 strcpy(text->
str, t->
str);
925 if( (sfactor == GL_SRC_ALPHA && dfactor == GL_ONE_MINUS_SRC_ALPHA) ||
926 (sfactor == GL_ONE && dfactor == GL_ZERO) )
989 GLboolean assignprops)
994 if(GL_TRUE == assignprops)
1002 for(i = 0; i < 3; i++)
1063 return (plane[0] * point[0] +
1064 plane[1] * point[1] +
1065 plane[2] * point[2] +
1071 return (a[0]*b[0] + a[1]*b[1] + a[2]*b[2]);
1076 c[0] = a[1]*b[2] - a[2]*b[1];
1077 c[1] = a[2]*b[0] - a[0]*b[2];
1078 c[2] = a[0]*b[1] - a[1]*b[0];
1083 return (GLfloat)sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
1107 GL2PSxyz v = {0.0F, 0.0F, 0.0F}, w = {0.0F, 0.0F, 0.0F};
1120 plane[0] = plane[1] = 0.0F;
1129 - plane[2] * prim->
verts[0].
xyz[2];
1137 plane[0] = plane[1] = 0.0F;
1149 - plane[2] * prim->
verts[0].
xyz[2];
1157 plane[0] = plane[1] = 0.0F;
1163 plane[0] = plane[1] = plane[3] = 0.0F;
1175 v[0] = b->
xyz[0] - a->
xyz[0];
1176 v[1] = b->
xyz[1] - a->
xyz[1];
1177 v[2] = b->
xyz[2] - a->
xyz[2];
1184 c->
xyz[0] = a->
xyz[0] + v[0] * sect;
1185 c->
xyz[1] = a->
xyz[1] + v[1] * sect;
1186 c->
xyz[2] = a->
xyz[2] + v[2] * sect;
1188 c->
rgba[0] = (1 - sect) * a->
rgba[0] + sect * b->
rgba[0];
1189 c->
rgba[1] = (1 - sect) * a->
rgba[1] + sect * b->
rgba[1];
1190 c->
rgba[2] = (1 - sect) * a->
rgba[2] + sect * b->
rgba[2];
1191 c->
rgba[3] = (1 - sect) * a->
rgba[3] + sect * b->
rgba[3];
1196 GLshort *index0, GLshort *index1)
1227 for(i = 0; i < numverts; i++){
1233 plane, &child->
verts[i]);
1239 GLshort i, GLshort j)
1243 for(k = 0; k < *nb; k++){
1244 if((index0[k] == i && index1[k] == j) ||
1245 (index1[k] == i && index0[k] == j))
return;
1254 return (i < num - 1) ? i + 1 : 0;
1263 for(i = 0; i < prim->
numverts; i++){
1271 for(i = 0; i < prim->
numverts; i++){
1291 GLshort i, j, in = 0, out = 0, in0[5], in1[5], out0[5], out1[5];
1297 for(i = 0; i < prim->
numverts; i++){
1308 for(i = 0; i < prim->
numverts; i++){
1354 (*t1)->numverts = (*t2)->numverts = 3;
1355 (*t1)->culled = (*t2)->culled = quad->
culled;
1356 (*t1)->offset = (*t2)->offset = quad->
offset;
1357 (*t1)->pattern = (*t2)->pattern = quad->
pattern;
1358 (*t1)->factor = (*t2)->factor = quad->
factor;
1359 (*t1)->width = (*t2)->width = quad->
width;
1362 (*t1)->verts[0] = quad->
verts[0];
1363 (*t1)->verts[1] = quad->
verts[1];
1364 (*t1)->verts[2] = quad->
verts[2];
1365 (*t1)->boundary = ((quad->
boundary & 1) ? 1 : 0) | ((quad->
boundary & 2) ? 2 : 0);
1366 (*t2)->verts[0] = quad->
verts[0];
1367 (*t2)->verts[1] = quad->
verts[2];
1368 (*t2)->verts[2] = quad->
verts[3];
1369 (*t2)->boundary = ((quad->
boundary & 4) ? 2 : 0) | ((quad->
boundary & 8) ? 4 : 0);
1375 GLfloat dq = 0.0F, dw = 0.0F, diff;
1386 for(i = 0; i < w->numverts; i++){
1409 return (q->
type < w->
type ? 1 : -1);
1414 GLint i, j, count, best = 1000000, index = 0;
1431 for(i = 0; i < maxp; i++){
1440 if(count > best)
break;
1446 if(!count)
return index;
1460 while(list != NULL){
1504 if((*tree)->primitives){
1516 if(f1 > f2)
return GL_TRUE;
1517 else return GL_FALSE;
1522 if(f1 < f2)
return GL_TRUE;
1523 else return GL_FALSE;
1590 GLboolean (*compare)(GLfloat f1, GLfloat f2),
1591 void (*action)(
void *data),
int inverse)
1599 if(GL_TRUE == compare(result, epsilon)){
1609 else if(GL_TRUE == compare(-epsilon, result)){
1628 GLfloat minZ, maxZ, rangeZ, scaleZ;
1629 GLfloat factor, units, area, dZ, dZdX, dZdY, maxdZ;
1637 minZ = maxZ = prim->
verts[0].
xyz[2];
1638 for(i = 1; i < prim->
numverts; i++){
1644 for(j = 0; j < prim->
numverts; j++){
1649 rangeZ = (maxZ - minZ);
1655 if(scaleZ > 100000.F) scaleZ = 100000.F;
1660 for(j = 0; j < prim->
numverts; j++){
1675 factor = gl2ps->
offset[0];
1676 units = gl2ps->
offset[1];
1693 maxdZ = (GLfloat)sqrt(dZdX * dZdX + dZdY * dZdY);
1698 dZ = factor * maxdZ + units;
1716 plane[0] = b[1] - a[1];
1717 plane[1] = a[0] - b[0];
1718 n = (GLfloat)sqrt(plane[0]*plane[0] + plane[1]*plane[1]);
1723 plane[3] = -plane[0]*a[0]-plane[1]*a[1];
1762 if((*tree == NULL) && (prim->
numverts > 2)){
1768 for(i = 0; i < prim->
numverts-1; i++){
1786 for(i = 2+offset; i < prim->
numverts; i++){
1793 for(i = 1+offset; i < prim->
numverts-1; i++){
1794 if(cur->front == NULL){
1799 cur->front->plane)){
1805 if(cur->front == NULL){
1810 cur->front->plane)){
1811 cur->front->front = NULL;
1812 cur->front->back = NULL;
1820 for(i = 0; i < 4; i++){
1824 for(i = 1+offset; i < prim->
numverts-1; i++){
1825 if(cur->front == NULL){
1830 cur->front->plane)){
1836 if(cur->front == NULL){
1841 cur->front->plane)){
1842 cur->front->front = NULL;
1843 cur->front->back = NULL;
1864 for(i = 1; i < prim->
numverts; i++){
1901 for(i = 0; i < numverts; i++){
1902 child->
verts[i] = vertx[i];
1917 GLint cur = -1, prev = -1, i, v1 = 0, v2 = 0,
flag = 1, prev0 = -1;
1920 GL2PSvertex *front_list = NULL, *back_list = NULL;
1923 GLshort front_count = 0, back_count = 0;
1925 for(i = 0; i <= prim->
numverts; i++){
1939 if(((prev == -1) || (prev == cur) || (prev == 0) || (cur == 0)) &&
1940 (i < prim->numverts)){
1945 front_list[front_count-1] = prim->
verts[v1];
1951 back_list[back_count-1] = prim->
verts[v1];
1957 front_list[front_count-1] = prim->
verts[v1];
1961 back_list[back_count-1] = prim->
verts[v1];
1965 else if((prev != cur) && (cur != 0) && (prev != 0)){
1974 plane, &front_list[front_count-1]);
1978 back_list[back_count-1] = front_list[front_count-1];
2018 if((*tree)->front != NULL){
2029 if((*tree)->back != NULL){
2035 if((*tree)->front != NULL){
2071 c[0] = c[1] = c[2] = 0.0F;
2072 for(i = 0; i < prim->
numverts; i++){
2079 for(i = 0; i < prim->
numverts; i++){
2080 if(prim->
boundary & (GLint)pow(2., i)){
2093 v[0] = c[0] - prim->
verts[i].
xyz[0];
2094 v[1] = c[1] - prim->
verts[i].
xyz[1];
2155 GLushort pattern, GLint factor,
2156 GLfloat width,
char boundary)
2166 prim->
offset = (char)offset;
2169 prim->
width = width;
2187 i = (GLint)(p[3] + 0.5);
2206 GLushort pattern = 0;
2208 GLint i, sizeoffloat, count, v, vtot, offset = 0, factor = 0, auxindex = 0;
2209 GLfloat lwidth = 1.0F, psize = 1.0F;
2216 boundary = gl2ps->
boundary = GL_FALSE;
2220 if(GL_TRUE == boundary) gl2ps->
boundary = GL_TRUE;
2222 switch((GLint)*current){
2223 case GL_POINT_TOKEN :
2230 pattern, factor, psize, 0);
2232 case GL_LINE_TOKEN :
2233 case GL_LINE_RESET_TOKEN :
2243 pattern, factor, lwidth, 0);
2245 case GL_POLYGON_TOKEN :
2246 count = (GLint)current[1];
2250 while(count > 0 && used > 0){
2258 if(GL_TRUE == boundary){
2259 if(!count && vtot == 2) flag = 1|2|4;
2260 else if(!count) flag = 2|4;
2261 else if(vtot == 2) flag = 1|2;
2267 pattern, factor, 1, flag);
2268 vertices[1] = vertices[2];
2274 case GL_BITMAP_TOKEN :
2275 case GL_DRAW_PIXEL_TOKEN :
2276 case GL_COPY_PIXEL_TOKEN :
2283 case GL_PASS_THROUGH_TOKEN :
2284 switch((GLint)current[1]){
2295 pattern = (GLushort)current[1];
2298 factor = (GLint)current[1];
2303 gl2ps->
blendfunc[0] = (GLint)current[1];
2308 gl2ps->
blendfunc[1] = (GLint)current[1];
2318 lwidth = current[1];
2347 current += 2; used -= 2;
2349 current += i; used -= i;
2352 current += 2; used -= 2;
2356 for(i = 1; i < 4; i++){
2357 for(v = 0; v < 3; v++){
2368 sizeoffloat =
sizeof(GLfloat);
2369 v = 2 * sizeoffloat;
2376 for(i = 0; i < vtot; i += sizeoffloat){
2377 current += 2; used -= 2;
2379 memcpy(&(((
char*)(node->
image->
pixels))[i + v]), &(current[2]), sizeoffloat);
2381 memcpy(&(((
char*)(node->
image->
pixels))[i + v]), &(current[2]), vtot - i);
2417 unsigned char h = byte / 16;
2418 unsigned char l = byte % 16;
2424 GLuint nbhex, nbyte, nrgb, nbits;
2425 GLuint row, col, ibyte, icase;
2426 GLfloat dr, dg, db, fgrey;
2427 unsigned char red = 0, green = 0, blue = 0, b, grey;
2428 GLuint width = (GLuint)im->
width;
2429 GLuint height = (GLuint)im->
height;
2436 if((width <= 0) || (height <= 0))
return;
2445 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2446 gl2psPrintf(
"{ currentfile picstr readhexstring pop }\n");
2448 for(row = 0; row < height; row++){
2449 for(col = 0; col < width; col++){
2451 fgrey = (0.30F * dr + 0.59F * dg + 0.11F * db);
2452 grey = (
unsigned char)(255. * fgrey);
2457 nbhex = width * height * 2;
2462 nbits = nrgb * nbit;
2464 if((nbyte * 8) != nbits) nbyte++;
2467 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2468 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2471 for(row = 0; row < height; row++){
2475 for(ibyte = 0; ibyte < nbyte; ibyte++){
2484 red = (
unsigned char)(3. * dr);
2485 green = (
unsigned char)(3. * dg);
2486 blue = (
unsigned char)(3. * db);
2497 red = (
unsigned char)(3. * dr);
2498 green = (
unsigned char)(3. * dg);
2499 blue = (
unsigned char)(3. * db);
2505 else if(icase == 2) {
2515 red = (
unsigned char)(3. * dr);
2516 green = (
unsigned char)(3. * dg);
2517 blue = (
unsigned char)(3. * db);
2524 else if(icase == 3) {
2533 red = (
unsigned char)(3. * dr);
2534 green = (
unsigned char)(3. * dg);
2535 blue = (
unsigned char)(3. * db);
2549 nbits = nrgb * nbit;
2551 if((nbyte * 8) != nbits) nbyte++;
2554 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2555 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2558 for(row = 0; row < height; row++){
2561 for(ibyte = 0; ibyte < nbyte; ibyte++){
2570 red = (
unsigned char)(15. * dr);
2571 green = (
unsigned char)(15. * dg);
2575 else if(icase == 2) {
2576 blue = (
unsigned char)(15. * db);
2584 red = (
unsigned char)(15. * dr);
2588 else if(icase == 3) {
2589 green = (
unsigned char)(15. * dg);
2590 blue = (
unsigned char)(15. * db);
2602 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2603 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2606 for(row = 0; row < height; row++){
2607 for(col = 0; col < width; col++){
2609 red = (
unsigned char)(255. * dr);
2611 green = (
unsigned char)(255. * dg);
2613 blue = (
unsigned char)(255. * db);
2624 GLsizei width, GLsizei height,
2625 const unsigned char *imagemap){
2628 if((width <= 0) || (height <= 0))
return;
2630 size = height + height * (width - 1) / 8;
2634 gl2psPrintf(
"%d %d scale\n%d %d\ntrue\n", width, height,width, height);
2635 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ] {<", width, height);
2636 for(i = 0; i < size; i++){
2662 "%%%%Creator: GL2PS %d.%d.%d%s, %s\n"
2664 "%%%%CreationDate: %s"
2665 "%%%%LanguageLevel: 3\n"
2666 "%%%%DocumentData: Clean7Bit\n"
2674 "%%%%DocumentMedia: Default %d %d 0 () ()\n",
2683 "%%%%EndComments\n",
2707 "/gl2psdict 64 dict def gl2psdict begin\n"
2708 "0 setlinecap 0 setlinejoin\n"
2709 "/tryPS3shading %s def %% set to false to force subdivision\n"
2710 "/rThreshold %g def %% red component subdivision threshold\n"
2711 "/gThreshold %g def %% green component subdivision threshold\n"
2712 "/bThreshold %g def %% blue component subdivision threshold\n",
2717 "/C { setrgbcolor } BD\n"
2718 "/G { 0.082 mul exch 0.6094 mul add exch 0.3086 mul add neg 1.0 add setgray } BD\n"
2719 "/W { setlinewidth } BD\n");
2721 gl2psPrintf(
"/FC { findfont exch /SH exch def SH scalefont setfont } BD\n"
2722 "/SW { dup stringwidth pop } BD\n"
2723 "/S { FC moveto show } BD\n"
2724 "/SBC{ FC moveto SW -2 div 0 rmoveto show } BD\n"
2725 "/SBR{ FC moveto SW neg 0 rmoveto show } BD\n"
2726 "/SCL{ FC moveto 0 SH -2 div rmoveto show } BD\n"
2727 "/SCC{ FC moveto SW -2 div SH -2 div rmoveto show } BD\n"
2728 "/SCR{ FC moveto SW neg SH -2 div rmoveto show } BD\n"
2729 "/STL{ FC moveto 0 SH neg rmoveto show } BD\n"
2730 "/STC{ FC moveto SW -2 div SH neg rmoveto show } BD\n"
2731 "/STR{ FC moveto SW neg SH neg rmoveto show } BD\n");
2736 "/SR { gsave FCT moveto rotate show grestore } BD\n"
2737 "/SBCR{ gsave FCT moveto rotate SW -2 div 0 rmoveto show grestore } BD\n"
2738 "/SBRR{ gsave FCT moveto rotate SW neg 0 rmoveto show grestore } BD\n"
2739 "/SCLR{ gsave FCT moveto rotate 0 SH -2 div rmoveto show grestore} BD\n");
2740 gl2psPrintf(
"/SCCR{ gsave FCT moveto rotate SW -2 div SH -2 div rmoveto show grestore} BD\n"
2741 "/SCRR{ gsave FCT moveto rotate SW neg SH -2 div rmoveto show grestore} BD\n"
2742 "/STLR{ gsave FCT moveto rotate 0 SH neg rmoveto show grestore } BD\n"
2743 "/STCR{ gsave FCT moveto rotate SW -2 div SH neg rmoveto show grestore } BD\n"
2744 "/STRR{ gsave FCT moveto rotate SW neg SH neg rmoveto show grestore } BD\n");
2746 gl2psPrintf(
"/P { newpath 0.0 360.0 arc closepath fill } BD\n"
2747 "/LS { newpath moveto } BD\n"
2748 "/L { lineto } BD\n"
2749 "/LE { lineto stroke } BD\n"
2750 "/T { newpath moveto lineto lineto closepath fill } BD\n");
2756 " /b1 exch def /g1 exch def /r1 exch def /y1 exch def /x1 exch def\n"
2757 " /b2 exch def /g2 exch def /r2 exch def /y2 exch def /x2 exch def\n"
2758 " /b3 exch def /g3 exch def /r3 exch def /y3 exch def /x3 exch def\n"
2759 " gsave << /ShadingType 4 /ColorSpace [/DeviceRGB]\n"
2760 " /DataSource [ 0 x1 y1 r1 g1 b1 0 x2 y2 r2 g2 b2 0 x3 y3 r3 g3 b3 ] >>\n"
2761 " shfill grestore } BD\n");
2767 "/Tm { 3 -1 roll 8 -1 roll 13 -1 roll add add 3 div\n"
2769 " 3 -1 roll 7 -1 roll 11 -1 roll add add 3 div\n"
2771 " 3 -1 roll 6 -1 roll 9 -1 roll add add 3 div"
2781 " 4 index 15 index add 0.5 mul\n"
2782 " 4 index 15 index add 0.5 mul\n"
2783 " 4 index 15 index add 0.5 mul\n"
2784 " 4 index 15 index add 0.5 mul\n"
2785 " 4 index 15 index add 0.5 mul\n"
2786 " 5 copy 5 copy 25 15 roll\n");
2791 " 9 index 30 index add 0.5 mul\n"
2792 " 9 index 30 index add 0.5 mul\n"
2793 " 9 index 30 index add 0.5 mul\n"
2794 " 9 index 30 index add 0.5 mul\n"
2795 " 5 copy 5 copy 35 5 roll 25 5 roll 15 5 roll\n");
2800 " 4 index 10 index add 0.5 mul\n"
2801 " 4 index 10 index add 0.5 mul\n"
2802 " 4 index 10 index add 0.5 mul\n"
2803 " 4 index 10 index add 0.5 mul\n"
2804 " 5 copy 5 copy 40 5 roll 25 5 roll 15 5 roll 25 5 roll\n");
2808 gl2psPrintf(
" STnoshfill STnoshfill STnoshfill STnoshfill } BD\n");
2815 " 2 index 8 index sub abs rThreshold gt\n"
2817 " { 1 index 7 index sub abs gThreshold gt\n"
2819 " { dup 6 index sub abs bThreshold gt\n"
2821 " { 2 index 13 index sub abs rThreshold gt\n"
2823 " { 1 index 12 index sub abs gThreshold gt\n"
2825 " { dup 11 index sub abs bThreshold gt\n"
2827 " { 7 index 13 index sub abs rThreshold gt\n");
2829 " { 6 index 12 index sub abs gThreshold gt\n"
2831 " { 5 index 11 index sub abs bThreshold gt\n"
2846 " { /ST { STshfill } BD }\n"
2847 " { /ST { STnoshfill } BD }\n"
2849 "{ /ST { STnoshfill } BD }\n"
2855 "/DeviceRGB setcolorspace\n"
2859 "%%%%BeginPageSetup\n");
2873 "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n"
2886 gl2psPrintf(
"%g %g %g C\n", rgba[0], rgba[1], rgba[2]);
2900 for(i = 0; i < 3; i++)
2902 for(i = 0; i < 4; i++)
2908 int *nb,
int array[10])
2911 int on[8] = {0, 0, 0, 0, 0, 0, 0, 0};
2912 int off[8] = {0, 0, 0, 0, 0, 0, 0, 0};
2916 for(n = 15; n >= 0; n--){
2917 tmp[n] = (char)(pattern & 0x01);
2922 for(i = 0; i < 8; i++){
2923 while(n < 16 && !tmp[n]){ off[i]++; n++; }
2924 while(n < 16 && tmp[n]){ on[i]++; n++; }
2925 if(n >= 15){ i++;
break; }
2934 for(n = i - 1; n >= 0; n--){
2935 array[(*nb)++] = factor * on[n];
2936 array[(*nb)++] = factor * off[n];
2937 if(*nb == 10)
break;
2943 int len = 0, i, n, array[10];
2951 if(!pattern || !factor){
2958 for(i = 0; i < n; i++){
3015 newline ?
"LS" :
"L");
3021 gl2psPrintf(
"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g ST\n",
3124 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
3126 glRenderMode(GL_FEEDBACK);
3130 gl2ps->
header = GL_FALSE;
3138 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
3141 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &index);
3142 rgba[0] = gl2ps->
colormap[index][0];
3143 rgba[1] = gl2ps->
colormap[index][1];
3144 rgba[2] = gl2ps->
colormap[index][2];
3148 "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n"
3150 rgba[0], rgba[1], rgba[2],
3151 x, y, x+w, y, x+w, y+h, x, y+h);
3154 gl2psPrintf(
"newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n"
3156 x, y, x+w, y, x+w, y+h, x, y+h);
3196 "Encapsulated Postscript"
3212 for(i = (
int)strlen(gl2ps->
filename) - 1; i >= 0; i--){
3219 if(i <= 0) strcpy(name, gl2ps->
filename);
3222 strcpy(name,
"untitled");
3229 "%% Creator: GL2PS %d.%d.%d%s, %s\n"
3231 "%% CreationDate: %s",
3237 "\\setlength{\\unitlength}{1pt}\n"
3238 "\\begin{picture}(0,0)\n"
3239 "\\includegraphics{%s}\n"
3240 "\\end{picture}%%\n"
3241 "%s\\begin{picture}(%d,%d)(0,0)\n",
3254 fprintf(gl2ps->
stream,
"\\fontsize{%d}{0}\n\\selectfont",
3256 fprintf(gl2ps->
stream,
"\\put(%g,%g)",
3260 fprintf(gl2ps->
stream,
"{\\makebox(0,0)");
3263 fprintf(gl2ps->
stream,
"{");
3266 fprintf(gl2ps->
stream,
"[l]{");
3269 fprintf(gl2ps->
stream,
"[r]{");
3272 fprintf(gl2ps->
stream,
"[b]{");
3275 fprintf(gl2ps->
stream,
"[br]{");
3278 fprintf(gl2ps->
stream,
"[t]{");
3281 fprintf(gl2ps->
stream,
"[tl]{");
3284 fprintf(gl2ps->
stream,
"[tr]{");
3288 fprintf(gl2ps->
stream,
"[bl]{");
3291 fprintf(gl2ps->
stream,
"\\textcolor[rgb]{%g,%g,%g}{{%s}}",
3295 fprintf(gl2ps->
stream,
"}");
3296 fprintf(gl2ps->
stream,
"}}\n");
3311 fprintf(gl2ps->
stream,
"\\end{picture}%s\n",
3318 glRenderMode(GL_FEEDBACK);
3322 gl2ps->
header = GL_FALSE;
3356 #if defined(GL2PS_HAVE_ZLIB)
3358 return fprintf(gl2ps->
stream,
"/Filter [/FlateDecode]\n");
3369 for(i = 0; i < 3; ++i){
3372 else if(rgba[i] < 1e-4 || rgba[i] > 1e6)
3385 for(i = 0; i < 3; ++i){
3388 else if(rgba[i] < 1e-4 || rgba[i] > 1e6)
3401 else if(lw < 1e-4 || lw > 1e6)
3409 GLfloat rad, crad, srad;
3411 if(text->
angle == 0.0F){
3421 rad = (GLfloat)(
M_PI * text->
angle / 180.0F);
3422 srad = (GLfloat)sin(rad);
3423 crad = (GLfloat)cos(rad);
3427 "%f %f %f %f %f %f Tm\n"
3430 cnt, text->
fontsize, crad, srad, -srad, crad, x, y, text->
str);
3438 "%d 0 0 %d %f %f cm\n"
3441 (
int)image->
width, (
int)image->
height, x, y, cnt);
3474 GL2PSrgba lastrgba = {-1.0F, -1.0F, -1.0F, -1.0F};
3475 GLushort lastpattern = 0;
3476 GLint lastfactor = 0;
3477 GLfloat lastwidth = 1;
3479 int lastTriangleWasNotSimpleWithSameColor = 0;
3505 if(lasttype != p->
type || lastwidth != p->
width ||
3518 lastwidth = p->
width;
3524 if(lasttype != p->
type || lastwidth != p->
width ||
3534 lastwidth = p->
width;
3541 lastTriangleWasNotSimpleWithSameColor =
3545 lastTriangleWasNotSimpleWithSameColor){
3642 for(j = 0; j <= lastel; ++j){
3664 for(j = 1; j <= lastel; ++j){
3673 prev->verts[1].xyz[0], prev->verts[1].xyz[1]);
3699 for(j = 0; j <= lastel; ++j){
3719 for(j = 0; j <= lastel; ++j){
3742 for(j = 0; j <= lastel; ++j){
3784 for(j = 0; j <= lastel; ++j){
3791 for(j = 0; j <= lastel; ++j){
3812 offs += fprintf(gl2ps->
stream,
3821 offs += fprintf(gl2ps->
stream,
">>\n");
3833 offs += fprintf(gl2ps->
stream,
3843 offs += fprintf(gl2ps->
stream,
">>\n");
3856 offs += fprintf(gl2ps->
stream,
3879 offs += fprintf(gl2ps->
stream,
">>\n");
3891 offs += fprintf(gl2ps->
stream,
"/Font\n<<\n");
3900 offs += fprintf(gl2ps->
stream,
">>\n");
3931 newtime = gmtime(&now);
3933 offs = fprintf(gl2ps->
stream,
3937 "/Creator (GL2PS %d.%d.%d%s, %s)\n"
3944 offs += fprintf(gl2ps->
stream,
3950 offs += fprintf(gl2ps->
stream,
3951 "/CreationDate (D:%d%02d%02d%02d%02d%02d)\n"
3954 newtime->tm_year+1900,
3967 return fprintf(gl2ps->
stream,
3978 return fprintf(gl2ps->
stream,
3994 offs += fprintf(gl2ps->
stream,
3997 "/Length 5 0 R\n" );
3999 offs += fprintf(gl2ps->
stream,
4033 #if defined(GL2PS_HAVE_ZLIB)
4035 gl2psSetupCompress();
4039 offs += fprintf(gl2ps->
stream,
"%%PDF-1.4\n");
4075 #if defined(GL2PS_HAVE_ZLIB)
4077 if(Z_OK != gl2psDeflate())
4084 gl2psFreeCompress();
4088 offs += fprintf(gl2ps->
stream,
4098 return fprintf(gl2ps->
stream,
4112 offs = fprintf(gl2ps->
stream,
4117 "/MediaBox [%d %d %d %d]\n",
4122 offs += fprintf(gl2ps->
stream,
"/Rotate -90\n");
4124 offs += fprintf(gl2ps->
stream,
4128 "/ProcSet [/PDF /Text /ImageB /ImageC] %%/ImageI\n");
4152 offs += fprintf(gl2ps->
stream,
4163 return fprintf(gl2ps->
stream,
4166 "/Type /ExtGState\n"
4182 int (*action)(
unsigned long data,
int size),
4183 GLfloat dx, GLfloat dy,
4184 GLfloat xmin, GLfloat ymin)
4193 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4195 offs += (*action)(edgeflag, 1);
4201 offs += (*action)(0, 4);
4202 offs += (*action)(0, 4);
4205 diff = (vertex->
xyz[0] - xmin) / dx;
4210 imap = (
unsigned long)(diff * dmax);
4211 offs += (*action)(imap, 4);
4213 diff = (vertex->
xyz[1] - ymin) / dy;
4218 imap = (
unsigned long)(diff * dmax);
4219 offs += (*action)(imap, 4);
4228 int (*action)(
unsigned long data,
int size))
4235 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4237 imap = (
unsigned long)((vertex->
rgba[0]) * dmax);
4238 offs += (*action)(imap, 1);
4240 imap = (
unsigned long)((vertex->
rgba[1]) * dmax);
4241 offs += (*action)(imap, 1);
4243 imap = (
unsigned long)((vertex->
rgba[2]) * dmax);
4244 offs += (*action)(imap, 1);
4252 int (*action)(
unsigned long data,
int size),
4260 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4262 if(sigbyte != 8 && sigbyte != 16)
4267 imap = (
unsigned long)((vertex->
rgba[3]) * dmax);
4269 offs += (*action)(imap, sigbyte);
4277 GLfloat dx, GLfloat dy,
4278 GLfloat xmin, GLfloat ymin,
4279 int (*action)(
unsigned long data,
int size),
4285 if(gray && gray != 8 && gray != 16)
4288 for(i = 0; i < 3; ++i){
4290 dx, dy, xmin, ymin);
4304 GLfloat *ymin, GLfloat *ymax,
4314 for(i = 0; i < cnt; ++i){
4315 for(j = 0; j < 3; ++j){
4316 if(*xmin > triangles[i].vertex[j].xyz[0])
4318 if(*xmax < triangles[i].vertex[j].xyz[0])
4320 if(*ymin > triangles[i].vertex[j].xyz[1])
4322 if(*ymax < triangles[i].vertex[j].xyz[1])
4336 int i, offs = 0, vertexbytes, done = 0;
4337 GLfloat xmin, xmax, ymin, ymax;
4341 vertexbytes = 1+4+4+1+1+1;
4344 vertexbytes = 1+4+4+1;
4347 vertexbytes = 1+4+4+2;
4351 vertexbytes = 1+4+4+1;
4357 offs += fprintf(gl2ps->
stream,
4362 "/BitsPerCoordinate 32 "
4363 "/BitsPerComponent %d "
4365 "/Decode [%f %f %f %f 0 1 %s] ",
4367 (gray) ?
"/DeviceGray" :
"/DeviceRGB",
4369 xmin, xmax, ymin, ymax,
4370 (gray) ?
"" :
"0 1 0 1");
4372 #if defined(GL2PS_HAVE_ZLIB)
4374 gl2psAllocCompress(vertexbytes * size * 3);
4376 for(i = 0; i < size; ++i)
4378 xmax-xmin, ymax-ymin, xmin, ymin,
4379 gl2psWriteBigEndianCompress, gray);
4381 if(Z_OK == gl2psDeflate() && 23 + gl2ps->
compress->destLen < gl2ps->
compress->srcLen){
4383 offs += fprintf(gl2ps->
stream,
4393 gl2psFreeCompress();
4400 offs += fprintf(gl2ps->
stream,
4404 vertexbytes * 3 * size);
4405 for(i = 0; i < size; ++i)
4407 xmax-xmin, ymax-ymin, xmin, ymin,
4411 offs += fprintf(gl2ps->
stream,
4424 offs += fprintf(gl2ps->
stream,
4429 "/BBox [ %d %d %d %d ]\n"
4430 "/Group \n<<\n/S /Transparency /CS /DeviceRGB\n"
4437 ? (
int)strlen(
"/TrSh sh\n") + (
int)log10((
double)childobj)+1
4438 : (
int)strlen(
"/TrSh0 sh\n");
4440 offs += fprintf(gl2ps->
stream,
4445 offs += fprintf(gl2ps->
stream,
4448 offs += fprintf(gl2ps->
stream,
4463 offs += fprintf(gl2ps->
stream,
4468 offs += fprintf(gl2ps->
stream,
4469 "/SMask << /S /Alpha /G %d 0 R >> ",
4472 offs += fprintf(gl2ps->
stream,
4484 offs += fprintf(gl2ps->
stream,
4497 int (*action)(
unsigned long data,
int size),
4503 if(im->
format != GL_RGBA && gray)
4506 if(gray && gray != 8 && gray != 16)
4511 shift = (
sizeof(
unsigned long) - 1) * 8;
4513 for(y = 0; y < im->
height; ++y){
4514 for(x = 0; x < im->
width; ++x){
4516 if(im->
format == GL_RGBA && gray){
4517 (*action)((
unsigned long)(a * 255) << shift, gray);
4520 (*action)((
unsigned long)(r * 255) << shift, 1);
4521 (*action)((
unsigned long)(g * 255) << shift, 1);
4522 (*action)((
unsigned long)(b * 255) << shift, 1);
4537 int offs = 0, done = 0, sigbytes = 3;
4539 if(gray && gray !=8 && gray != 16)
4543 sigbytes = gray / 8;
4545 offs += fprintf(gl2ps->
stream,
4553 "/BitsPerComponent 8\n",
4556 (gray) ?
"/DeviceGray" :
"/DeviceRGB" );
4557 if(GL_RGBA == im->
format && gray == 0){
4558 offs += fprintf(gl2ps->
stream,
4563 #if defined(GL2PS_HAVE_ZLIB)
4565 gl2psAllocCompress((
int)(im->
width * im->
height * sigbytes));
4569 if(Z_OK == gl2psDeflate() && 23 + gl2ps->
compress->destLen < gl2ps->
compress->srcLen){
4571 offs += fprintf(gl2ps->
stream,
4580 gl2psFreeCompress();
4587 offs += fprintf(gl2ps->
stream,
4595 offs += fprintf(gl2ps->
stream,
4606 offs += fprintf(gl2ps->
stream,
4613 "/Encoding /MacRomanEncoding\n"
4627 int offs = entryoffs;
4647 for(j = 0; j < size; ++j){
4752 #if defined(GL2PS_HAVE_ZLIB)
4754 gl2psFreeCompress();
4768 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
4770 glRenderMode(GL_FEEDBACK);
4774 gl2ps->
header = GL_FALSE;
4781 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
4784 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &index);
4785 rgba[0] = gl2ps->
colormap[index][0];
4786 rgba[1] = gl2ps->
colormap[index][1];
4787 rgba[2] = gl2ps->
colormap[index][2];
4829 "Portable Document Format"
4843 for(i = 0; i < n; i++){
4844 xyz[i][0] = verts[i].
xyz[0];
4847 for(j = 0; j < 4; j++)
4848 rgba[i][j] = verts[i].rgba[j];
4854 int r = (
int)(255. * rgba[0]);
4855 int g = (
int)(255. * rgba[1]);
4856 int b = (
int)(255. * rgba[2]);
4857 int rc = (r < 0) ? 0 : (r > 255) ? 255 : r;
4858 int gc = (g < 0) ? 0 : (g > 255) ? 255 : g;
4859 int bc = (b < 0) ? 0 : (b > 255) ? 255 : b;
4860 sprintf(str,
"#%2.2x%2.2x%2.2x", rc, gc, bc);
4865 int x, y, width, height;
4887 gl2psPrintf(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
4888 gl2psPrintf(
"<svg xmlns=\"http://www.w3.org/2000/svg\"\n");
4889 gl2psPrintf(
" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
4890 " width=\"%dpx\" height=\"%dpx\" viewBox=\"%d %d %d %d\">\n",
4891 width, height, x, y, width, height);
4905 gl2psPrintf(
"<polygon fill=\"%s\" points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n", col,
4913 gl2psPrintf(
"<g shape-rendering=\"crispEdges\">\n");
4930 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"fill-opacity=\"%g\" ", rgba[0][3]);
4931 gl2psPrintf(
"points=\"%g,%g %g,%g %g,%g\"/>\n", xyz[0][0], xyz[0][1],
4932 xyz[1][0], xyz[1][1], xyz[2][0], xyz[2][1]);
4936 for(i = 0; i < 3; i++){
4937 xyz2[0][i] = xyz[0][i];
4938 xyz2[1][i] = 0.5F * (xyz[0][i] + xyz[1][i]);
4939 xyz2[2][i] = 0.5F * (xyz[0][i] + xyz[2][i]);
4941 for(i = 0; i < 4; i++){
4942 rgba2[0][i] = rgba[0][i];
4943 rgba2[1][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
4944 rgba2[2][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
4947 for(i = 0; i < 3; i++){
4948 xyz2[0][i] = 0.5F * (xyz[0][i] + xyz[1][i]);
4949 xyz2[1][i] = xyz[1][i];
4950 xyz2[2][i] = 0.5F * (xyz[1][i] + xyz[2][i]);
4952 for(i = 0; i < 4; i++){
4953 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
4954 rgba2[1][i] = rgba[1][i];
4955 rgba2[2][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
4958 for(i = 0; i < 3; i++){
4959 xyz2[0][i] = 0.5F * (xyz[0][i] + xyz[2][i]);
4960 xyz2[1][i] = xyz[2][i];
4961 xyz2[2][i] = 0.5F * (xyz[1][i] + xyz[2][i]);
4963 for(i = 0; i < 4; i++){
4964 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
4965 rgba2[1][i] = rgba[2][i];
4966 rgba2[2][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
4969 for(i = 0; i < 3; i++){
4970 xyz2[0][i] = 0.5F * (xyz[0][i] + xyz[1][i]);
4971 xyz2[1][i] = 0.5F * (xyz[1][i] + xyz[2][i]);
4972 xyz2[2][i] = 0.5F * (xyz[0][i] + xyz[2][i]);
4974 for(i = 0; i < 4; i++){
4975 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
4976 rgba2[1][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
4977 rgba2[2][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
4985 int i, n, array[10];
4987 if(!pattern || !factor)
return;
4991 for(i = 0; i < n; i++){
5004 for(i = 0; i < 3; i++)
5006 for(i = 0; i < 4; i++)
5013 #if defined(GL2PS_HAVE_LIBPNG)
5025 sizeof(
unsigned char));
5026 gl2psConvertPixmapToPNG(pixmap, png);
5027 gl2psListEncodeBase64(png);
5028 gl2psPrintf(
"<image x=\"%g\" y=\"%g\" width=\"%d\" height=\"%d\"\n",
5030 gl2psPrintf(
"xlink:href=\"data:image/png;base64,");
5032 gl2psListRead(png, i, &c);
5039 "order to embed images in SVG streams");
5066 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"fill-opacity=\"%g\" ", rgba[0][3]);
5068 xyz[0][0], xyz[0][1], 0.5 * prim->
width);
5093 gl2psPrintf(
"<polyline fill=\"none\" stroke=\"%s\" stroke-width=\"%g\" ",
5095 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"stroke-opacity=\"%g\" ", rgba[0][3]);
5097 gl2psPrintf(
"points=\"%g,%g ", xyz[0][0], xyz[0][1]);
5114 gl2psPrintf(
"<text fill=\"%s\" x=\"%g\" y=\"%g\" font-size=\"%d\" ",
5121 gl2psPrintf(
"text-anchor=\"middle\" baseline-shift=\"%d\" ",
5125 gl2psPrintf(
"text-anchor=\"start\" baseline-shift=\"%d\" ",
5129 gl2psPrintf(
"text-anchor=\"end\" baseline-shift=\"%d\" ",
5133 gl2psPrintf(
"text-anchor=\"middle\" baseline-shift=\"0\" ");
5136 gl2psPrintf(
"text-anchor=\"end\" baseline-shift=\"0\" ");
5139 gl2psPrintf(
"text-anchor=\"middle\" baseline-shift=\"%d\" ",
5143 gl2psPrintf(
"text-anchor=\"start\" baseline-shift=\"%d\" ",
5147 gl2psPrintf(
"text-anchor=\"end\" baseline-shift=\"%d\" ",
5152 gl2psPrintf(
"text-anchor=\"start\" baseline-shift=\"0\" ");
5158 gl2psPrintf(
"font-family=\"Times\" font-weight=\"bold\">");
5160 gl2psPrintf(
"font-family=\"Times\" font-style=\"italic\">");
5162 gl2psPrintf(
"font-family=\"Times\" font-style=\"italic\" font-weight=\"bold\">");
5164 gl2psPrintf(
"font-family=\"Helvetica\" font-weight=\"bold\">");
5166 gl2psPrintf(
"font-family=\"Helvetica\" font-style=\"oblique\">");
5168 gl2psPrintf(
"font-family=\"Helvetica\" font-style=\"oblique\" font-weight=\"bold\">");
5170 gl2psPrintf(
"font-family=\"Courier\" font-weight=\"bold\">");
5172 gl2psPrintf(
"font-family=\"Courier\" font-style=\"oblique\">");
5174 gl2psPrintf(
"font-family=\"Courier\" font-style=\"oblique\" font-weight=\"bold\">");
5203 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
5205 glRenderMode(GL_FEEDBACK);
5209 gl2ps->
header = GL_FALSE;
5214 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
5217 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &index);
5218 rgba[0] = gl2ps->
colormap[index][0];
5219 rgba[1] = gl2ps->
colormap[index][1];
5220 rgba[2] = gl2ps->
colormap[index][2];
5224 gl2psPrintf(
"<polygon fill=\"%s\" points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n", col,
5227 x + w, gl2ps->
viewport[3] - (y + h),
5231 gl2psPrintf(
"<clipPath id=\"cp%d%d%d%d\">\n", x, y, w, h);
5232 gl2psPrintf(
" <polygon points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n",
5235 x + w, gl2ps->
viewport[3] - (y + h),
5238 gl2psPrintf(
"<g clip-path=\"url(#cp%d%d%d%d)\">\n", x, y, w, h);
5266 "Scalable Vector Graphics"
5279 fprintf(gl2ps->
stream,
"\\color[rgb]{%f,%f,%f}\n", rgba[0], rgba[1], rgba[2]);
5291 "%% Creator: GL2PS %d.%d.%d%s, %s\n"
5293 "%% CreationDate: %s",
5298 fprintf(gl2ps->
stream,
"\\begin{pgfpicture}\n");
5302 "\\pgfpathrectanglecorners{"
5303 "\\pgfpoint{%dpt}{%dpt}}{\\pgfpoint{%dpt}{%dpt}}\n"
5304 "\\pgfusepath{fill}\n",
5312 int i, n, array[10];
5320 if(!pattern || !factor){
5322 fprintf(gl2ps->
stream,
"\\pgfsetdash{}{0pt}\n");
5326 fprintf(gl2ps->
stream,
"\\pgfsetdash{");
5327 for(i = 0; i < n; i++) fprintf(gl2ps->
stream,
"{%dpt}", array[i]);
5328 fprintf(gl2ps->
stream,
"}{0pt}\n");
5344 default :
return "south west";
5359 "\\pgfpathrectangle{\\pgfpoint{%fpt}{%fpt}}"
5360 "{\\pgfpoint{%fpt}{%fpt}}\n\\pgfusepath{fill}\n",
5373 "\\pgfpathmoveto{\\pgfpoint{%fpt}{%fpt}}\n"
5374 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n"
5375 "\\pgfusepath{stroke}\n",
5382 fprintf(gl2ps->
stream,
"\\pgfsetlinewidth{0.01pt}\n");
5386 "\\pgfpathmoveto{\\pgfpoint{%fpt}{%fpt}}\n"
5387 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n"
5388 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n"
5390 "\\pgfusepath{fill,stroke}\n",
5396 fprintf(gl2ps->
stream,
"{\n\\pgftransformshift{\\pgfpoint{%fpt}{%fpt}}\n",
5402 fprintf(gl2ps->
stream,
"\\pgfnode{rectangle}{%s}{\\fontsize{%d}{0}\\selectfont",
5406 fprintf(gl2ps->
stream,
"\\textcolor[rgb]{%g,%g,%g}{{%s}}",
5410 fprintf(gl2ps->
stream,
"}{}{\\pgfusepath{discard}}}\n");
5425 fprintf(gl2ps->
stream,
"\\end{pgfpicture}\n");
5432 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
5434 glRenderMode(GL_FEEDBACK);
5438 gl2ps->
header = GL_FALSE;
5441 fprintf(gl2ps->
stream,
"\\begin{pgfscope}\n");
5444 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
5447 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &index);
5448 rgba[0] = gl2ps->
colormap[index][0];
5449 rgba[1] = gl2ps->
colormap[index][1];
5450 rgba[2] = gl2ps->
colormap[index][2];
5455 "\\pgfpathrectangle{\\pgfpoint{%dpt}{%dpt}}"
5456 "{\\pgfpoint{%dpt}{%dpt}}\n"
5457 "\\pgfusepath{fill}\n",
5462 "\\pgfpathrectangle{\\pgfpoint{%dpt}{%dpt}}"
5463 "{\\pgfpoint{%dpt}{%dpt}}\n"
5464 "\\pgfusepath{clip}\n",
5472 fprintf(gl2ps->
stream,
"\\end{pgfscope}\n");
5490 "PGF Latex Graphics"
5518 for(i = 0; i < prim->
numverts; i++){
5536 used = glRenderMode(GL_RENDER);
5556 gl2ps->
header = GL_FALSE;
5564 switch(gl2ps->
sort){
5611 GLint viewport[4], GLint format, GLint sort,
5612 GLint options, GLint colormode,
5614 GLint nr, GLint ng, GLint nb, GLint buffersize,
5615 FILE *stream,
const char *filename)
5627 if(format >= 0 && format < (GLint)(
sizeof(
gl2psbackends) /
sizeof(gl2psbackends[0]))){
5668 glGetIntegerv(GL_VIEWPORT, gl2ps->
viewport);
5671 for(i = 0; i < 4; i++){
5685 gl2ps->
threshold[0] = nr ? 1.0F / (GLfloat)nr : 0.064F;
5686 gl2ps->
threshold[1] = ng ? 1.0F / (GLfloat)ng : 0.034F;
5687 gl2ps->
threshold[2] = nb ? 1.0F / (GLfloat)nb : 0.100F;
5689 gl2ps->
buffersize = buffersize > 0 ? buffersize : 2048 * 2048;
5690 for(i = 0; i < 3; i++){
5693 for(i = 0; i < 4; i++){
5710 glGetIntegerv(GL_BLEND_SRC, &gl2ps->
blendfunc[0]);
5711 glGetIntegerv(GL_BLEND_DST, &gl2ps->
blendfunc[1]);
5716 glGetFloatv(GL_COLOR_CLEAR_VALUE, gl2ps->
bgcolor);
5718 else if(gl2ps->
colormode == GL_COLOR_INDEX){
5719 if(!colorsize || !colormap){
5728 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &index);
5743 gl2ps->
title[0] =
'\0';
5747 strcpy(gl2ps->
title, title);
5772 glRenderMode(GL_FEEDBACK);
5828 GLshort fontsize, GLint alignment, GLfloat angle)
5844 GLint xorig, GLint yorig,
5845 GLenum format, GLenum type,
5850 GLfloat pos[4], zoom_x, zoom_y;
5856 if((width <= 0) || (height <= 0))
return GL2PS_ERROR;
5860 if((format != GL_RGB && format != GL_RGBA) || type != GL_FLOAT){
5862 "GL_RGB/GL_RGBA, GL_FLOAT pixels");
5866 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
5869 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
5870 glGetFloatv(GL_ZOOM_X, &zoom_x);
5871 glGetFloatv(GL_ZOOM_Y, &zoom_y);
5878 prim->
verts[0].
xyz[0] = pos[0] + xorig;
5879 prim->
verts[0].
xyz[1] = pos[1] + yorig;
5886 glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->
verts[0].
rgba);
5900 size = height * width * 3;
5902 piv = (
const GLfloat*)pixels;
5903 for(i = 0; i < size; ++i, ++piv){
5910 size = height * width * 4;
5917 size = height * width * 3;
5930 const GLfloat position[3],
5931 const unsigned char *imagemap){
5933 int sizeoffloat =
sizeof(GLfloat);
5937 if((width <= 0) || (height <= 0))
return GL2PS_ERROR;
5939 size = height + height * ((width - 1) / 8);
5942 glVertex3f(position[0], position[1],position[2]);
5944 glPassThrough((GLfloat)width);
5945 glPassThrough((GLfloat)height);
5946 for(i = 0; i < size; i += sizeoffloat){
5947 const float *value = (
const float*)imagemap;
5948 glPassThrough(*value);
5949 imagemap += sizeoffloat;
5963 glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &gl2ps->
offset[0]);
5964 glGetFloatv(GL_POLYGON_OFFSET_UNITS, &gl2ps->
offset[1]);
5971 glGetIntegerv(GL_LINE_STIPPLE_PATTERN, &tmp);
5972 glPassThrough((GLfloat)tmp);
5973 glGetIntegerv(GL_LINE_STIPPLE_REPEAT, &tmp);
5974 glPassThrough((GLfloat)tmp);
6017 glPassThrough(value);
6027 glPassThrough(value);
6040 glPassThrough((GLfloat)sfactor);
6042 glPassThrough((GLfloat)dfactor);
6070 if(format >= 0 && format < (GLint)(
sizeof(gl2psbackends) /
sizeof(gl2psbackends[0])))
6073 return "Unknown format";
6078 if(format >= 0 && format < (GLint)(
sizeof(gl2psbackends) /
sizeof(gl2psbackends[0])))
6081 return "Unknown format";
static void gl2psBuildPolygonBoundary(GL2PSbsptree *tree)
static int gl2psOpenPDFDataStreamWritePreface(void)
static void gl2psFreeImagemap(GL2PSimagemap *list)
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, GLint viewport[4], GLint format, GLint sort, GLint options, GLint colormode, GLint colorsize, GL2PSrgba *colormap, GLint nr, GLint ng, GLint nb, GLint buffersize, FILE *stream, const char *filename)
static int gl2psOpenPDFDataStream(void)
union GL2PSprimitive::@0 data
static void gl2psSortOutTrianglePDFgroup(GL2PSpdfgroup *gro)
static void gl2psPrintPGFFinalPrimitive(void)
static GLint gl2psGetVertex(GL2PSvertex *v, GLfloat *p)
static int gl2psPrintPDFLineWidth(GLfloat lw)
static void gl2psBuildBspTree(GL2PSbsptree *tree, GL2PSlist *primitives)
static void gl2psPrintSVGSmoothTriangle(GL2PSxyz xyz[3], GL2PSrgba rgba[3])
static void gl2psPrintSVGPrimitive(void *data)
static int gl2psPrintPDFGSObject(void)
static void gl2psPrintPDFHeader(void)
static int gl2psPrintPDFShaderStreamDataAlpha(GL2PSvertex *vertex, int(*action)(unsigned long data, int size), int sigbyte)
GL2PSDLL_API GLint gl2psSetOptions(GLint options)
static GLint gl2psPrintTeXEndViewport(void)
static void gl2psPrintSVGFinalPrimitive(void)
static void gl2psGetPlane(GL2PSprimitive *prim, GL2PSplane plane)
static void gl2psListAdd(GL2PSlist *list, void *data)
static void gl2psFreeBspImageTree(GL2PSbsptree2d **tree)
static void * gl2psRealloc(void *ptr, size_t size)
static int gl2psPDFgroupListWriteVariableResources(void)
static void gl2psCreateSplitPrimitive(GL2PSprimitive *parent, GL2PSplane plane, GL2PSprimitive *child, GLshort numverts, GLshort *index0, GLshort *index1)
static GLboolean gl2psGreater(GLfloat f1, GLfloat f2)
static void gl2psPrintPGFColor(GL2PSrgba rgba)
static void gl2psPrintTeXPrimitive(void *data)
static void gl2psPDFRectHull(GLfloat *xmin, GLfloat *xmax, GLfloat *ymin, GLfloat *ymax, GL2PStriangle *triangles, int cnt)
static GLint gl2psAddText(GLint type, const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle)
#define GL2PS_POINT_SIZE_TOKEN
static void gl2psAdaptVertexForBlending(GL2PSvertex *v)
static void gl2psPrintPostScriptPixmap(GLfloat x, GLfloat y, GL2PSimage *im)
static GL2PSimage * gl2psCopyPixmap(GL2PSimage *im)
GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4])
static void gl2psFreeText(GL2PSstring *text)
static GL2PSprimitive * gl2psCreateSplitPrimitive2D(GL2PSprimitive *parent, GLshort numverts, GL2PSvertex *vertx)
static void gl2psPrintPDFPrimitive(void *data)
static GL2PSbackend gl2psPDF
GL2PSimagemap * imagemap_tail
static void gl2psPrintSVGHeader(void)
static void gl2psListDelete(GL2PSlist *list)
static void gl2psEndPostScriptLine(void)
static GLfloat gl2psComparePointPlane(GL2PSxyz point, GL2PSplane plane)
static void gl2psSVGGetColorString(GL2PSrgba rgba, char str[32])
#define GL2PS_DRAW_BACKGROUND
static int gl2psPrintPostScriptDash(GLushort pattern, GLint factor, const char *str)
static int gl2psPrintPDFFillColor(GL2PSrgba rgba)
#define GL2PS_EXTRA_VERSION
static GLboolean gl2psVertsSameColor(const GL2PSprimitive *prim)
static const char * gl2psPGFTextAlignment(int align)
static void gl2psAssignTriangleProperties(GL2PStriangle *t)
static GL2PSstring * gl2psCopyText(GL2PSstring *t)
static GLint gl2psTestSplitPrimitive(GL2PSprimitive *prim, GL2PSplane plane)
#define GL2PS_BEGIN_BLEND_TOKEN
#define GL2PS_POINT_COINCIDENT
static int gl2psPDFgroupListWriteXObjectResources(void)
static int gl2psPrintPDFShaderMask(int obj, int childobj)
static void gl2psFreePrimitive(void *data)
static void gl2psPrintSVGDash(GLushort pattern, GLint factor)
static void gl2psAddPrimitiveInList(GL2PSprimitive *prim, GL2PSlist *list)
static void gl2psPrintTeXHeader(void)
static GLint gl2psAddInBspImageTree(GL2PSprimitive *prim, GL2PSbsptree2d **tree)
#define GL2PS_MAJOR_VERSION
static void gl2psPrintGzipHeader(void)
GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname, GLshort fontsize)
static void gl2psPDFgroupListInit(void)
static void gl2psFree(void *ptr)
#define GL2PS_OCCLUSION_CULL
void(* beginViewport)(GLint viewport[4])
static void gl2psPrintSVGPixmap(GLfloat x, GLfloat y, GL2PSimage *pixmap)
#define GL2PS_BEGIN_STIPPLE_TOKEN
static void gl2psCutEdge(GL2PSvertex *a, GL2PSvertex *b, GL2PSplane plane, GL2PSvertex *c)
static void gl2psFreePixmap(GL2PSimage *im)
static int gl2psTrianglesFirst(const void *a, const void *b)
static void gl2psSetLastColor(GL2PSrgba rgba)
static void gl2psPrintPDFFinalPrimitive(void)
static void gl2psSplitPrimitive2D(GL2PSprimitive *prim, GL2PSplane plane, GL2PSprimitive **front, GL2PSprimitive **back)
static GL2PSprimitive * gl2psCopyPrimitive(GL2PSprimitive *p)
#define GL2PS_LINE_STIPPLE
static GL2PSbackend gl2psPGF
static void gl2psPvec(GLfloat *a, GLfloat *b, GLfloat *c)
#define GL2PS_BEGIN_BOUNDARY_TOKEN
#define GL2PS_IMAGEMAP_TOKEN
static void gl2psListActionInverse(GL2PSlist *list, void(*action)(void *data))
#define GL2PS_END_BLEND_TOKEN
static GLint gl2psPrintPostScriptEndViewport(void)
static void gl2psPrintPDFFooter(void)
static int gl2psPrintPDFShaderStreamData(GL2PStriangle *triangle, GLfloat dx, GLfloat dy, GLfloat xmin, GLfloat ymin, int(*action)(unsigned long data, int size), int gray)
static void gl2psPrintPostScriptPrimitive(void *data)
static GLint gl2psPrintPGFEndViewport(void)
static int gl2psPrintPDFShaderStreamDataCoord(GL2PSvertex *vertex, int(*action)(unsigned long data, int size), GLfloat dx, GLfloat dy, GLfloat xmin, GLfloat ymin)
static void gl2psPrintPGFFooter(void)
static int gl2psPDFgroupListWriteObjects(int entryoffs)
static GL2PSbackend gl2psTEX
static GL2PSbackend gl2psEPS
static void gl2psPrintPostScriptColor(GL2PSrgba rgba)
GL2PSDLL_API GLint gl2psDrawImageMap(GLsizei width, GLsizei height, const GLfloat position[3], const unsigned char *imagemap)
const unsigned char flag[]
#define GL2PS_END_BOUNDARY_TOKEN
static int gl2psCompareDepth(const void *a, const void *b)
static GLboolean gl2psSamePosition(GL2PSxyz p1, GL2PSxyz p2)
static GL2PSbackend gl2psSVG
static void gl2psPrintPostScriptFooter(void)
#define GL2PS_POLYGON_BOUNDARY
void(* printFinalPrimitive)(void)
GL2PSDLL_API GLint gl2psGetOptions(GLint *options)
static void gl2psFillTriangleFromPrimitive(GL2PStriangle *t, GL2PSprimitive *p, GLboolean assignprops)
static void gl2psWriteByte(unsigned char byte)
void(* printHeader)(void)
#define GL2PS_UNINITIALIZED
static void gl2psSVGGetCoordsAndColors(int n, GL2PSvertex *verts, GL2PSxyz *xyz, GL2PSrgba *rgba)
GLboolean zerosurfacearea
static void gl2psRescaleAndOffset(void)
static void gl2psMsg(GLint level, const char *fmt,...)
GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str)
static void gl2psTraverseBspTree(GL2PSbsptree *tree, GL2PSxyz eye, GLfloat epsilon, GLboolean(*compare)(GLfloat f1, GLfloat f2), void(*action)(void *data), int inverse)
static int gl2psPrintf(const char *fmt,...)
static GLfloat gl2psPsca(GLfloat *a, GLfloat *b)
#define GL2PS_PATCH_VERSION
#define GL2PS_USE_CURRENT_VIEWPORT
static void gl2psAddPlanesInBspTreeImage(GL2PSprimitive *prim, GL2PSbsptree2d **tree)
GL2PSDLL_API GLint gl2psEndPage(void)
GL2PSDLL_API const char * gl2psGetFileExtension(GLint format)
static void gl2psPrintSVGFooter(void)
static void gl2psPrintTeXFooter(void)
static void gl2psPDFgroupListDelete(void)
#define GL2PS_TIGHT_BOUNDING_BOX
static GLfloat gl2psGetRGB(GL2PSimage *im, GLuint x, GLuint y, GLfloat *red, GLfloat *green, GLfloat *blue)
static void gl2psPrintTeXBeginViewport(GLint viewport[4])
static void gl2psAddBoundaryInList(GL2PSprimitive *prim, GL2PSlist *list)
GL2PSimagemap * imagemap_head
static void gl2psGetNormal(GLfloat *a, GLfloat *b, GLfloat *c)
GL2PSDLL_API GLint gl2psBlendFunc(GLenum sfactor, GLenum dfactor)
static int gl2psPrintPDFShaderStreamDataRGB(GL2PSvertex *vertex, int(*action)(unsigned long data, int size))
static void gl2psPDFgroupObjectInit(GL2PSpdfgroup *gro)
static void gl2psPrintPGFDash(GLushort pattern, GLint factor)
static void gl2psResetPostScriptColor(void)
const char * file_extension
static void gl2psPutPDFImage(GL2PSimage *image, int cnt, GLfloat x, GLfloat y)
#define GL2PS_DRAW_PIXELS_TOKEN
static int gl2psPrintPDFShader(int obj, GL2PStriangle *triangles, int size, int gray)
static int gl2psClosePDFDataStream(void)
static void gl2psListRealloc(GL2PSlist *list, GLint n)
#define GL2PS_END_STIPPLE_TOKEN
#define GL2PS_MINOR_VERSION
static GLshort gl2psGetIndex(GLshort i, GLshort num)
#define GL2PS_SIMPLE_SORT
GL2PSDLL_API GLint gl2psPointSize(GLfloat value)
static int gl2psPDFgroupListWriteFontResources(void)
static void gl2psPrintPostScriptBeginViewport(GLint viewport[4])
static GL2PSbackend * gl2psbackends[]
static void gl2psPutPDFText(GL2PSstring *text, int cnt, GLfloat x, GLfloat y)
static int gl2psPrintPDFInfo(void)
static void gl2psFreeBspTree(GL2PSbsptree **tree)
GL2PSprimitive * primitivetoadd
#define GL2PS_ZOFFSET_LARGE
GL2PSDLL_API const char * gl2psGetFormatDescription(GLint format)
#define GL2PS_IMAGEMAP_VISIBLE
static int gl2psPrintPDFCompressorType(void)
static void gl2psComputeTightBoundingBox(void *data)
static GLboolean gl2psLess(GLfloat f1, GLfloat f2)
static int gl2psPrintPDFPixmap(int obj, int childobj, GL2PSimage *im, int gray)
GL2PSDLL_API GLint gl2psDisable(GLint mode)
static void gl2psInitTriangle(GL2PStriangle *t)
static GLint gl2psCheckPrimitive(GL2PSprimitive *prim, GL2PSplane plane)
static void gl2psPrintSVGBeginViewport(GLint viewport[4])
static int gl2psPrintPDFPages(void)
static void gl2psPrintPostScriptHeader(void)
static int gl2psPDFgroupListWriteGStateResources(void)
static void gl2psAddIndex(GLshort *index0, GLshort *index1, GLshort *nb, GLshort i, GLshort j)
static int gl2psWriteBigEndian(unsigned long data, int bytes)
GLint(* endViewport)(void)
#define GL2PS_DST_BLEND_TOKEN
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
static void gl2psPDFstacksInit(void)
static GLint gl2psGetPlaneFromPoints(GL2PSxyz a, GL2PSxyz b, GL2PSplane plane)
static void gl2psPrintPostScriptFinalPrimitive(void)
static void gl2psPrintPGFHeader(void)
#define GL2PS_LINE_WIDTH_TOKEN
#define GL2PS_NO_FEEDBACK
static int gl2psPrintPDFShaderExtGS(int obj, int childobj)
static GLint gl2psCheckPoint(GL2PSxyz point, GL2PSplane plane)
static int gl2psPrintPDFText(int obj, GL2PSstring *s, int fontnumber)
static int gl2psPrintPDFOpenPage(void)
#define GL2PS_POLYGON_OFFSET_FILL
static int gl2psPrintPDFPixmapStreamData(GL2PSimage *im, int(*action)(unsigned long data, int size), int gray)
static void gl2psParseFeedbackBuffer(GLint used)
GL2PSbsptree2d * imagetree
static int gl2psPDFgroupListWriteShaderResources(void)
static void gl2psListSort(GL2PSlist *list, int(*fcmp)(const void *a, const void *b))
static GLint gl2psFindRoot(GL2PSlist *primitives, GL2PSprimitive **root)
static GLfloat gl2psNorm(GLfloat *a)
void(* printPrimitive)(void *data)
void(* printFooter)(void)
static void * gl2psMalloc(size_t size)
static GL2PScontext * gl2ps
#define GL2PS_IN_FRONT_OF
static void gl2psDivideQuad(GL2PSprimitive *quad, GL2PSprimitive **t1, GL2PSprimitive **t2)
static void gl2psParseStipplePattern(GLushort pattern, GLint factor, int *nb, int array[10])
#define GL2PS_END_OFFSET_TOKEN
static GLint gl2psPrintSVGEndViewport(void)
static int gl2psPrintPDFDataStreamLength(int val)
#define GL2PS_SRC_BLEND_TOKEN
static GL2PSbackend gl2psPS
static GLint gl2psPrintPrimitives(void)
static void gl2psPrintPostScriptImagemap(GLfloat x, GLfloat y, GLsizei width, GLsizei height, const unsigned char *imagemap)
static void gl2psPrintTeXFinalPrimitive(void)
static void gl2psPrintPGFPrimitive(void *data)
GL2PSDLL_API GLint gl2psEnable(GLint mode)
GL2PSDLL_API GLint gl2psTextOpt(const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle)
#define GL2PS_BEGIN_OFFSET_TOKEN
static void gl2psEndSVGLine(void)
static GLboolean gl2psSupportedBlendMode(GLenum sfactor, GLenum dfactor)
static void gl2psListReset(GL2PSlist *list)
static void gl2psPrintGzipFooter(void)
static int gl2psPrintPDFStrokeColor(GL2PSrgba rgba)
static void gl2psPDFgroupListWriteMainStream(void)
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value)
static int gl2psPrintPDFCatalog(void)
static int gl2psListNbr(GL2PSlist *list)
static void gl2psPrintPDFBeginViewport(GLint viewport[4])
#define GL2PS_NO_BLENDING
static void gl2psAddPolyPrimitive(GLshort type, GLshort numverts, GL2PSvertex *verts, GLint offset, GLushort pattern, GLint factor, GLfloat width, char boundary)
#define GL2PS_POINT_INFRONT
static int gl2psPrintPDFShaderSimpleExtGS(int obj, GLfloat alpha)
static GLint gl2psSplitPrimitive(GL2PSprimitive *prim, GL2PSplane plane, GL2PSprimitive **front, GL2PSprimitive **back)
#define GL2PS_NO_PS3_SHADING
static GLint gl2psPrintPDFEndViewport(void)
GL2PSlist * auxprimitives
static GLboolean gl2psSameColorThreshold(int n, GL2PSrgba rgba[], GL2PSrgba threshold)
static void gl2psListAction(GL2PSlist *list, void(*action)(void *data))
#define GL2PS_IMAGEMAP_WRITTEN
static GL2PSlist * gl2psListCreate(GLint n, GLint incr, GLint size)
static void gl2psAddInImageTree(void *data)
static void gl2psPrintPGFBeginViewport(GLint viewport[4])
GL2PSDLL_API GLint gl2psEndViewport(void)
static GLboolean gl2psSameColor(GL2PSrgba rgba1, GL2PSrgba rgba2)
static void * gl2psListPointer(GL2PSlist *list, GLint index)
#define GL2PS_SIMPLE_LINE_OFFSET