ATLAS Offline Software
Classes | Macros | Typedefs | Enumerations | Functions
gl2ps.cxx File Reference
#include "VP1HEPVis/gl2ps.h"
#include <math.h>
#include <string.h>
#include <sys/types.h>
#include <stdarg.h>
#include <time.h>
#include <float.h>
Include dependency graph for gl2ps.cxx:

Go to the source code of this file.

Classes

struct  _GL2PSbsptree2d
 
struct  GL2PSlist
 
struct  _GL2PSbsptree
 
struct  GL2PSvertex
 
struct  GL2PStriangle
 
struct  GL2PSstring
 
struct  GL2PSimage
 
struct  _GL2PSimagemap
 
struct  GL2PSprimitive
 
struct  GL2PScompress
 
struct  GL2PSpdfgroup
 
struct  GL2PScontext
 
struct  GL2PSbackend
 

Macros

#define GL2PS_EPSILON   5.0e-3F
 
#define GL2PS_ZSCALE   1000.0F
 
#define GL2PS_ZOFFSET   5.0e-2F
 
#define GL2PS_ZOFFSET_LARGE   20.0F
 
#define GL2PS_ZERO(arg)   (fabs(arg) < 1.e-20)
 
#define GL2PS_NO_TYPE   -1
 
#define GL2PS_TEXT   1
 
#define GL2PS_POINT   2
 
#define GL2PS_LINE   3
 
#define GL2PS_QUADRANGLE   4
 
#define GL2PS_TRIANGLE   5
 
#define GL2PS_PIXMAP   6
 
#define GL2PS_IMAGEMAP   7
 
#define GL2PS_IMAGEMAP_WRITTEN   8
 
#define GL2PS_IMAGEMAP_VISIBLE   9
 
#define GL2PS_SPECIAL   10
 
#define GL2PS_COINCIDENT   1
 
#define GL2PS_IN_FRONT_OF   2
 
#define GL2PS_IN_BACK_OF   3
 
#define GL2PS_SPANNING   4
 
#define GL2PS_POINT_COINCIDENT   0
 
#define GL2PS_POINT_INFRONT   1
 
#define GL2PS_POINT_BACK   2
 
#define GL2PS_BEGIN_OFFSET_TOKEN   1
 
#define GL2PS_END_OFFSET_TOKEN   2
 
#define GL2PS_BEGIN_BOUNDARY_TOKEN   3
 
#define GL2PS_END_BOUNDARY_TOKEN   4
 
#define GL2PS_BEGIN_STIPPLE_TOKEN   5
 
#define GL2PS_END_STIPPLE_TOKEN   6
 
#define GL2PS_POINT_SIZE_TOKEN   7
 
#define GL2PS_LINE_WIDTH_TOKEN   8
 
#define GL2PS_BEGIN_BLEND_TOKEN   9
 
#define GL2PS_END_BLEND_TOKEN   10
 
#define GL2PS_SRC_BLEND_TOKEN   11
 
#define GL2PS_DST_BLEND_TOKEN   12
 
#define GL2PS_IMAGEMAP_TOKEN   13
 
#define GL2PS_DRAW_PIXELS_TOKEN   14
 
#define GL2PS_TEXT_TOKEN   15
 

Typedefs

typedef GLfloat GL2PSxyz[3]
 
typedef GLfloat GL2PSplane[4]
 
typedef struct _GL2PSbsptree2d GL2PSbsptree2d
 
typedef struct _GL2PSbsptree GL2PSbsptree
 
typedef struct _GL2PSimagemap GL2PSimagemap
 

Enumerations

enum  GL2PS_TRIANGLE_PROPERTY {
  T_UNDEFINED = -1, T_CONST_COLOR = 1, T_VAR_COLOR = 1<<1, T_ALPHA_1 = 1<<2,
  T_ALPHA_LESS_1 = 1<<3, T_VAR_ALPHA = 1<<4
}
 

Functions

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)
 
GL2PSDLL_API GLint gl2psEndPage (void)
 
GL2PSDLL_API GLint gl2psBeginViewport (GLint viewport[4])
 
GL2PSDLL_API GLint gl2psEndViewport (void)
 
GL2PSDLL_API GLint gl2psTextOpt (const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle)
 
GL2PSDLL_API GLint gl2psText (const char *str, const char *fontname, GLshort fontsize)
 
GL2PSDLL_API GLint gl2psSpecial (GLint format, const char *str)
 
