40 #include <sys/types.h> 45 #if defined(GL2PS_HAVE_ZLIB) 49 #if defined(GL2PS_HAVE_LIBPNG) 62 #define GL2PS_EPSILON 5.0e-3F 63 #define GL2PS_ZSCALE 1000.0F 64 #define GL2PS_ZOFFSET 5.0e-2F 65 #define GL2PS_ZOFFSET_LARGE 20.0F 66 #define GL2PS_ZERO(arg) (fabs(arg) < 1.e-20) 70 #define GL2PS_NO_TYPE -1 74 #define GL2PS_QUADRANGLE 4 75 #define GL2PS_TRIANGLE 5 76 #define GL2PS_PIXMAP 6 77 #define GL2PS_IMAGEMAP 7 78 #define GL2PS_IMAGEMAP_WRITTEN 8 79 #define GL2PS_IMAGEMAP_VISIBLE 9 80 #define GL2PS_SPECIAL 10 84 #define GL2PS_COINCIDENT 1 85 #define GL2PS_IN_FRONT_OF 2 86 #define GL2PS_IN_BACK_OF 3 87 #define GL2PS_SPANNING 4 91 #define GL2PS_POINT_COINCIDENT 0 92 #define GL2PS_POINT_INFRONT 1 93 #define GL2PS_POINT_BACK 2 97 #define GL2PS_BEGIN_OFFSET_TOKEN 1 98 #define GL2PS_END_OFFSET_TOKEN 2 99 #define GL2PS_BEGIN_BOUNDARY_TOKEN 3 100 #define GL2PS_END_BOUNDARY_TOKEN 4 101 #define GL2PS_BEGIN_STIPPLE_TOKEN 5 102 #define GL2PS_END_STIPPLE_TOKEN 6 103 #define GL2PS_POINT_SIZE_TOKEN 7 104 #define GL2PS_LINE_WIDTH_TOKEN 8 105 #define GL2PS_BEGIN_BLEND_TOKEN 9 106 #define GL2PS_END_BLEND_TOKEN 10 107 #define GL2PS_SRC_BLEND_TOKEN 11 108 #define GL2PS_DST_BLEND_TOKEN 12 109 #define GL2PS_IMAGEMAP_TOKEN 13 110 #define GL2PS_DRAW_PIXELS_TOKEN 14 111 #define GL2PS_TEXT_TOKEN 15 195 #if defined(GL2PS_HAVE_ZLIB) 196 Bytef *dest, *src, *start;
197 uLongf destLen, srcLen;
211 GLint format,
sort, options, colorsize, colormode, buffersize;
215 GLint viewport[4], blendfunc[2], lastfactor;
250 void (*printHeader)(void);
251 void (*printFooter)(void);
252 void (*beginViewport)(GLint viewport[4]);
253 GLint (*endViewport)(void);
254 void (*printPrimitive)(
void *data);
255 void (*printFinalPrimitive)(void);
275 static void gl2psMsg(GLint level,
const char *fmt, ...)
281 case GL2PS_INFO : fprintf(stderr,
"GL2PS info: ");
break;
282 case GL2PS_WARNING : fprintf(stderr,
"GL2PS warning: ");
break;
283 case GL2PS_ERROR : fprintf(stderr,
"GL2PS error: ");
break;
286 vfprintf(stderr, fmt, args);
288 fprintf(stderr,
"\n");
297 if(!size)
return NULL;
309 if(!size)
return NULL;
310 ptr = realloc(orig, size);
328 int size =
sizeof(
unsigned long);
329 for(i = 1; i <= bytes; ++i){
330 fputc(0xff & (data >> (size - i) * 8), gl2ps->
stream);
337 #if defined(GL2PS_HAVE_ZLIB) 339 static void gl2psSetupCompress(
void)
349 static void gl2psFreeCompress(
void)
362 static int gl2psAllocCompress(
unsigned int srcsize)
378 static void *gl2psReallocCompress(
unsigned int srcsize)
383 if(srcsize < gl2ps->compress->srcLen)
397 static int gl2psWriteBigEndianCompress(
unsigned long data,
int bytes)
400 int size =
sizeof(
unsigned long);
401 for(i = 1; i <= bytes; ++i){
402 *gl2ps->
compress->src = (Bytef)(0xff & (data >> (size-i) * 8));
408 static int gl2psDeflate(
void)
423 #if defined(GL2PS_HAVE_ZLIB) 424 static char buf[1024];
426 GLboolean freebuf = GL_FALSE;
427 unsigned int oldsize = 0;
428 #if !defined(GL2PS_HAVE_NO_VSNPRINTF) 431 int bufsize =
sizeof(buf);
435 #if defined(GL2PS_HAVE_NO_VSNPRINTF) 436 ret = vsprintf(buf, fmt, args);
438 ret = vsnprintf(bufptr, bufsize, fmt, args);
441 #if !defined(GL2PS_HAVE_NO_VSNPRINTF) 442 while(ret >= (bufsize - 1) || ret < 0){
445 if(freebuf == GL_TRUE)
gl2psFree(bufptr);
449 ret = vsnprintf(bufptr, bufsize, fmt, args);
454 gl2ps->
compress->start = (Bytef*)gl2psReallocCompress(oldsize + ret);
455 memcpy(gl2ps->
compress->start + oldsize, bufptr, ret);
456 if(freebuf == GL_TRUE)
gl2psFree(bufptr);
462 ret = vfprintf(gl2ps->
stream, fmt, args);
464 #if defined(GL2PS_HAVE_ZLIB) 472 #if defined(GL2PS_HAVE_ZLIB) 473 char tmp[10] = {
'\x1f',
'\x8b',
481 gl2psSetupCompress();
483 fwrite(tmp, 10, 1, gl2ps->
stream);
490 #if defined(GL2PS_HAVE_ZLIB) 496 if(Z_OK != gl2psDeflate()){
502 if(gl2ps->
compress->dest[1] & (1<<5)){
510 for(n = 0; n < 4; ++n){
511 tmp[n] = (char)(crc & 0xff);
515 for(n = 4; n < 8; ++n){
516 tmp[n] = (char)(len & 0xff);
519 fwrite(tmp, 8, 1, gl2ps->
stream);
555 if(incr <= 0) incr = 1;
587 memcpy(&list->
array[(list->
n - 1) * list->
size], data, list->
size);
603 if((idx < 0) || (idx >= list->
n)){
611 int (*fcmp)(
const void *a,
const void *b))
615 qsort(list->
array, list->
n, list->
size, fcmp);
636 #if defined(GL2PS_HAVE_LIBPNG) 638 static void gl2psListRead(
GL2PSlist *list,
int index,
void *data)
640 if((index < 0) || (index >= list->
n))
645 static void gl2psEncodeBase64Block(
unsigned char in[3],
unsigned char out[4],
int len)
647 static const char cb64[] =
648 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
650 out[0] = cb64[ in[0] >> 2 ];
651 out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
652 out[2] = (len > 1) ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] :
'=';
653 out[3] = (len > 2) ? cb64[ in[2] & 0x3f ] :
'=';
656 static void gl2psListEncodeBase64(
GL2PSlist *list)
658 unsigned char *buffer, in[3], out[4];
659 int i, n, index, len;
661 n = list->
n * list->
size;
662 buffer = (
unsigned char*)
gl2psMalloc(n *
sizeof(
unsigned char));
663 memcpy(buffer, list->
array, n *
sizeof(
unsigned char));
669 for(i = 0; i < 3; i++) {
671 in[i] = buffer[index];
680 gl2psEncodeBase64Block(in, out, len);
681 for(i = 0; i < 4; i++)
705 for(i = 1; i < prim->
numverts; i++){
718 if(n < 2)
return GL_TRUE;
720 for(i = 1; i < n; i++){
721 if(fabs(rgba[0][0] - rgba[i][0]) > threshold[0] ||
722 fabs(rgba[0][1] - rgba[i][1]) > threshold[1] ||
723 fabs(rgba[0][2] - rgba[i][2]) > threshold[2])
733 for(i = 0; i < 3; ++i){
739 GLfloat *red, GLfloat *green, GLfloat *blue)
742 GLsizei width = im->
width;
743 GLsizei height = im->
height;
744 GLfloat *pixels = im->
pixels;
750 pimag = pixels + 4 * (width * (height - 1 - y) + x);
754 pimag = pixels + 3 * (width * (height - 1 - y) + x);
757 *red = *pimag; pimag++;
758 *green = *pimag; pimag++;
759 *blue = *pimag; pimag++;
761 return (im->
format == GL_RGBA) ? *pimag : 1.0F;
780 size = image->
height * image->
width * 4 *
sizeof(GLfloat);
784 size = image->
height * image->
width * 3 *
sizeof(GLfloat);
802 #if defined(GL2PS_HAVE_LIBPNG) 804 #if !defined(png_jmpbuf) 805 # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) 808 static void gl2psUserWritePNG(png_structp png_ptr, png_bytep data, png_size_t length)
812 for(i = 0; i < length; i++)
816 static void gl2psUserFlushPNG(png_structp png_ptr)
825 unsigned char *row_data;
829 if(!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)))
832 if(!(info_ptr = png_create_info_struct(png_ptr))){
833 png_destroy_write_struct(&png_ptr, NULL);
837 if(setjmp(png_jmpbuf(png_ptr))) {
838 png_destroy_write_struct(&png_ptr, &info_ptr);
842 png_set_write_fn(png_ptr, (
void *)png, gl2psUserWritePNG, gl2psUserFlushPNG);
843 png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
844 png_set_IHDR(png_ptr, info_ptr, pixmap->
width, pixmap->
height, 8,
845 PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
846 PNG_FILTER_TYPE_BASE);
847 png_write_info(png_ptr, info_ptr);
849 row_data = (
unsigned char*)
gl2psMalloc(3 * pixmap->
width *
sizeof(
unsigned char));
850 for(row = 0; row < pixmap->
height; row++){
851 for(col = 0; col < pixmap->
width; col++){
853 row_data[3*col] = (
unsigned char)(255. * dr);
854 row_data[3*col+1] = (
unsigned char)(255. * dg);
855 row_data[3*col+2] = (
unsigned char)(255. * db);
857 png_write_row(png_ptr, (png_bytep)row_data);
861 png_write_end(png_ptr, info_ptr);
862 png_destroy_write_struct(&png_ptr, &info_ptr);
869 static GLint
gl2psAddText(GLint type,
const char *str,
const char *fontname,
870 GLshort fontsize, GLint alignment, GLfloat angle,
881 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
884 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
887 prim->
type = (GLshort)type;
902 memcpy(prim->
verts[0].
rgba, color, 4 *
sizeof(
float));
904 glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->
verts[0].
rgba);
924 strcpy(text->
str, t->
str);
950 if( (sfactor == GL_SRC_ALPHA && dfactor == GL_ONE_MINUS_SRC_ALPHA) ||
951 (sfactor == GL_ONE && dfactor == GL_ZERO) )
1014 GLboolean assignprops)
1019 if(GL_TRUE == assignprops)
1026 GL2PSvertex vertex = { {-1.0F, -1.0F, -1.0F}, {-1.0F, -1.0F, -1.0F, -1.0F} };
1027 for(i = 0; i < 3; i++)
1090 return (plane[0] * point[0] +
1091 plane[1] * point[1] +
1092 plane[2] * point[2] +
1098 return (a[0]*b[0] + a[1]*b[1] + a[2]*b[2]);
1103 c[0] = a[1]*b[2] - a[2]*b[1];
1104 c[1] = a[2]*b[0] - a[0]*b[2];
1105 c[2] = a[0]*b[1] - a[1]*b[0];
1110 return (GLfloat)sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
1134 GL2PSxyz v = {0.0F, 0.0F, 0.0F}, w = {0.0F, 0.0F, 0.0F};
1147 plane[0] = plane[1] = 0.0F;
1156 - plane[2] * prim->
verts[0].
xyz[2];
1164 plane[0] = plane[1] = 0.0F;
1176 - plane[2] * prim->
verts[0].
xyz[2];
1184 plane[0] = plane[1] = 0.0F;
1190 plane[0] = plane[1] = plane[3] = 0.0F;
1202 v[0] = b->
xyz[0] - a->
xyz[0];
1203 v[1] = b->
xyz[1] - a->
xyz[1];
1204 v[2] = b->
xyz[2] - a->
xyz[2];
1211 c->
xyz[0] = a->
xyz[0] + v[0] * sect;
1212 c->
xyz[1] = a->
xyz[1] + v[1] * sect;
1213 c->
xyz[2] = a->
xyz[2] + v[2] * sect;
1215 c->
rgba[0] = (1 - sect) * a->
rgba[0] + sect * b->
rgba[0];
1216 c->
rgba[1] = (1 - sect) * a->
rgba[1] + sect * b->
rgba[1];
1217 c->
rgba[2] = (1 - sect) * a->
rgba[2] + sect * b->
rgba[2];
1218 c->
rgba[3] = (1 - sect) * a->
rgba[3] + sect * b->
rgba[3];
1223 GLshort *index0, GLshort *index1)
1256 for(i = 0; i < numverts; i++){
1262 plane, &child->
verts[i]);
1268 GLshort i, GLshort j)
1272 for(k = 0; k < *nb; k++){
1273 if((index0[k] == i && index1[k] == j) ||
1274 (index1[k] == i && index0[k] == j))
return;
1283 return (i < num - 1) ? i + 1 : 0;
1292 for(i = 0; i < prim->
numverts; i++){
1300 for(i = 0; i < prim->
numverts; i++){
1320 GLshort i, j, in = 0, out = 0, in0[5], in1[5], out0[5], out1[5];
1326 for(i = 0; i < prim->
numverts; i++){
1337 for(i = 0; i < prim->
numverts; i++){
1383 (*t1)->numverts = (*t2)->numverts = 3;
1384 (*t1)->culled = (*t2)->culled = quad->
culled;
1385 (*t1)->offset = (*t2)->offset = quad->
offset;
1386 (*t1)->ofactor = (*t2)->ofactor = quad->
ofactor;
1387 (*t1)->ounits = (*t2)->ounits = quad->
ounits;
1388 (*t1)->pattern = (*t2)->pattern = quad->
pattern;
1389 (*t1)->factor = (*t2)->factor = quad->
factor;
1390 (*t1)->width = (*t2)->width = quad->
width;
1393 (*t1)->verts[0] = quad->
verts[0];
1394 (*t1)->verts[1] = quad->
verts[1];
1395 (*t1)->verts[2] = quad->
verts[2];
1396 (*t1)->boundary = ((quad->
boundary & 1) ? 1 : 0) | ((quad->
boundary & 2) ? 2 : 0);
1397 (*t2)->verts[0] = quad->
verts[0];
1398 (*t2)->verts[1] = quad->
verts[2];
1399 (*t2)->verts[2] = quad->
verts[3];
1400 (*t2)->boundary = ((quad->
boundary & 4) ? 2 : 0) | ((quad->
boundary & 8) ? 4 : 0);
1406 GLfloat dq = 0.0F, dw = 0.0F, diff;
1417 for(i = 0; i < w->numverts; i++){
1440 return (q->
type < w->
type ? 1 : -1);
1445 GLint i, j, count, best = 1000000, idx = 0;
1462 for(i = 0; i < maxp; i++){
1471 if(count > best)
break;
1477 if(!count)
return idx;
1491 while(list != NULL){
1535 if((*tree)->primitives){
1547 if(f1 > f2)
return GL_TRUE;
1548 else return GL_FALSE;
1553 if(f1 < f2)
return GL_TRUE;
1554 else return GL_FALSE;
1621 GLboolean (*compare)(GLfloat f1, GLfloat f2),
1622 void (*action)(
void *data),
int inverse)
1630 if(GL_TRUE == compare(result, epsilon)){
1640 else if(GL_TRUE == compare(-epsilon, result)){
1659 GLfloat minZ, maxZ, rangeZ, scaleZ;
1660 GLfloat factor, units, area, dZ, dZdX, dZdY, maxdZ;
1668 minZ = maxZ = prim->
verts[0].
xyz[2];
1669 for(i = 1; i < prim->
numverts; i++){
1675 for(j = 0; j < prim->
numverts; j++){
1680 rangeZ = (maxZ - minZ);
1686 if(scaleZ > 100000.F) scaleZ = 100000.F;
1691 for(j = 0; j < prim->
numverts; j++){
1724 maxdZ = (GLfloat)sqrt(dZdX * dZdX + dZdY * dZdY);
1729 dZ = factor * maxdZ + units;
1747 plane[0] = b[1] - a[1];
1748 plane[1] = a[0] - b[0];
1749 n = (GLfloat)sqrt(plane[0]*plane[0] + plane[1]*plane[1]);
1754 plane[3] = -plane[0]*a[0]-plane[1]*a[1];
1793 if((*tree == NULL) && (prim->
numverts > 2)){
1799 for(i = 0; i < prim->
numverts-1; i++){
1817 for(i = 2+offset; i < prim->
numverts; 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;
1851 for(i = 0; i < 4; i++){
1855 for(i = 1+offset; i < prim->
numverts-1; i++){
1856 if(cur->front == NULL){
1861 cur->front->plane)){
1867 if(cur->front == NULL){
1872 cur->front->plane)){
1873 cur->front->front = NULL;
1874 cur->front->back = NULL;
1895 for(i = 1; i < prim->
numverts; i++){
1934 for(i = 0; i < numverts; i++){
1935 child->
verts[i] = vertx[i];
1950 GLint cur = -1, prev = -1, i, v1 = 0, v2 = 0,
flag = 1, prev0 = -1;
1953 GL2PSvertex *front_list = NULL, *back_list = NULL;
1956 GLshort front_count = 0, back_count = 0;
1958 for(i = 0; i <= prim->
numverts; i++){
1972 if(((prev == -1) || (prev == cur) || (prev == 0) || (cur == 0)) &&
1973 (i < prim->numverts)){
1978 front_list[front_count-1] = prim->
verts[v1];
1984 back_list[back_count-1] = prim->
verts[v1];
1990 front_list[front_count-1] = prim->
verts[v1];
1994 back_list[back_count-1] = prim->
verts[v1];
1998 else if((prev != cur) && (cur != 0) && (prev != 0)){
2007 plane, &front_list[front_count-1]);
2011 back_list[back_count-1] = front_list[front_count-1];
2051 if((*tree)->front != NULL){
2062 if((*tree)->back != NULL){
2068 if((*tree)->front != NULL){
2104 c[0] = c[1] = c[2] = 0.0F;
2105 for(i = 0; i < prim->
numverts; i++){
2112 for(i = 0; i < prim->
numverts; i++){
2113 if(prim->
boundary & (GLint)pow(2., i)){
2128 v[0] = c[0] - prim->
verts[i].
xyz[0];
2129 v[1] = c[1] - prim->
verts[i].
xyz[1];
2190 GLfloat ofactor, GLfloat ounits,
2191 GLushort pattern, GLint factor,
2192 GLfloat width,
char boundary)
2202 prim->
offset = (char)offset;
2207 prim->
width = width;
2225 i = (GLint)(p[3] + 0.5);
2244 GLushort pattern = 0;
2246 GLint i, sizeoffloat, count, v, vtot, offset = 0, factor = 0, auxindex = 0;
2247 GLfloat lwidth = 1.0F, psize = 1.0F, ofactor, ounits;
2254 boundary = gl2ps->
boundary = GL_FALSE;
2258 if(GL_TRUE == boundary) gl2ps->
boundary = GL_TRUE;
2260 switch((GLint)*current){
2261 case GL_POINT_TOKEN :
2268 pattern, factor, psize, 0);
2270 case GL_LINE_TOKEN :
2271 case GL_LINE_RESET_TOKEN :
2281 pattern, factor, lwidth, 0);
2283 case GL_POLYGON_TOKEN :
2284 count = (GLint)current[1];
2288 while(count > 0 && used > 0){
2296 if(GL_TRUE == boundary){
2297 if(!count && vtot == 2) flag = 1|2|4;
2298 else if(!count) flag = 2|4;
2299 else if(vtot == 2) flag = 1|2;
2305 ounits, pattern, factor, 1, flag);
2306 vertices[1] = vertices[2];
2312 case GL_BITMAP_TOKEN :
2313 case GL_DRAW_PIXEL_TOKEN :
2314 case GL_COPY_PIXEL_TOKEN :
2321 case GL_PASS_THROUGH_TOKEN :
2322 switch((GLint)current[1]){
2327 ofactor = current[1];
2330 ounits = current[1];
2345 pattern = (GLushort)current[1];
2348 factor = (GLint)current[1];
2353 gl2ps->
blendfunc[0] = (GLint)current[1];
2358 gl2ps->
blendfunc[1] = (GLint)current[1];
2368 lwidth = current[1];
2399 current += 2; used -= 2;
2401 current += i; used -= i;
2404 current += 2; used -= 2;
2408 for(i = 1; i < 4; i++){
2409 for(v = 0; v < 3; v++){
2420 sizeoffloat =
sizeof(GLfloat);
2421 v = 2 * sizeoffloat;
2428 for(i = 0; i < vtot; i += sizeoffloat){
2429 current += 2; used -= 2;
2431 memcpy(&(((
char*)(node->
image->
pixels))[i + v]), &(current[2]), sizeoffloat);
2433 memcpy(&(((
char*)(node->
image->
pixels))[i + v]), &(current[2]), vtot - i);
2469 unsigned char h = byte / 16;
2470 unsigned char l = byte % 16;
2476 GLuint nbhex, nbyte, nrgb, nbits;
2477 GLuint row, col, ibyte, icase;
2478 GLfloat dr = 0., dg = 0., db = 0., fgrey;
2479 unsigned char red = 0, green = 0, blue = 0, b, grey;
2480 GLuint width = (GLuint)im->
width;
2481 GLuint height = (GLuint)im->
height;
2488 if((width <= 0) || (height <= 0))
return;
2497 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2498 gl2psPrintf(
"{ currentfile picstr readhexstring pop }\n");
2500 for(row = 0; row < height; row++){
2501 for(col = 0; col < width; col++){
2503 fgrey = (0.30F * dr + 0.59F * dg + 0.11F * db);
2504 grey = (
unsigned char)(255. * fgrey);
2509 nbhex = width * height * 2;
2514 nbits = nrgb * nbit;
2516 if((nbyte * 8) != nbits) nbyte++;
2519 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2520 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2523 for(row = 0; row < height; row++){
2527 for(ibyte = 0; ibyte < nbyte; ibyte++){
2536 red = (
unsigned char)(3. * dr);
2537 green = (
unsigned char)(3. * dg);
2538 blue = (
unsigned char)(3. * db);
2549 red = (
unsigned char)(3. * dr);
2550 green = (
unsigned char)(3. * dg);
2551 blue = (
unsigned char)(3. * db);
2557 else if(icase == 2) {
2567 red = (
unsigned char)(3. * dr);
2568 green = (
unsigned char)(3. * dg);
2569 blue = (
unsigned char)(3. * db);
2576 else if(icase == 3) {
2585 red = (
unsigned char)(3. * dr);
2586 green = (
unsigned char)(3. * dg);
2587 blue = (
unsigned char)(3. * db);
2601 nbits = nrgb * nbit;
2603 if((nbyte * 8) != nbits) nbyte++;
2606 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2607 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2610 for(row = 0; row < height; row++){
2613 for(ibyte = 0; ibyte < nbyte; ibyte++){
2622 red = (
unsigned char)(15. * dr);
2623 green = (
unsigned char)(15. * dg);
2627 else if(icase == 2) {
2628 blue = (
unsigned char)(15. * db);
2636 red = (
unsigned char)(15. * dr);
2640 else if(icase == 3) {
2641 green = (
unsigned char)(15. * dg);
2642 blue = (
unsigned char)(15. * db);
2654 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ]\n", width, height, height);
2655 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2658 for(row = 0; row < height; row++){
2659 for(col = 0; col < width; col++){
2661 red = (
unsigned char)(255. * dr);
2663 green = (
unsigned char)(255. * dg);
2665 blue = (
unsigned char)(255. * db);
2676 GLsizei width, GLsizei height,
2677 const unsigned char *imagemap){
2680 if((width <= 0) || (height <= 0))
return;
2682 size = height + height * (width - 1) / 8;
2686 gl2psPrintf(
"%d %d scale\n%d %d\ntrue\n", width, height,width, height);
2687 gl2psPrintf(
"[ %d 0 0 -%d 0 %d ] {<", width, height);
2688 for(i = 0; i < size; i++){
2714 "%%%%Creator: GL2PS %d.%d.%d%s, %s\n" 2716 "%%%%CreationDate: %s" 2717 "%%%%LanguageLevel: 3\n" 2718 "%%%%DocumentData: Clean7Bit\n" 2726 "%%%%DocumentMedia: Default %d %d 0 () ()\n",
2735 "%%%%EndComments\n",
2759 "/gl2psdict 64 dict def gl2psdict begin\n" 2760 "0 setlinecap 0 setlinejoin\n" 2761 "/tryPS3shading %s def %% set to false to force subdivision\n" 2762 "/rThreshold %g def %% red component subdivision threshold\n" 2763 "/gThreshold %g def %% green component subdivision threshold\n" 2764 "/bThreshold %g def %% blue component subdivision threshold\n",
2769 "/C { setrgbcolor } BD\n" 2770 "/G { 0.082 mul exch 0.6094 mul add exch 0.3086 mul add neg 1.0 add setgray } BD\n" 2771 "/W { setlinewidth } BD\n");
2773 gl2psPrintf(
"/FC { findfont exch /SH exch def SH scalefont setfont } BD\n" 2774 "/SW { dup stringwidth pop } BD\n" 2775 "/S { FC moveto show } BD\n" 2776 "/SBC{ FC moveto SW -2 div 0 rmoveto show } BD\n" 2777 "/SBR{ FC moveto SW neg 0 rmoveto show } BD\n" 2778 "/SCL{ FC moveto 0 SH -2 div rmoveto show } BD\n" 2779 "/SCC{ FC moveto SW -2 div SH -2 div rmoveto show } BD\n" 2780 "/SCR{ FC moveto SW neg SH -2 div rmoveto show } BD\n" 2781 "/STL{ FC moveto 0 SH neg rmoveto show } BD\n" 2782 "/STC{ FC moveto SW -2 div SH neg rmoveto show } BD\n" 2783 "/STR{ FC moveto SW neg SH neg rmoveto show } BD\n");
2788 "/SR { gsave FCT moveto rotate show grestore } BD\n" 2789 "/SBCR{ gsave FCT moveto rotate SW -2 div 0 rmoveto show grestore } BD\n" 2790 "/SBRR{ gsave FCT moveto rotate SW neg 0 rmoveto show grestore } BD\n" 2791 "/SCLR{ gsave FCT moveto rotate 0 SH -2 div rmoveto show grestore} BD\n");
2792 gl2psPrintf(
"/SCCR{ gsave FCT moveto rotate SW -2 div SH -2 div rmoveto show grestore} BD\n" 2793 "/SCRR{ gsave FCT moveto rotate SW neg SH -2 div rmoveto show grestore} BD\n" 2794 "/STLR{ gsave FCT moveto rotate 0 SH neg rmoveto show grestore } BD\n" 2795 "/STCR{ gsave FCT moveto rotate SW -2 div SH neg rmoveto show grestore } BD\n" 2796 "/STRR{ gsave FCT moveto rotate SW neg SH neg rmoveto show grestore } BD\n");
2798 gl2psPrintf(
"/P { newpath 0.0 360.0 arc closepath fill } BD\n" 2799 "/LS { newpath moveto } BD\n" 2800 "/L { lineto } BD\n" 2801 "/LE { lineto stroke } BD\n" 2802 "/T { newpath moveto lineto lineto closepath fill } BD\n");
2808 " /b1 exch def /g1 exch def /r1 exch def /y1 exch def /x1 exch def\n" 2809 " /b2 exch def /g2 exch def /r2 exch def /y2 exch def /x2 exch def\n" 2810 " /b3 exch def /g3 exch def /r3 exch def /y3 exch def /x3 exch def\n" 2811 " gsave << /ShadingType 4 /ColorSpace [/DeviceRGB]\n" 2812 " /DataSource [ 0 x1 y1 r1 g1 b1 0 x2 y2 r2 g2 b2 0 x3 y3 r3 g3 b3 ] >>\n" 2813 " shfill grestore } BD\n");
2819 "/Tm { 3 -1 roll 8 -1 roll 13 -1 roll add add 3 div\n" 2821 " 3 -1 roll 7 -1 roll 11 -1 roll add add 3 div\n" 2823 " 3 -1 roll 6 -1 roll 9 -1 roll add add 3 div" 2833 " 4 index 15 index add 0.5 mul\n" 2834 " 4 index 15 index add 0.5 mul\n" 2835 " 4 index 15 index add 0.5 mul\n" 2836 " 4 index 15 index add 0.5 mul\n" 2837 " 4 index 15 index add 0.5 mul\n" 2838 " 5 copy 5 copy 25 15 roll\n");
2843 " 9 index 30 index add 0.5 mul\n" 2844 " 9 index 30 index add 0.5 mul\n" 2845 " 9 index 30 index add 0.5 mul\n" 2846 " 9 index 30 index add 0.5 mul\n" 2847 " 5 copy 5 copy 35 5 roll 25 5 roll 15 5 roll\n");
2852 " 4 index 10 index add 0.5 mul\n" 2853 " 4 index 10 index add 0.5 mul\n" 2854 " 4 index 10 index add 0.5 mul\n" 2855 " 4 index 10 index add 0.5 mul\n" 2856 " 5 copy 5 copy 40 5 roll 25 5 roll 15 5 roll 25 5 roll\n");
2860 gl2psPrintf(
" STnoshfill STnoshfill STnoshfill STnoshfill } BD\n");
2867 " 2 index 8 index sub abs rThreshold gt\n" 2869 " { 1 index 7 index sub abs gThreshold gt\n" 2871 " { dup 6 index sub abs bThreshold gt\n" 2873 " { 2 index 13 index sub abs rThreshold gt\n" 2875 " { 1 index 12 index sub abs gThreshold gt\n" 2877 " { dup 11 index sub abs bThreshold gt\n" 2879 " { 7 index 13 index sub abs rThreshold gt\n");
2881 " { 6 index 12 index sub abs gThreshold gt\n" 2883 " { 5 index 11 index sub abs bThreshold gt\n" 2898 " { /ST { STshfill } BD }\n" 2899 " { /ST { STnoshfill } BD }\n" 2901 "{ /ST { STnoshfill } BD }\n" 2907 "/DeviceRGB setcolorspace\n" 2911 "%%%%BeginPageSetup\n");
2925 "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n" 2938 gl2psPrintf(
"%g %g %g C\n", rgba[0], rgba[1], rgba[2]);
2952 for(i = 0; i < 3; i++)
2954 for(i = 0; i < 4; i++)
2960 int *nb,
int array[10])
2963 int on[8] = {0, 0, 0, 0, 0, 0, 0, 0};
2964 int off[8] = {0, 0, 0, 0, 0, 0, 0, 0};
2968 for(n = 15; n >= 0; n--){
2969 tmp[n] = (char)(pattern & 0x01);
2974 for(i = 0; i < 8; i++){
2975 while(n < 16 && !tmp[n]){ off[i]++; n++; }
2976 while(n < 16 && tmp[n]){ on[i]++; n++; }
2977 if(n >= 15){ i++;
break; }
2986 for(n = i - 1; n >= 0; n--){
2987 array[(*nb)++] = factor * on[n];
2988 array[(*nb)++] = factor * off[n];
2989 if(*nb == 10)
break;
2995 int len = 0, i, n, array[10];
3003 if(!pattern || !factor){
3010 for(i = 0; i < n; i++){
3067 newline ?
"LS" :
"L");
3073 gl2psPrintf(
"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g ST\n",
3176 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
3178 glRenderMode(GL_FEEDBACK);
3182 gl2ps->
header = GL_FALSE;
3190 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
3193 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &idx);
3200 "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n" 3202 rgba[0], rgba[1], rgba[2],
3203 x, y, x+w, y, x+w, y+h, x, y+h);
3206 gl2psPrintf(
"newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n" 3208 x, y, x+w, y, x+w, y+h, x, y+h);
3248 "Encapsulated Postscript" 3264 for(i = (
int)strlen(gl2ps->
filename) - 1; i >= 0; i--){
3271 if(i <= 0) strcpy(name, gl2ps->
filename);
3274 strcpy(name,
"untitled");
3281 "%% Creator: GL2PS %d.%d.%d%s, %s\n" 3283 "%% CreationDate: %s",
3289 "\\setlength{\\unitlength}{1pt}\n" 3290 "\\begin{picture}(0,0)\n" 3291 "\\includegraphics{%s}\n" 3292 "\\end{picture}%%\n" 3293 "%s\\begin{picture}(%d,%d)(0,0)\n",
3306 fprintf(gl2ps->
stream,
"\\fontsize{%d}{0}\n\\selectfont",
3308 fprintf(gl2ps->
stream,
"\\put(%g,%g)",
3312 fprintf(gl2ps->
stream,
"{\\makebox(0,0)");
3315 fprintf(gl2ps->
stream,
"{");
3318 fprintf(gl2ps->
stream,
"[l]{");
3321 fprintf(gl2ps->
stream,
"[r]{");
3324 fprintf(gl2ps->
stream,
"[b]{");
3327 fprintf(gl2ps->
stream,
"[br]{");
3330 fprintf(gl2ps->
stream,
"[t]{");
3333 fprintf(gl2ps->
stream,
"[tl]{");
3336 fprintf(gl2ps->
stream,
"[tr]{");
3340 fprintf(gl2ps->
stream,
"[bl]{");
3343 fprintf(gl2ps->
stream,
"\\textcolor[rgb]{%g,%g,%g}{{%s}}",
3347 fprintf(gl2ps->
stream,
"}");
3348 fprintf(gl2ps->
stream,
"}}\n");
3363 fprintf(gl2ps->
stream,
"\\end{picture}%s\n",
3370 glRenderMode(GL_FEEDBACK);
3374 gl2ps->
header = GL_FALSE;
3408 #if defined(GL2PS_HAVE_ZLIB) 3410 return fprintf(gl2ps->
stream,
"/Filter [/FlateDecode]\n");
3421 for(i = 0; i < 3; ++i){
3424 else if(rgba[i] < 1e-4 || rgba[i] > 1e6)
3437 for(i = 0; i < 3; ++i){
3440 else if(rgba[i] < 1e-4 || rgba[i] > 1e6)
3453 else if(lw < 1e-4 || lw > 1e6)
3461 GLfloat rad, crad, srad;
3463 if(text->
angle == 0.0F){
3473 rad = (GLfloat)(3.141593F * text->
angle / 180.0F);
3474 srad = (GLfloat)sin(rad);
3475 crad = (GLfloat)cos(rad);
3479 "%f %f %f %f %f %f Tm\n" 3482 cnt, text->
fontsize, crad, srad, -srad, crad, x, y, text->
str);
3495 "%d 0 0 %d %f %f cm\n" 3498 (
int)image->
width, (
int)image->
height, x, y, cnt);
3531 GL2PSrgba lastrgba = {-1.0F, -1.0F, -1.0F, -1.0F};
3532 GLushort lastpattern = 0;
3533 GLint lastfactor = 0;
3534 GLfloat lastwidth = 1;
3536 int lastTriangleWasNotSimpleWithSameColor = 0;
3562 if(lasttype != p->
type || lastwidth != p->
width ||
3575 lastwidth = p->
width;
3581 if(lasttype != p->
type || lastwidth != p->
width ||
3591 lastwidth = p->
width;
3598 lastTriangleWasNotSimpleWithSameColor =
3602 lastTriangleWasNotSimpleWithSameColor){
3705 for(j = 0; j <= lastel; ++j){
3727 for(j = 1; j <= lastel; ++j){
3736 prev->verts[1].xyz[0], prev->verts[1].xyz[1]);
3762 for(j = 0; j <= lastel; ++j){
3782 for(j = 0; j <= lastel; ++j){
3805 for(j = 0; j <= lastel; ++j){
3847 for(j = 0; j <= lastel; ++j){
3854 for(j = 0; j <= lastel; ++j){
3862 for(j = 0; j <= lastel; ++j){
3880 offs += fprintf(gl2ps->
stream,
3889 offs += fprintf(gl2ps->
stream,
">>\n");
3901 offs += fprintf(gl2ps->
stream,
3911 offs += fprintf(gl2ps->
stream,
">>\n");
3924 offs += fprintf(gl2ps->
stream,
3947 offs += fprintf(gl2ps->
stream,
">>\n");
3959 offs += fprintf(gl2ps->
stream,
"/Font\n<<\n");
3968 offs += fprintf(gl2ps->
stream,
">>\n");
3999 newtime = gmtime(&now);
4001 offs = fprintf(gl2ps->
stream,
4005 "/Creator (GL2PS %d.%d.%d%s, %s)\n" 4012 offs += fprintf(gl2ps->
stream,
4018 offs += fprintf(gl2ps->
stream,
4019 "/CreationDate (D:%d%02d%02d%02d%02d%02d)\n" 4022 newtime->tm_year+1900,
4035 return fprintf(gl2ps->
stream,
4046 return fprintf(gl2ps->
stream,
4062 offs += fprintf(gl2ps->
stream,
4065 "/Length 5 0 R\n" );
4067 offs += fprintf(gl2ps->
stream,
4101 #if defined(GL2PS_HAVE_ZLIB) 4103 gl2psSetupCompress();
4107 offs += fprintf(gl2ps->
stream,
"%%PDF-1.4\n");
4143 #if defined(GL2PS_HAVE_ZLIB) 4145 if(Z_OK != gl2psDeflate())
4152 gl2psFreeCompress();
4156 offs += fprintf(gl2ps->
stream,
4166 return fprintf(gl2ps->
stream,
4180 offs = fprintf(gl2ps->
stream,
4185 "/MediaBox [%d %d %d %d]\n",
4190 offs += fprintf(gl2ps->
stream,
"/Rotate -90\n");
4192 offs += fprintf(gl2ps->
stream,
4196 "/ProcSet [/PDF /Text /ImageB /ImageC] %%/ImageI\n");
4220 offs += fprintf(gl2ps->
stream,
4231 return fprintf(gl2ps->
stream,
4234 "/Type /ExtGState\n" 4250 int (*action)(
unsigned long data,
int size),
4251 GLfloat dx, GLfloat dy,
4252 GLfloat xmin, GLfloat ymin)
4261 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4263 offs += (*action)(edgeflag, 1);
4269 offs += (*action)(0, 4);
4270 offs += (*action)(0, 4);
4273 diff = (vertex->
xyz[0] - xmin) / dx;
4278 imap = (
unsigned long)(diff * dmax);
4279 offs += (*action)(imap, 4);
4281 diff = (vertex->
xyz[1] - ymin) / dy;
4286 imap = (
unsigned long)(diff * dmax);
4287 offs += (*action)(imap, 4);
4296 int (*action)(
unsigned long data,
int size))
4303 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4305 imap = (
unsigned long)((vertex->
rgba[0]) * dmax);
4306 offs += (*action)(imap, 1);
4308 imap = (
unsigned long)((vertex->
rgba[1]) * dmax);
4309 offs += (*action)(imap, 1);
4311 imap = (
unsigned long)((vertex->
rgba[2]) * dmax);
4312 offs += (*action)(imap, 1);
4320 int (*action)(
unsigned long data,
int size),
4328 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4330 if(sigbyte != 8 && sigbyte != 16)
4335 imap = (
unsigned long)((vertex->
rgba[3]) * dmax);
4337 offs += (*action)(imap, sigbyte);
4345 GLfloat dx, GLfloat dy,
4346 GLfloat xmin, GLfloat ymin,
4347 int (*action)(
unsigned long data,
int size),
4353 if(gray && gray != 8 && gray != 16)
4356 for(i = 0; i < 3; ++i){
4358 dx, dy, xmin, ymin);
4372 GLfloat *ymin, GLfloat *ymax,
4382 for(i = 0; i < cnt; ++i){
4383 for(j = 0; j < 3; ++j){
4384 if(*xmin > triangles[i].vertex[j].xyz[0])
4386 if(*xmax < triangles[i].vertex[j].xyz[0])
4388 if(*ymin > triangles[i].vertex[j].xyz[1])
4390 if(*ymax < triangles[i].vertex[j].xyz[1])
4404 int i, offs = 0, vertexbytes, done = 0;
4405 GLfloat xmin, xmax, ymin, ymax;
4409 vertexbytes = 1+4+4+1+1+1;
4412 vertexbytes = 1+4+4+1;
4415 vertexbytes = 1+4+4+2;
4419 vertexbytes = 1+4+4+1;
4425 offs += fprintf(gl2ps->
stream,
4430 "/BitsPerCoordinate 32 " 4431 "/BitsPerComponent %d " 4433 "/Decode [%f %f %f %f 0 1 %s] ",
4435 (gray) ?
"/DeviceGray" :
"/DeviceRGB",
4437 xmin, xmax, ymin, ymax,
4438 (gray) ?
"" :
"0 1 0 1");
4440 #if defined(GL2PS_HAVE_ZLIB) 4442 gl2psAllocCompress(vertexbytes * size * 3);
4444 for(i = 0; i < size; ++i)
4446 xmax-xmin, ymax-ymin, xmin, ymin,
4447 gl2psWriteBigEndianCompress, gray);
4449 if(Z_OK == gl2psDeflate() && 23 + gl2ps->
compress->destLen < gl2ps->
compress->srcLen){
4451 offs += fprintf(gl2ps->
stream,
4461 gl2psFreeCompress();
4468 offs += fprintf(gl2ps->
stream,
4472 vertexbytes * 3 * size);
4473 for(i = 0; i < size; ++i)
4475 xmax-xmin, ymax-ymin, xmin, ymin,
4479 offs += fprintf(gl2ps->
stream,
4492 offs += fprintf(gl2ps->
stream,
4497 "/BBox [ %d %d %d %d ]\n" 4498 "/Group \n<<\n/S /Transparency /CS /DeviceRGB\n" 4505 ? (
int)strlen(
"/TrSh sh\n") + (int)log10((
double)childobj)+1
4506 : (
int)strlen(
"/TrSh0 sh\n");
4508 offs += fprintf(gl2ps->
stream,
4513 offs += fprintf(gl2ps->
stream,
4516 offs += fprintf(gl2ps->
stream,
4531 offs += fprintf(gl2ps->
stream,
4536 offs += fprintf(gl2ps->
stream,
4537 "/SMask << /S /Alpha /G %d 0 R >> ",
4540 offs += fprintf(gl2ps->
stream,
4552 offs += fprintf(gl2ps->
stream,
4565 int (*action)(
unsigned long data,
int size),
4571 if(im->
format != GL_RGBA && gray)
4574 if(gray && gray != 8 && gray != 16)
4579 shift = (
sizeof(
unsigned long) - 1) * 8;
4581 for(y = 0; y < im->
height; ++y){
4582 for(x = 0; x < im->
width; ++x){
4584 if(im->
format == GL_RGBA && gray){
4585 (*action)((
unsigned long)(a * 255) << shift, gray);
4588 (*action)((
unsigned long)(r * 255) << shift, 1);
4589 (*action)((
unsigned long)(g * 255) << shift, 1);
4590 (*action)((
unsigned long)(b * 255) << shift, 1);
4605 int offs = 0, done = 0, sigbytes = 3;
4607 if(gray && gray !=8 && gray != 16)
4611 sigbytes = gray / 8;
4613 offs += fprintf(gl2ps->
stream,
4621 "/BitsPerComponent 8\n",
4624 (gray) ?
"/DeviceGray" :
"/DeviceRGB" );
4625 if(GL_RGBA == im->
format && gray == 0){
4626 offs += fprintf(gl2ps->
stream,
4631 #if defined(GL2PS_HAVE_ZLIB) 4633 gl2psAllocCompress((
int)(im->
width * im->
height * sigbytes));
4637 if(Z_OK == gl2psDeflate() && 23 + gl2ps->
compress->destLen < gl2ps->
compress->srcLen){
4639 offs += fprintf(gl2ps->
stream,
4648 gl2psFreeCompress();
4655 offs += fprintf(gl2ps->
stream,
4663 offs += fprintf(gl2ps->
stream,
4674 offs += fprintf(gl2ps->
stream,
4681 "/Encoding /MacRomanEncoding\n" 4695 int offs = entryoffs;
4715 for(j = 0; j < size; ++j){
4820 #if defined(GL2PS_HAVE_ZLIB) 4822 gl2psFreeCompress();
4836 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
4838 glRenderMode(GL_FEEDBACK);
4842 gl2ps->
header = GL_FALSE;
4849 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
4852 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &idx);
4897 "Portable Document Format" 4911 for(i = 0; i < n; i++){
4912 xyz[i][0] = verts[i].
xyz[0];
4915 for(j = 0; j < 4; j++)
4916 rgba[i][j] = verts[i].rgba[j];
4922 int r = (int)(255. * rgba[0]);
4923 int g = (int)(255. * rgba[1]);
4924 int b = (int)(255. * rgba[2]);
4925 int rc = (r < 0) ? 0 : (r > 255) ? 255 : r;
4926 int gc = (g < 0) ? 0 : (g > 255) ? 255 : g;
4927 int bc = (b < 0) ? 0 : (b > 255) ? 255 : b;
4928 sprintf(str,
"#%2.2x%2.2x%2.2x", rc, gc, bc);
4933 int x, y, width, height;
4955 gl2psPrintf(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
4956 gl2psPrintf(
"<svg xmlns=\"http://www.w3.org/2000/svg\"\n");
4957 gl2psPrintf(
" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" 4958 " width=\"%dpx\" height=\"%dpx\" viewBox=\"%d %d %d %d\">\n",
4959 width, height, x, y, width, height);
4973 gl2psPrintf(
"<polygon fill=\"%s\" points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n", col,
4981 gl2psPrintf(
"<g shape-rendering=\"crispEdges\">\n");
4998 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"fill-opacity=\"%g\" ", rgba[0][3]);
4999 gl2psPrintf(
"points=\"%g,%g %g,%g %g,%g\"/>\n", xyz[0][0], xyz[0][1],
5000 xyz[1][0], xyz[1][1], xyz[2][0], xyz[2][1]);
5004 for(i = 0; i < 3; i++){
5005 xyz2[0][i] = xyz[0][i];
5006 xyz2[1][i] = 0.5F * (xyz[0][i] + xyz[1][i]);
5007 xyz2[2][i] = 0.5F * (xyz[0][i] + xyz[2][i]);
5009 for(i = 0; i < 4; i++){
5010 rgba2[0][i] = rgba[0][i];
5011 rgba2[1][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
5012 rgba2[2][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
5015 for(i = 0; i < 3; i++){
5016 xyz2[0][i] = 0.5F * (xyz[0][i] + xyz[1][i]);
5017 xyz2[1][i] = xyz[1][i];
5018 xyz2[2][i] = 0.5F * (xyz[1][i] + xyz[2][i]);
5020 for(i = 0; i < 4; i++){
5021 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
5022 rgba2[1][i] = rgba[1][i];
5023 rgba2[2][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
5026 for(i = 0; i < 3; i++){
5027 xyz2[0][i] = 0.5F * (xyz[0][i] + xyz[2][i]);
5028 xyz2[1][i] = xyz[2][i];
5029 xyz2[2][i] = 0.5F * (xyz[1][i] + xyz[2][i]);
5031 for(i = 0; i < 4; i++){
5032 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
5033 rgba2[1][i] = rgba[2][i];
5034 rgba2[2][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
5037 for(i = 0; i < 3; i++){
5038 xyz2[0][i] = 0.5F * (xyz[0][i] + xyz[1][i]);
5039 xyz2[1][i] = 0.5F * (xyz[1][i] + xyz[2][i]);
5040 xyz2[2][i] = 0.5F * (xyz[0][i] + xyz[2][i]);
5042 for(i = 0; i < 4; i++){
5043 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
5044 rgba2[1][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
5045 rgba2[2][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
5053 int i, n, array[10];
5055 if(!pattern || !factor)
return;
5059 for(i = 0; i < n; i++){
5072 for(i = 0; i < 3; i++)
5074 for(i = 0; i < 4; i++)
5081 #if defined(GL2PS_HAVE_LIBPNG) 5093 sizeof(
unsigned char));
5094 gl2psConvertPixmapToPNG(pixmap, png);
5095 gl2psListEncodeBase64(png);
5100 gl2psPrintf(
"<image x=\"%g\" y=\"%g\" width=\"%d\" height=\"%d\"\n",
5102 gl2psPrintf(
"transform=\"matrix(%g,0,0,%g,%g,%g)\"\n",
5104 gl2psPrintf(
"xlink:href=\"data:image/png;base64,");
5106 gl2psListRead(png, i, &c);
5112 (void) x; (void) y; (void) pixmap;
5114 "order to embed images in SVG streams");
5141 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"fill-opacity=\"%g\" ", rgba[0][3]);
5143 xyz[0][0], xyz[0][1], 0.5 * prim->
width);
5168 gl2psPrintf(
"<polyline fill=\"none\" stroke=\"%s\" stroke-width=\"%g\" ",
5170 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"stroke-opacity=\"%g\" ", rgba[0][3]);
5172 gl2psPrintf(
"points=\"%g,%g ", xyz[0][0], xyz[0][1]);
5189 gl2psPrintf(
"<text fill=\"%s\" x=\"%g\" y=\"%g\" font-size=\"%d\" ",
5196 gl2psPrintf(
"text-anchor=\"middle\" baseline-shift=\"%d\" ",
5200 gl2psPrintf(
"text-anchor=\"start\" baseline-shift=\"%d\" ",
5204 gl2psPrintf(
"text-anchor=\"end\" baseline-shift=\"%d\" ",
5208 gl2psPrintf(
"text-anchor=\"middle\" baseline-shift=\"0\" ");
5211 gl2psPrintf(
"text-anchor=\"end\" baseline-shift=\"0\" ");
5214 gl2psPrintf(
"text-anchor=\"middle\" baseline-shift=\"%d\" ",
5218 gl2psPrintf(
"text-anchor=\"start\" baseline-shift=\"%d\" ",
5222 gl2psPrintf(
"text-anchor=\"end\" baseline-shift=\"%d\" ",
5227 gl2psPrintf(
"text-anchor=\"start\" baseline-shift=\"0\" ");
5233 gl2psPrintf(
"font-family=\"Times\" font-weight=\"bold\">");
5235 gl2psPrintf(
"font-family=\"Times\" font-style=\"italic\">");
5237 gl2psPrintf(
"font-family=\"Times\" font-style=\"italic\" font-weight=\"bold\">");
5239 gl2psPrintf(
"font-family=\"Helvetica\" font-weight=\"bold\">");
5241 gl2psPrintf(
"font-family=\"Helvetica\" font-style=\"oblique\">");
5243 gl2psPrintf(
"font-family=\"Helvetica\" font-style=\"oblique\" font-weight=\"bold\">");
5245 gl2psPrintf(
"font-family=\"Courier\" font-weight=\"bold\">");
5247 gl2psPrintf(
"font-family=\"Courier\" font-style=\"oblique\">");
5249 gl2psPrintf(
"font-family=\"Courier\" font-style=\"oblique\" font-weight=\"bold\">");
5278 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
5280 glRenderMode(GL_FEEDBACK);
5284 gl2ps->
header = GL_FALSE;
5289 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
5292 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &idx);
5299 gl2psPrintf(
"<polygon fill=\"%s\" points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n", col,
5302 x + w, gl2ps->
viewport[3] - (y + h),
5306 gl2psPrintf(
"<clipPath id=\"cp%d%d%d%d\">\n", x, y, w, h);
5307 gl2psPrintf(
" <polygon points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n",
5310 x + w, gl2ps->
viewport[3] - (y + h),
5313 gl2psPrintf(
"<g clip-path=\"url(#cp%d%d%d%d)\">\n", x, y, w, h);
5341 "Scalable Vector Graphics" 5354 fprintf(gl2ps->
stream,
"\\color[rgb]{%f,%f,%f}\n", rgba[0], rgba[1], rgba[2]);
5366 "%% Creator: GL2PS %d.%d.%d%s, %s\n" 5368 "%% CreationDate: %s",
5373 fprintf(gl2ps->
stream,
"\\begin{pgfpicture}\n");
5377 "\\pgfpathrectanglecorners{" 5378 "\\pgfpoint{%dpt}{%dpt}}{\\pgfpoint{%dpt}{%dpt}}\n" 5379 "\\pgfusepath{fill}\n",
5387 int i, n, array[10];
5395 if(!pattern || !factor){
5397 fprintf(gl2ps->
stream,
"\\pgfsetdash{}{0pt}\n");
5401 fprintf(gl2ps->
stream,
"\\pgfsetdash{");
5402 for(i = 0; i < n; i++) fprintf(gl2ps->
stream,
"{%dpt}", array[i]);
5403 fprintf(gl2ps->
stream,
"}{0pt}\n");
5419 default :
return "south west";
5434 "\\pgfpathrectangle{\\pgfpoint{%fpt}{%fpt}}" 5435 "{\\pgfpoint{%fpt}{%fpt}}\n\\pgfusepath{fill}\n",
5448 "\\pgfpathmoveto{\\pgfpoint{%fpt}{%fpt}}\n" 5449 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n" 5450 "\\pgfusepath{stroke}\n",
5457 fprintf(gl2ps->
stream,
"\\pgfsetlinewidth{0.01pt}\n");
5461 "\\pgfpathmoveto{\\pgfpoint{%fpt}{%fpt}}\n" 5462 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n" 5463 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n" 5465 "\\pgfusepath{fill,stroke}\n",
5471 fprintf(gl2ps->
stream,
"{\n\\pgftransformshift{\\pgfpoint{%fpt}{%fpt}}\n",
5477 fprintf(gl2ps->
stream,
"\\pgfnode{rectangle}{%s}{\\fontsize{%d}{0}\\selectfont",
5481 fprintf(gl2ps->
stream,
"\\textcolor[rgb]{%g,%g,%g}{{%s}}",
5485 fprintf(gl2ps->
stream,
"}{}{\\pgfusepath{discard}}}");
5488 fprintf(gl2ps->
stream,
"}");
5490 fprintf(gl2ps->
stream,
"\n");
5505 fprintf(gl2ps->
stream,
"\\end{pgfpicture}\n");
5512 int x = viewport[0], y = viewport[1], w = viewport[2], h = viewport[3];
5514 glRenderMode(GL_FEEDBACK);
5518 gl2ps->
header = GL_FALSE;
5521 fprintf(gl2ps->
stream,
"\\begin{pgfscope}\n");
5524 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
5527 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &idx);
5535 "\\pgfpathrectangle{\\pgfpoint{%dpt}{%dpt}}" 5536 "{\\pgfpoint{%dpt}{%dpt}}\n" 5537 "\\pgfusepath{fill}\n",
5542 "\\pgfpathrectangle{\\pgfpoint{%dpt}{%dpt}}" 5543 "{\\pgfpoint{%dpt}{%dpt}}\n" 5544 "\\pgfusepath{clip}\n",
5552 fprintf(gl2ps->
stream,
"\\end{pgfscope}\n");
5570 "PGF Latex Graphics" 5598 for(i = 0; i < prim->
numverts; i++){
5616 used = glRenderMode(GL_RENDER);
5636 gl2ps->
header = GL_FALSE;
5644 switch(gl2ps->
sort){
5691 GLint viewport[4], GLint format, GLint sort,
5692 GLint options, GLint colormode,
5694 GLint nr, GLint ng, GLint nb, GLint buffersize,
5695 FILE *stream,
const char *filename)
5707 if(format >= 0 && format < (GLint)(
sizeof(
gl2psbackends) /
sizeof(gl2psbackends[0]))){
5748 glGetIntegerv(GL_VIEWPORT, gl2ps->
viewport);
5751 for(i = 0; i < 4; i++){
5765 gl2ps->
threshold[0] = nr ? 1.0F / (GLfloat)nr : 0.064F;
5766 gl2ps->
threshold[1] = ng ? 1.0F / (GLfloat)ng : 0.034F;
5767 gl2ps->
threshold[2] = nb ? 1.0F / (GLfloat)nb : 0.100F;
5769 gl2ps->
buffersize = buffersize > 0 ? buffersize : 2048 * 2048;
5770 for(i = 0; i < 3; i++){
5773 for(i = 0; i < 4; i++){
5790 glGetIntegerv(GL_BLEND_SRC, &gl2ps->
blendfunc[0]);
5791 glGetIntegerv(GL_BLEND_DST, &gl2ps->
blendfunc[1]);
5796 glGetFloatv(GL_COLOR_CLEAR_VALUE, gl2ps->
bgcolor);
5798 else if(gl2ps->
colormode == GL_COLOR_INDEX){
5799 if(!colorsize || !colormap){
5808 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &idx);
5823 gl2ps->
title[0] =
'\0';
5827 strcpy(gl2ps->
title, title);
5852 glRenderMode(GL_FEEDBACK);
5908 GLshort fontsize, GLint alignment, GLfloat angle,
5916 GLshort fontsize, GLint alignment, GLfloat angle)
5933 GLint xorig, GLint yorig,
5934 GLenum format, GLenum type,
5939 GLfloat pos[4], zoom_x, zoom_y;
5945 if((width <= 0) || (height <= 0))
return GL2PS_ERROR;
5949 if((format != GL_RGB && format != GL_RGBA) || type != GL_FLOAT){
5951 "GL_RGB/GL_RGBA, GL_FLOAT pixels");
5955 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
5958 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
5959 glGetFloatv(GL_ZOOM_X, &zoom_x);
5960 glGetFloatv(GL_ZOOM_Y, &zoom_y);
5967 prim->
verts[0].
xyz[0] = pos[0] + xorig;
5968 prim->
verts[0].
xyz[1] = pos[1] + yorig;
5977 glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->
verts[0].
rgba);
5991 size = height * width * 3;
5993 piv = (
const GLfloat*)pixels;
5994 for(i = 0; i < size; ++i, ++piv){
6001 size = height * width * 4;
6008 size = height * width * 3;
6021 const GLfloat position[3],
6022 const unsigned char *imagemap){
6024 int sizeoffloat =
sizeof(GLfloat);
6028 if((width <= 0) || (height <= 0))
return GL2PS_ERROR;
6030 size = height + height * ((width - 1) / 8);
6033 glVertex3f(position[0], position[1],position[2]);
6035 glPassThrough((GLfloat)width);
6036 glPassThrough((GLfloat)height);
6037 for(i = 0; i < size; i += sizeoffloat){
6038 const float *value = (
const float*)imagemap;
6039 glPassThrough(*value);
6040 imagemap += sizeoffloat;
6055 glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &tmp2);
6056 glPassThrough(tmp2);
6057 glGetFloatv(GL_POLYGON_OFFSET_UNITS, &tmp2);
6058 glPassThrough(tmp2);
6065 glGetIntegerv(GL_LINE_STIPPLE_PATTERN, &tmp);
6066 glPassThrough((GLfloat)tmp);
6067 glGetIntegerv(GL_LINE_STIPPLE_REPEAT, &tmp);
6068 glPassThrough((GLfloat)tmp);
6111 glPassThrough(value);
6121 glPassThrough(value);
6134 glPassThrough((GLfloat)sfactor);
6136 glPassThrough((GLfloat)dfactor);
6164 if(format >= 0 && format < (GLint)(
sizeof(gl2psbackends) /
sizeof(gl2psbackends[0])))
6167 return "Unknown format";
6172 if(format >= 0 && format < (GLint)(
sizeof(gl2psbackends) /
sizeof(gl2psbackends[0])))
6175 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)
void(* printFooter)(void)
static void gl2psSortOutTrianglePDFgroup(GL2PSpdfgroup *gro)
static void gl2psPrintPGFFinalPrimitive(void)
static GLint gl2psGetVertex(GL2PSvertex *v, GLfloat *p)
void(* printHeader)(void)
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 const char * pixmap[]
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)
GL2PSDLL_API GLint gl2psTextOptColor(const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle, GL2PSrgba color)
static int gl2psPDFgroupListWriteVariableResources(void)
static void gl2psPutPDFSpecial(GL2PSstring *text)
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)
#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)
void(* printFinalPrimitive)(void)
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)
void image(float x, float y, GLboolean opaque)
static void gl2psAddPrimitiveInList(GL2PSprimitive *prim, GL2PSlist *list)
static void gl2psPrintTeXHeader(void)
static GLint gl2psAddInBspImageTree(GL2PSprimitive *prim, GL2PSbsptree2d **tree)
static void * gl2psListPointer(GL2PSlist *list, GLint idx)
GLint(* endViewport)(void)
#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
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
GL2PSDLL_API GLint gl2psGetOptions(GLint *options)
static void gl2psFillTriangleFromPrimitive(GL2PStriangle *t, GL2PSprimitive *p, GLboolean assignprops)
static void gl2psWriteByte(unsigned char byte)
#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))
union GL2PSprimitive::@7 data
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[]
void(* printPrimitive)(void *data)
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)
#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 GLint gl2psAddText(GLint type, const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle, GL2PSrgba color)
static void gl2psPDFstacksInit(void)
GL2PSDLL_API GLint gl2psGetFileFormat()
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)
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
#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)
static void gl2psAddPolyPrimitive(GLshort type, GLshort numverts, GL2PSvertex *verts, GLint offset, GLfloat ofactor, GLfloat ounits, GLushort pattern, GLint factor, GLfloat width, char boundary)
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)
void(* beginViewport)(GLint viewport[4])
static void gl2psPrintPGFBeginViewport(GLint viewport[4])
GL2PSDLL_API GLint gl2psEndViewport(void)
static GLboolean gl2psSameColor(GL2PSrgba rgba1, GL2PSrgba rgba2)
#define GL2PS_SIMPLE_LINE_OFFSET