GL2PSDLL_API GLint gl2psDrawPixels (GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
 
GL2PSDLL_API GLint gl2psDrawImageMap (GLsizei width, GLsizei height, const GLfloat position[3], const unsigned char *imagemap)
 
GL2PSDLL_API GLint gl2psEnable (GLint mode)
 
GL2PSDLL_API GLint gl2psDisable (GLint mode)
 
GL2PSDLL_API GLint gl2psPointSize (GLfloat value)
 
GL2PSDLL_API GLint gl2psLineWidth (GLfloat value)
 
GL2PSDLL_API GLint gl2psBlendFunc (GLenum sfactor, GLenum dfactor)
 
GL2PSDLL_API GLint gl2psSetOptions (GLint options)
 
GL2PSDLL_API GLint gl2psGetOptions (GLint *options)
 
GL2PSDLL_API const char * gl2psGetFileExtension (GLint format)
 
GL2PSDLL_API const char * gl2psGetFormatDescription (GLint format)
 

Macro Definition Documentation

◆ GL2PS_BEGIN_BLEND_TOKEN

#define GL2PS_BEGIN_BLEND_TOKEN   9

Definition at line 110 of file gl2ps.cxx.

◆ GL2PS_BEGIN_BOUNDARY_TOKEN

#define GL2PS_BEGIN_BOUNDARY_TOKEN   3

Definition at line 104 of file gl2ps.cxx.

◆ GL2PS_BEGIN_OFFSET_TOKEN

#define GL2PS_BEGIN_OFFSET_TOKEN   1

Definition at line 102 of file gl2ps.cxx.

◆ GL2PS_BEGIN_STIPPLE_TOKEN

#define GL2PS_BEGIN_STIPPLE_TOKEN   5

Definition at line 106 of file gl2ps.cxx.

◆ GL2PS_COINCIDENT

#define GL2PS_COINCIDENT   1

Definition at line 89 of file gl2ps.cxx.

◆ GL2PS_DRAW_PIXELS_TOKEN

#define GL2PS_DRAW_PIXELS_TOKEN   14

Definition at line 115 of file gl2ps.cxx.

◆ GL2PS_DST_BLEND_TOKEN

#define GL2PS_DST_BLEND_TOKEN   12

Definition at line 113 of file gl2ps.cxx.

◆ GL2PS_END_BLEND_TOKEN

#define GL2PS_END_BLEND_TOKEN   10

Definition at line 111 of file gl2ps.cxx.

◆ GL2PS_END_BOUNDARY_TOKEN

#define GL2PS_END_BOUNDARY_TOKEN   4

Definition at line 105 of file gl2ps.cxx.

◆ GL2PS_END_OFFSET_TOKEN

#define GL2PS_END_OFFSET_TOKEN   2

Definition at line 103 of file gl2ps.cxx.

◆ GL2PS_END_STIPPLE_TOKEN

#define GL2PS_END_STIPPLE_TOKEN   6

Definition at line 107 of file gl2ps.cxx.

◆ GL2PS_EPSILON

#define GL2PS_EPSILON   5.0e-3F

Definition at line 67 of file gl2ps.cxx.

◆ GL2PS_IMAGEMAP

#define GL2PS_IMAGEMAP   7

Definition at line 82 of file gl2ps.cxx.

◆ GL2PS_IMAGEMAP_TOKEN

#define GL2PS_IMAGEMAP_TOKEN   13

Definition at line 114 of file gl2ps.cxx.

◆ GL2PS_IMAGEMAP_VISIBLE

#define GL2PS_IMAGEMAP_VISIBLE   9

Definition at line 84 of file gl2ps.cxx.

◆ GL2PS_IMAGEMAP_WRITTEN

#define GL2PS_IMAGEMAP_WRITTEN   8

Definition at line 83 of file gl2ps.cxx.

◆ GL2PS_IN_BACK_OF

#define GL2PS_IN_BACK_OF   3

Definition at line 91 of file gl2ps.cxx.

◆ GL2PS_IN_FRONT_OF

#define GL2PS_IN_FRONT_OF   2

Definition at line 90 of file gl2ps.cxx.

◆ GL2PS_LINE

#define GL2PS_LINE   3

Definition at line 78 of file gl2ps.cxx.

◆ GL2PS_LINE_WIDTH_TOKEN

#define GL2PS_LINE_WIDTH_TOKEN   8

Definition at line 109 of file gl2ps.cxx.

◆ GL2PS_NO_TYPE

#define GL2PS_NO_TYPE   -1

Definition at line 75 of file gl2ps.cxx.

◆ GL2PS_PIXMAP

#define GL2PS_PIXMAP   6

Definition at line 81 of file gl2ps.cxx.

◆ GL2PS_POINT

#define GL2PS_POINT   2

Definition at line 77 of file gl2ps.cxx.

◆ GL2PS_POINT_BACK

#define GL2PS_POINT_BACK   2

Definition at line 98 of file gl2ps.cxx.

◆ GL2PS_POINT_COINCIDENT

#define GL2PS_POINT_COINCIDENT   0

Definition at line 96 of file gl2ps.cxx.

◆ GL2PS_POINT_INFRONT

#define GL2PS_POINT_INFRONT   1

Definition at line 97 of file gl2ps.cxx.

◆ GL2PS_POINT_SIZE_TOKEN

#define GL2PS_POINT_SIZE_TOKEN   7

Definition at line 108 of file gl2ps.cxx.

◆ GL2PS_QUADRANGLE

#define GL2PS_QUADRANGLE   4

Definition at line 79 of file gl2ps.cxx.

◆ GL2PS_SPANNING

#define GL2PS_SPANNING   4

Definition at line 92 of file gl2ps.cxx.

◆ GL2PS_SPECIAL

#define GL2PS_SPECIAL   10

Definition at line 85 of file gl2ps.cxx.

◆ GL2PS_SRC_BLEND_TOKEN

#define GL2PS_SRC_BLEND_TOKEN   11

Definition at line 112 of file gl2ps.cxx.

◆ GL2PS_TEXT

#define GL2PS_TEXT   1

Definition at line 76 of file gl2ps.cxx.

◆ GL2PS_TEXT_TOKEN

#define GL2PS_TEXT_TOKEN   15

Definition at line 116 of file gl2ps.cxx.

◆ GL2PS_TRIANGLE

#define GL2PS_TRIANGLE   5

Definition at line 80 of file gl2ps.cxx.

◆ GL2PS_ZERO

#define GL2PS_ZERO (   arg)    (fabs(arg) < 1.e-20)

Definition at line 71 of file gl2ps.cxx.

◆ GL2PS_ZOFFSET

#define GL2PS_ZOFFSET   5.0e-2F

Definition at line 69 of file gl2ps.cxx.

◆ GL2PS_ZOFFSET_LARGE

#define GL2PS_ZOFFSET_LARGE   20.0F

Definition at line 70 of file gl2ps.cxx.

◆ GL2PS_ZSCALE

#define GL2PS_ZSCALE   1000.0F

Definition at line 68 of file gl2ps.cxx.

Typedef Documentation

◆ GL2PSbsptree

typedef struct _GL2PSbsptree GL2PSbsptree

Definition at line 127 of file gl2ps.cxx.

◆ GL2PSbsptree2d

Definition at line 127 of file gl2ps.cxx.

◆ GL2PSimagemap

typedef struct _GL2PSimagemap GL2PSimagemap

Definition at line 127 of file gl2ps.cxx.

◆ GL2PSplane

typedef GLfloat GL2PSplane[4]

Definition at line 127 of file gl2ps.cxx.

◆ GL2PSxyz

typedef GLfloat GL2PSxyz[3]

Definition at line 126 of file gl2ps.cxx.

Enumeration Type Documentation

◆ GL2PS_TRIANGLE_PROPERTY

Enumerator
T_UNDEFINED 
T_CONST_COLOR 
T_VAR_COLOR 
T_ALPHA_1 
T_ALPHA_LESS_1 
T_VAR_ALPHA 

Definition at line 117 of file gl2ps.cxx.

117  {
118  T_UNDEFINED = -1,
119  T_CONST_COLOR = 1,
120  T_VAR_COLOR = 1<<1,
121  T_ALPHA_1 = 1<<2,
122  T_ALPHA_LESS_1 = 1<<3,
123  T_VAR_ALPHA = 1<<4

Function Documentation

◆ gl2psBeginPage()

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 
)

Definition at line 5583 of file gl2ps.cxx.

5589 {
5590  GLint index;
5591  int i;
5592 
5593  if(gl2ps){
5594  gl2psMsg(GL2PS_ERROR, "gl2psBeginPage called in wrong program state");
5595  return GL2PS_ERROR;
5596  }
5597 
5598  gl2ps = (GL2PScontext*)gl2psMalloc(sizeof(GL2PScontext));
5599 
5600  if(format >= 0 && format < (GLint)(sizeof(gl2psbackends) / sizeof(gl2psbackends[0]))){
5601  gl2ps->format = format;
5602  }
5603  else {
5604  gl2psMsg(GL2PS_ERROR, "Unknown output format: %d", format);
5605  gl2psFree(gl2ps);
5606  gl2ps = NULL;
5607  return GL2PS_ERROR;
5608  }
5609 
5610  switch(sort){
5611  case GL2PS_NO_SORT :
5612  case GL2PS_SIMPLE_SORT :
5613  case GL2PS_BSP_SORT :
5614  gl2ps->sort = sort;
5615  break;
5616  default :
5617  gl2psMsg(GL2PS_ERROR, "Unknown sorting algorithm: %d", sort);
5618  gl2psFree(gl2ps);
5619  gl2ps = NULL;
5620  return GL2PS_ERROR;
5621  }
5622 
5623  if(stream){
5624  gl2ps->stream = stream;
5625  }
5626  else{
5627  gl2psMsg(GL2PS_ERROR, "Bad file pointer");
5628  gl2psFree(gl2ps);
5629  gl2ps = NULL;
5630  return GL2PS_ERROR;
5631  }
5632 
5633  gl2ps->header = GL_TRUE;
5634  gl2ps->maxbestroot = 10;
5635  gl2ps->options = options;
5636  gl2ps->compress = NULL;
5637  gl2ps->imagemap_head = NULL;
5638  gl2ps->imagemap_tail = NULL;
5639 
5640  if(gl2ps->options & GL2PS_USE_CURRENT_VIEWPORT){
5641  glGetIntegerv(GL_VIEWPORT, gl2ps->viewport);
5642  }
5643  else{
5644  for(i = 0; i < 4; i++){
5645  gl2ps->viewport[i] = viewport[i];
5646  }
5647  }
5648 
5649  if(!gl2ps->viewport[2] || !gl2ps->viewport[3]){
5650  gl2psMsg(GL2PS_ERROR, "Incorrect viewport (x=%d, y=%d, width=%d, height=%d)",
5651  gl2ps->viewport[0], gl2ps->viewport[1],
5652  gl2ps->viewport[2], gl2ps->viewport[3]);
5653  gl2psFree(gl2ps);
5654  gl2ps = NULL;
5655  return GL2PS_ERROR;
5656  }
5657 
5658  gl2ps->threshold[0] = nr ? 1.0F / (GLfloat)nr : 0.064F;
5659  gl2ps->threshold[1] = ng ? 1.0F / (GLfloat)ng : 0.034F;
5660  gl2ps->threshold[2] = nb ? 1.0F / (GLfloat)nb : 0.100F;
5661  gl2ps->colormode = colormode;
5662  gl2ps->buffersize = buffersize > 0 ? buffersize : 2048 * 2048;
5663  for(i = 0; i < 3; i++){
5664  gl2ps->lastvertex.xyz[i] = -1.0F;
5665  }
5666  for(i = 0; i < 4; i++){
5667  gl2ps->lastvertex.rgba[i] = -1.0F;
5668  gl2ps->lastrgba[i] = -1.0F;
5669  }
5670  gl2ps->lastlinewidth = -1.0F;
5671  gl2ps->lastpattern = 0;
5672  gl2ps->lastfactor = 0;
5673  gl2ps->imagetree = NULL;
5674  gl2ps->primitivetoadd = NULL;
5675  gl2ps->zerosurfacearea = GL_FALSE;
5676  gl2ps->pdfprimlist = NULL;
5677  gl2ps->pdfgrouplist = NULL;
5678  gl2ps->xreflist = NULL;
5679 
5680  /* get default blending mode from current OpenGL state (enabled by
5681  default for SVG) */
5682  gl2ps->blending = (gl2ps->format == GL2PS_SVG) ? GL_TRUE : glIsEnabled(GL_BLEND);
5683  glGetIntegerv(GL_BLEND_SRC, &gl2ps->blendfunc[0]);
5684  glGetIntegerv(GL_BLEND_DST, &gl2ps->blendfunc[1]);
5685 
5686  if(gl2ps->colormode == GL_RGBA){
5687  gl2ps->colorsize = 0;
5688  gl2ps->colormap = NULL;
5689  glGetFloatv(GL_COLOR_CLEAR_VALUE, gl2ps->bgcolor);
5690  }
5691  else if(gl2ps->colormode == GL_COLOR_INDEX){
5692  if(!colorsize || !colormap){
5693  gl2psMsg(GL2PS_ERROR, "Missing colormap for GL_COLOR_INDEX rendering");
5694  gl2psFree(gl2ps);
5695  gl2ps = NULL;
5696  return GL2PS_ERROR;
5697  }
5698  gl2ps->colorsize = colorsize;
5699  gl2ps->colormap = (GL2PSrgba*)gl2psMalloc(gl2ps->colorsize * sizeof(GL2PSrgba));
5700  memcpy(gl2ps->colormap, colormap, gl2ps->colorsize * sizeof(GL2PSrgba));
5701  glGetIntegerv(GL_INDEX_CLEAR_VALUE, &index);
5702  gl2ps->bgcolor[0] = gl2ps->colormap[index][0];
5703  gl2ps->bgcolor[1] = gl2ps->colormap[index][1];
5704  gl2ps->bgcolor[2] = gl2ps->colormap[index][2];
5705  gl2ps->bgcolor[3] = 1.0F;
5706  }
5707  else{
5708  gl2psMsg(GL2PS_ERROR, "Unknown color mode in gl2psBeginPage");
5709  gl2psFree(gl2ps);
5710  gl2ps = NULL;
5711  return GL2PS_ERROR;
5712  }
5713 
5714  if(!title){
5715  gl2ps->title = (char*)gl2psMalloc(sizeof(char));
5716  gl2ps->title[0] = '\0';
5717  }
5718  else{
5719  gl2ps->title = (char*)gl2psMalloc((strlen(title)+1)*sizeof(char));
5720  strcpy(gl2ps->title, title);
5721  }
5722 
5723  if(!producer){
5724  gl2ps->producer = (char*)gl2psMalloc(sizeof(char));
5725  gl2ps->producer[0] = '\0';
5726  }
5727  else{
5728  gl2ps->producer = (char*)gl2psMalloc((strlen(producer)+1)*sizeof(char));
5729  strcpy(gl2ps->producer, producer);
5730  }
5731 
5732  if(!filename){
5733  gl2ps->filename = (char*)gl2psMalloc(sizeof(char));
5734  gl2ps->filename[0] = '\0';
5735  }
5736  else{
5737  gl2ps->filename = (char*)gl2psMalloc((strlen(filename)+1)*sizeof(char));
5738  strcpy(gl2ps->filename, filename);
5739  }
5740 
5741  gl2ps->primitives = gl2psListCreate(500, 500, sizeof(GL2PSprimitive*));
5742  gl2ps->auxprimitives = gl2psListCreate(100, 100, sizeof(GL2PSprimitive*));
5743  gl2ps->feedback = (GLfloat*)gl2psMalloc(gl2ps->buffersize * sizeof(GLfloat));
5744  glFeedbackBuffer(gl2ps->buffersize, GL_3D_COLOR, gl2ps->feedback);
5745  glRenderMode(GL_FEEDBACK);
5746 
5747  return GL2PS_SUCCESS;
5748 }

◆ gl2psBeginViewport()

GL2PSDLL_API GLint gl2psBeginViewport ( GLint  viewport[4])

Definition at line 5777 of file gl2ps.cxx.

5778 {
5779  if(!gl2ps) return GL2PS_UNINITIALIZED;
5780 
5781  (gl2psbackends[gl2ps->format]->beginViewport)(viewport);
5782 
5783  return GL2PS_SUCCESS;
5784 }

◆ gl2psBlendFunc()

GL2PSDLL_API GLint gl2psBlendFunc ( GLenum  sfactor,
GLenum  dfactor 
)

Definition at line 6001 of file gl2ps.cxx.

6002 {
6003  if(!gl2ps) return GL2PS_UNINITIALIZED;
6004 
6005  if(GL_FALSE == gl2psSupportedBlendMode(sfactor, dfactor))
6006  return GL2PS_WARNING;
6007 
6008  glPassThrough(GL2PS_SRC_BLEND_TOKEN);
6009  glPassThrough((GLfloat)sfactor);
6010  glPassThrough(GL2PS_DST_BLEND_TOKEN);
6011  glPassThrough((GLfloat)dfactor);
6012 
6013  return GL2PS_SUCCESS;
6014 }

◆ gl2psDisable()

GL2PSDLL_API GLint gl2psDisable ( GLint  mode)

Definition at line 5956 of file gl2ps.cxx.

5957 {
5958  if(!gl2ps) return GL2PS_UNINITIALIZED;
5959 
5960  switch(mode){
5962  glPassThrough(GL2PS_END_OFFSET_TOKEN);
5963  break;
5964  case GL2PS_POLYGON_BOUNDARY :
5965  glPassThrough(GL2PS_END_BOUNDARY_TOKEN);
5966  break;
5967  case GL2PS_LINE_STIPPLE :
5968  glPassThrough(GL2PS_END_STIPPLE_TOKEN);
5969  break;
5970  case GL2PS_BLEND :
5971  glPassThrough(GL2PS_END_BLEND_TOKEN);
5972  break;
5973  default :
5974  gl2psMsg(GL2PS_WARNING, "Unknown mode in gl2psDisable: %d", mode);
5975  return GL2PS_WARNING;
5976  }
5977 
5978  return GL2PS_SUCCESS;
5979 }

◆ gl2psDrawImageMap()

GL2PSDLL_API GLint gl2psDrawImageMap ( GLsizei  width,
GLsizei  height,
const GLfloat  position[3],
const unsigned char *  imagemap 
)

Definition at line 5897 of file gl2ps.cxx.

5899  {
5900  int size, i;
5901  int sizeoffloat = sizeof(GLfloat);
5902 
5903  if(!gl2ps || !imagemap) return GL2PS_UNINITIALIZED;
5904 
5905  if((width <= 0) || (height <= 0)) return GL2PS_ERROR;
5906 
5907  size = height + height * ((width - 1) / 8);
5908  glPassThrough(GL2PS_IMAGEMAP_TOKEN);
5909  glBegin(GL_POINTS);
5910  glVertex3f(position[0], position[1],position[2]);
5911  glEnd();
5912  glPassThrough((GLfloat)width);
5913  glPassThrough((GLfloat)height);
5914  for(i = 0; i < size; i += sizeoffloat){
5915  // cppcheck-suppress invalidPointerCast
5916  const float *value = reinterpret_cast<const float*>(imagemap);
5917  glPassThrough(*value);
5918  imagemap += sizeoffloat;
5919  }
5920  return GL2PS_SUCCESS;
5921 }

◆ gl2psDrawPixels()

GL2PSDLL_API GLint gl2psDrawPixels ( GLsizei  width,
GLsizei  height,
GLint  xorig,
GLint  yorig,
GLenum  format,
GLenum  type,
const void *  pixels 
)

Definition at line 5816 of file gl2ps.cxx.

5820 {
5821  int size, i;
5822  GLfloat pos[4], *piv;
5823  GL2PSprimitive *prim;
5824  GLboolean valid;
5825 
5826  if(!gl2ps || !pixels) return GL2PS_UNINITIALIZED;
5827 
5828  if((width <= 0) || (height <= 0)) return GL2PS_ERROR;
5829 
5830  if(gl2ps->options & GL2PS_NO_PIXMAP) return GL2PS_SUCCESS;
5831 
5832  if((format != GL_RGB && format != GL_RGBA) || type != GL_FLOAT){
5833  gl2psMsg(GL2PS_ERROR, "gl2psDrawPixels only implemented for "
5834  "GL_RGB/GL_RGBA, GL_FLOAT pixels");
5835  return GL2PS_ERROR;
5836  }
5837 
5838  glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
5839  if(GL_FALSE == valid) return GL2PS_SUCCESS; /* the primitive is culled */
5840 
5841  glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
5842 
5843  prim = (GL2PSprimitive*)gl2psMalloc(sizeof(GL2PSprimitive));
5844  prim->type = GL2PS_PIXMAP;
5845  prim->boundary = 0;
5846  prim->numverts = 1;
5847  prim->verts = (GL2PSvertex*)gl2psMalloc(sizeof(GL2PSvertex));
5848  prim->verts[0].xyz[0] = pos[0] + xorig;
5849  prim->verts[0].xyz[1] = pos[1] + yorig;
5850  prim->verts[0].xyz[2] = pos[2];
5851  prim->culled = 0;
5852  prim->offset = 0;
5853  prim->pattern = 0;
5854  prim->factor = 0;
5855  prim->width = 1;
5856  glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->verts[0].rgba);
5857  prim->data.image = (GL2PSimage*)gl2psMalloc(sizeof(GL2PSimage));
5858  prim->data.image->width = width;
5859  prim->data.image->height = height;
5860  prim->data.image->format = format;
5861  prim->data.image->type = type;
5862 
5863  switch(format){
5864  case GL_RGBA:
5865  if(gl2ps->options & GL2PS_NO_BLENDING || !gl2ps->blending){
5866  /* special case: blending turned off */
5867  prim->data.image->format = GL_RGB;
5868  size = height * width * 3;
5869  prim->data.image->pixels = (GLfloat*)gl2psMalloc(size * sizeof(GLfloat));
5870  piv = (GLfloat*)pixels;
5871  for(i = 0; i < size; ++i, ++piv){
5872  prim->data.image->pixels[i] = *piv;
5873  if(!((i+1)%3))
5874  ++piv;
5875  }
5876  }
5877  else{
5878  size = height * width * 4;
5879  prim->data.image->pixels = (GLfloat*)gl2psMalloc(size * sizeof(GLfloat));
5880  memcpy(prim->data.image->pixels, pixels, size * sizeof(GLfloat));
5881  }
5882  break;
5883  case GL_RGB:
5884  default:
5885  size = height * width * 3;
5886  prim->data.image->pixels = (GLfloat*)gl2psMalloc(size * sizeof(GLfloat));
5887  memcpy(prim->data.image->pixels, pixels, size * sizeof(GLfloat));
5888  break;
5889  }
5890 
5891  gl2psListAdd(gl2ps->auxprimitives, &prim);
5892  glPassThrough(GL2PS_DRAW_PIXELS_TOKEN);
5893 
5894  return GL2PS_SUCCESS;
5895 }

◆ gl2psEnable()

GL2PSDLL_API GLint gl2psEnable ( GLint  mode)

Definition at line 5923 of file gl2ps.cxx.

5924 {
5925  GLint tmp;
5926 
5927  if(!gl2ps) return GL2PS_UNINITIALIZED;
5928 
5929  switch(mode){
5931  glPassThrough(GL2PS_BEGIN_OFFSET_TOKEN);
5932  glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &gl2ps->offset[0]);
5933  glGetFloatv(GL_POLYGON_OFFSET_UNITS, &gl2ps->offset[1]);
5934  break;
5935  case GL2PS_POLYGON_BOUNDARY :
5936  glPassThrough(GL2PS_BEGIN_BOUNDARY_TOKEN);
5937  break;
5938  case GL2PS_LINE_STIPPLE :
5939  glPassThrough(GL2PS_BEGIN_STIPPLE_TOKEN);
5940  glGetIntegerv(GL_LINE_STIPPLE_PATTERN, &tmp);
5941  glPassThrough((GLfloat)tmp);
5942  glGetIntegerv(GL_LINE_STIPPLE_REPEAT, &tmp);
5943  glPassThrough((GLfloat)tmp);
5944  break;
5945  case GL2PS_BLEND :
5946  glPassThrough(GL2PS_BEGIN_BLEND_TOKEN);
5947  break;
5948  default :
5949  gl2psMsg(GL2PS_WARNING, "Unknown mode in gl2psEnable: %d", mode);
5950  return GL2PS_WARNING;
5951  }
5952 
5953  return GL2PS_SUCCESS;
5954 }

◆ gl2psEndPage()

GL2PSDLL_API GLint gl2psEndPage ( void  )

Definition at line 5750 of file gl2ps.cxx.

5751 {
5752  GLint res;
5753 
5754  if(!gl2ps) return GL2PS_UNINITIALIZED;
5755 
5756  res = gl2psPrintPrimitives();
5757 
5758  if(res != GL2PS_OVERFLOW)
5759  (gl2psbackends[gl2ps->format]->printFooter)();
5760 
5761  fflush(gl2ps->stream);
5762 
5763  gl2psListDelete(gl2ps->primitives);
5764  gl2psListDelete(gl2ps->auxprimitives);
5765  gl2psFreeImagemap(gl2ps->imagemap_head);
5766  gl2psFree(gl2ps->colormap);
5767  gl2psFree(gl2ps->title);
5768  gl2psFree(gl2ps->producer);
5769  gl2psFree(gl2ps->filename);
5770  gl2psFree(gl2ps->feedback);
5771  gl2psFree(gl2ps);
5772  gl2ps = NULL;
5773 
5774  return res;
5775 }

◆ gl2psEndViewport()

GL2PSDLL_API GLint gl2psEndViewport ( void  )

Definition at line 5786 of file gl2ps.cxx.

5787 {
5788  GLint res;
5789 
5790  if(!gl2ps) return GL2PS_UNINITIALIZED;
5791 
5792  res = (gl2psbackends[gl2ps->format]->endViewport)();
5793 
5794  /* reset last used colors, line widths */
5795  gl2ps->lastlinewidth = -1.0F;
5796 
5797  return res;
5798 }

◆ gl2psGetFileExtension()

GL2PSDLL_API const char* gl2psGetFileExtension ( GLint  format)

Definition at line 6037 of file gl2ps.cxx.

6038 {
6039  if(format >= 0 && format < (GLint)(sizeof(gl2psbackends) / sizeof(gl2psbackends[0])))
6040  return gl2psbackends[format]->file_extension;
6041  else
6042  return "Unknown format";
6043 }

◆ gl2psGetFormatDescription()

GL2PSDLL_API const char* gl2psGetFormatDescription ( GLint  format)

Definition at line 6045 of file gl2ps.cxx.

6046 {
6047  if(format >= 0 && format < (GLint)(sizeof(gl2psbackends) / sizeof(gl2psbackends[0])))
6048  return gl2psbackends[format]->description;
6049  else
6050  return "Unknown format";
6051 }

◆ gl2psGetOptions()

GL2PSDLL_API GLint gl2psGetOptions ( GLint *  options)

Definition at line 6025 of file gl2ps.cxx.

6026 {
6027  if(!gl2ps) {
6028  *options = 0;
6029  return GL2PS_UNINITIALIZED;
6030  }
6031 
6032  *options = gl2ps->options;
6033 
6034  return GL2PS_SUCCESS;
6035 }

◆ gl2psLineWidth()

GL2PSDLL_API GLint gl2psLineWidth ( GLfloat  value)

Definition at line 5991 of file gl2ps.cxx.

5992 {
5993  if(!gl2ps) return GL2PS_UNINITIALIZED;
5994 
5995  glPassThrough(GL2PS_LINE_WIDTH_TOKEN);
5996  glPassThrough(value);
5997 
5998  return GL2PS_SUCCESS;
5999 }

◆ gl2psPointSize()

GL2PSDLL_API GLint gl2psPointSize ( GLfloat  value)

Definition at line 5981 of file gl2ps.cxx.

5982 {
5983  if(!gl2ps) return GL2PS_UNINITIALIZED;
5984 
5985  glPassThrough(GL2PS_POINT_SIZE_TOKEN);
5986  glPassThrough(value);
5987 
5988  return GL2PS_SUCCESS;
5989 }

◆ gl2psSetOptions()

GL2PSDLL_API GLint gl2psSetOptions ( GLint  options)

Definition at line 6016 of file gl2ps.cxx.

6017 {
6018  if(!gl2ps) return GL2PS_UNINITIALIZED;
6019 
6020  gl2ps->options = options;
6021 
6022  return GL2PS_SUCCESS;
6023 }

◆ gl2psSpecial()

GL2PSDLL_API GLint gl2psSpecial ( GLint  format,
const char *  str 
)

Definition at line 5811 of file gl2ps.cxx.

5812 {
5813  return gl2psAddText(GL2PS_SPECIAL, str, "", 0, format, 0.0F);
5814 }

◆ gl2psText()

GL2PSDLL_API GLint gl2psText ( const char *  str,
const char *  fontname,
GLshort  fontsize 
)

Definition at line 5806 of file gl2ps.cxx.

5807 {
5808  return gl2psAddText(GL2PS_TEXT, str, fontname, fontsize, GL2PS_TEXT_BL, 0.0F);
5809 }

◆ gl2psTextOpt()

GL2PSDLL_API GLint gl2psTextOpt ( const char *  str,
const char *  fontname,
GLshort  fontsize,
GLint  alignment,
GLfloat  angle 
)

Definition at line 5800 of file gl2ps.cxx.

5802 {
5803  return gl2psAddText(GL2PS_TEXT, str, fontname, fontsize, alignment, angle);
5804 }
GL2PS_DRAW_PIXELS_TOKEN
#define GL2PS_DRAW_PIXELS_TOKEN
Definition: gl2ps.cxx:114
GL2PS_BLEND
#define GL2PS_BLEND
Definition: gl2ps.h:139
GL2PScontext::bgcolor
GL2PSrgba bgcolor
Definition: gl2ps.cxx:219
GL2PScontext::imagetree
GL2PSbsptree2d * imagetree
Definition: gl2ps.cxx:232
GL2PScontext::pdfprimlist
GL2PSlist * pdfprimlist
Definition: gl2ps.cxx:237
GL2PS_LINE_WIDTH_TOKEN
#define GL2PS_LINE_WIDTH_TOKEN
Definition: gl2ps.cxx:108
GL2PS_ERROR
#define GL2PS_ERROR
Definition: gl2ps.h:112
GL2PScontext::imagemap_tail
GL2PSimagemap * imagemap_tail
Definition: gl2ps.cxx:249
vtune_athena.format
format
Definition: vtune_athena.py:14
GL2PS_DST_BLEND_TOKEN
#define GL2PS_DST_BLEND_TOKEN
Definition: gl2ps.cxx:112
GL2PScontext::colormode
GLint colormode
Definition: gl2ps.cxx:214
GL2PScontext::lastpattern
GLushort lastpattern
Definition: gl2ps.cxx:220
T_CONST_COLOR
@ T_CONST_COLOR
Definition: gl2ps.cxx:119
GL2PS_SUCCESS
#define GL2PS_SUCCESS
Definition: gl2ps.h:109
index
Definition: index.py:1
GL2PSbackend::description
const char * description
Definition: gl2ps.cxx:260
GL2PSbackend::printFooter
void(* printFooter)(void)
Definition: gl2ps.cxx:254
GL2PScontext::options
GLint options
Definition: gl2ps.cxx:214
GL2PS_SPECIAL
#define GL2PS_SPECIAL
Definition: gl2ps.cxx:84
GL2PS_TEXT_BL
#define GL2PS_TEXT_BL
Definition: gl2ps.h:151
GL2PScontext::blending
GLboolean blending
Definition: gl2ps.cxx:216
GL2PS_PIXMAP
#define GL2PS_PIXMAP
Definition: gl2ps.cxx:80
GL2PScontext::header
GLboolean header
Definition: gl2ps.cxx:225
GL2PScontext::stream
FILE * stream
Definition: gl2ps.cxx:223
GL2PSprimitive::image
GL2PSimage * image
Definition: gl2ps.cxx:193
athena.value
value
Definition: athena.py:122
GL2PS_TRIANGLE_PROPERTY
GL2PS_TRIANGLE_PROPERTY
Definition: gl2ps.cxx:117
GL2PSimage::height
GLsizei height
Definition: gl2ps.cxx:169
GL2PSprimitive::data
union GL2PSprimitive::@62 data
GL2PSrgba
GLfloat GL2PSrgba[4]
Definition: gl2ps.h:157
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
GL2PSbackend::endViewport
GLint(* endViewport)(void)
Definition: gl2ps.cxx:256
GL2PScontext::pdfgrouplist
GL2PSlist * pdfgrouplist
Definition: gl2ps.cxx:237
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
GL2PS_TEXT
#define GL2PS_TEXT
Definition: gl2ps.cxx:75
GL2PSprimitive::boundary
char boundary
Definition: gl2ps.cxx:187
GL2PScontext::title
char * title
Definition: gl2ps.cxx:215
GL2PScontext::sort
GLint sort
Definition: gl2ps.cxx:214
GL2PSprimitive::verts
GL2PSvertex * verts
Definition: gl2ps.cxx:190
GL2PS_WARNING
#define GL2PS_WARNING
Definition: gl2ps.h:111
GL2PScontext::feedback
GLfloat * feedback
Definition: gl2ps.cxx:217
GL2PSprimitive::type
GLshort type
Definition: gl2ps.cxx:185
GL2PScontext::lastrgba
GL2PSrgba lastrgba
Definition: gl2ps.cxx:219
GL2PSbackend::beginViewport
void(* beginViewport)(GLint viewport[4])
Definition: gl2ps.cxx:255
GL2PScontext::lastfactor
GLint lastfactor
Definition: gl2ps.cxx:218
GL2PS_BEGIN_BOUNDARY_TOKEN
#define GL2PS_BEGIN_BOUNDARY_TOKEN
Definition: gl2ps.cxx:103
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GL2PS_NO_SORT
#define GL2PS_NO_SORT
Definition: gl2ps.h:103
calibdata.valid
list valid
Definition: calibdata.py:45
GL2PS_NO_BLENDING
#define GL2PS_NO_BLENDING
Definition: gl2ps.h:131
GL2PSprimitive::culled
char culled
Definition: gl2ps.cxx:187
GL2PSimage::format
GLenum format
Definition: gl2ps.cxx:173
GL2PScontext::maxbestroot
GLint maxbestroot
Definition: gl2ps.cxx:228
T_VAR_ALPHA
@ T_VAR_ALPHA
Definition: gl2ps.cxx:123
GL2PScontext::compress
GL2PScompress * compress
Definition: gl2ps.cxx:224
lumiFormat.i
int i
Definition: lumiFormat.py:92
GL2PS_SVG
#define GL2PS_SVG
Definition: gl2ps.h:98
GL2PScontext::xreflist
int * xreflist
Definition: gl2ps.cxx:238
GL2PSvertex
Definition: gl2ps.cxx:149
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
GL2PS_OVERFLOW
#define GL2PS_OVERFLOW
Definition: gl2ps.h:114
GL2PScontext::format
GLint format
Definition: gl2ps.cxx:214
T_ALPHA_LESS_1
@ T_ALPHA_LESS_1
Definition: gl2ps.cxx:122
GL2PScontext::buffersize
GLint buffersize
Definition: gl2ps.cxx:214
covarianceTool.title
title
Definition: covarianceTool.py:542
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
GL2PScontext::blendfunc
GLint blendfunc[2]
Definition: gl2ps.cxx:218
GL2PS_END_BOUNDARY_TOKEN
#define GL2PS_END_BOUNDARY_TOKEN
Definition: gl2ps.cxx:104
GL2PS_BEGIN_STIPPLE_TOKEN
#define GL2PS_BEGIN_STIPPLE_TOKEN
Definition: gl2ps.cxx:105
GL2PScontext::lastlinewidth
GLfloat lastlinewidth
Definition: gl2ps.cxx:217
Preparation.mode
mode
Definition: Preparation.py:95
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
GL2PS_BEGIN_OFFSET_TOKEN
#define GL2PS_BEGIN_OFFSET_TOKEN
Definition: gl2ps.cxx:101
GL2PScontext::auxprimitives
GL2PSlist * auxprimitives
Definition: gl2ps.cxx:222
SG::ArenaBlockAlignDetail::alignment
constexpr size_t alignment
Definition: ArenaBlockAlignDetail.h:39
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
GL2PSimage
Definition: gl2ps.cxx:168
GL2PS_LINE_STIPPLE
#define GL2PS_LINE_STIPPLE
Definition: gl2ps.h:138
T_VAR_COLOR
@ T_VAR_COLOR
Definition: gl2ps.cxx:120
T_UNDEFINED
@ T_UNDEFINED
Definition: gl2ps.cxx:118
GL2PScontext::producer
char * producer
Definition: gl2ps.cxx:215
GL2PScontext::offset
GLfloat offset[2]
Definition: gl2ps.cxx:217
GL2PScontext::colormap
GL2PSrgba * colormap
Definition: gl2ps.cxx:219
T_ALPHA_1
@ T_ALPHA_1
Definition: gl2ps.cxx:121
GL2PS_NO_PIXMAP
#define GL2PS_NO_PIXMAP
Definition: gl2ps.h:128
GL2PS_BEGIN_BLEND_TOKEN
#define GL2PS_BEGIN_BLEND_TOKEN
Definition: gl2ps.cxx:109
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
GL2PSprimitive::offset
char offset
Definition: gl2ps.cxx:187
GL2PS_POINT_SIZE_TOKEN
#define GL2PS_POINT_SIZE_TOKEN
Definition: gl2ps.cxx:107
GL2PScontext
Definition: gl2ps.cxx:212
GL2PScontext::lastvertex
GL2PSvertex lastvertex
Definition: gl2ps.cxx:221
GL2PS_END_STIPPLE_TOKEN
#define GL2PS_END_STIPPLE_TOKEN
Definition: gl2ps.cxx:106
DeMoScan.index
string index
Definition: DeMoScan.py:362
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
GL2PS_SIMPLE_SORT
#define GL2PS_SIMPLE_SORT
Definition: gl2ps.h:104
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
F
#define F(x, y, z)
Definition: MD5.cxx:112
GL2PSprimitive::factor
GLint factor
Definition: gl2ps.cxx:188
GL2PS_POLYGON_BOUNDARY
#define GL2PS_POLYGON_BOUNDARY
Definition: gl2ps.h:137
GL2PSimage::width
GLsizei width
Definition: gl2ps.cxx:169
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
GL2PS_BSP_SORT
#define GL2PS_BSP_SORT
Definition: gl2ps.h:105
GL2PSvertex::xyz
GL2PSxyz xyz
Definition: gl2ps.cxx:150
GL2PS_SRC_BLEND_TOKEN
#define GL2PS_SRC_BLEND_TOKEN
Definition: gl2ps.cxx:111
GL2PS_IMAGEMAP_TOKEN
#define GL2PS_IMAGEMAP_TOKEN
Definition: gl2ps.cxx:113
str
Definition: BTagTrackIpAccessor.cxx:11
GL2PS_UNINITIALIZED
#define GL2PS_UNINITIALIZED
Definition: gl2ps.h:115
GL2PSimage::pixels
GLfloat * pixels
Definition: gl2ps.cxx:174
GL2PS_END_OFFSET_TOKEN
#define GL2PS_END_OFFSET_TOKEN
Definition: gl2ps.cxx:102
GL2PScontext::threshold
GL2PSrgba threshold
Definition: gl2ps.cxx:219
GL2PSimage::type
GLenum type
Definition: gl2ps.cxx:173
GL2PSbackend::file_extension
const char * file_extension
Definition: gl2ps.cxx:259
GL2PS_USE_CURRENT_VIEWPORT
#define GL2PS_USE_CURRENT_VIEWPORT
Definition: gl2ps.h:129
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
GL2PSprimitive
Definition: gl2ps.cxx:184
GL2PS_END_BLEND_TOKEN
#define GL2PS_END_BLEND_TOKEN
Definition: gl2ps.cxx:110
GL2PScontext::primitivetoadd
GL2PSprimitive * primitivetoadd
Definition: gl2ps.cxx:233
GL2PScontext::zerosurfacearea
GLboolean zerosurfacearea
Definition: gl2ps.cxx:231
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
GL2PScontext::filename
char * filename
Definition: gl2ps.cxx:215
GL2PScontext::imagemap_head
GL2PSimagemap * imagemap_head
Definition: gl2ps.cxx:248
GL2PSprimitive::numverts
GLshort numverts
Definition: gl2ps.cxx:185
GL2PScontext::colorsize
GLint colorsize
Definition: gl2ps.cxx:214
ReadFromCoolCompare.ng
ng
Definition: ReadFromCoolCompare.py:234
GL2PSprimitive::pattern
GLushort pattern
Definition: gl2ps.cxx:186
GL2PS_POLYGON_OFFSET_FILL
#define GL2PS_POLYGON_OFFSET_FILL
Definition: gl2ps.h:136
GL2PScontext::primitives
GL2PSlist * primitives
Definition: gl2ps.cxx:222
GL2PSprimitive::width
GLfloat width
Definition: gl2ps.cxx:189
GL2PScontext::viewport
GLint viewport[4]
Definition: gl2ps.cxx:218
GL2PSvertex::rgba
GL2PSrgba rgba
Definition: gl2ps.cxx:151