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 5582 of file gl2ps.cxx.

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

◆ gl2psBeginViewport()

GL2PSDLL_API GLint gl2psBeginViewport ( GLint  viewport[4])

Definition at line 5776 of file gl2ps.cxx.

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

◆ gl2psBlendFunc()

GL2PSDLL_API GLint gl2psBlendFunc ( GLenum  sfactor,
GLenum  dfactor 
)

Definition at line 6000 of file gl2ps.cxx.

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

◆ gl2psDisable()

GL2PSDLL_API GLint gl2psDisable ( GLint  mode)

Definition at line 5955 of file gl2ps.cxx.

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

◆ gl2psDrawImageMap()

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

Definition at line 5896 of file gl2ps.cxx.

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

◆ gl2psDrawPixels()

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

Definition at line 5815 of file gl2ps.cxx.

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

◆ gl2psEnable()

GL2PSDLL_API GLint gl2psEnable ( GLint  mode)

Definition at line 5922 of file gl2ps.cxx.

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

◆ gl2psEndPage()

GL2PSDLL_API GLint gl2psEndPage ( void  )

Definition at line 5749 of file gl2ps.cxx.

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

◆ gl2psEndViewport()

GL2PSDLL_API GLint gl2psEndViewport ( void  )

Definition at line 5785 of file gl2ps.cxx.

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

◆ gl2psGetFileExtension()

GL2PSDLL_API const char* gl2psGetFileExtension ( GLint  format)

Definition at line 6036 of file gl2ps.cxx.

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

◆ gl2psGetFormatDescription()

GL2PSDLL_API const char* gl2psGetFormatDescription ( GLint  format)

Definition at line 6044 of file gl2ps.cxx.

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

◆ gl2psGetOptions()

GL2PSDLL_API GLint gl2psGetOptions ( GLint *  options)

Definition at line 6024 of file gl2ps.cxx.

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

◆ gl2psLineWidth()

GL2PSDLL_API GLint gl2psLineWidth ( GLfloat  value)

Definition at line 5990 of file gl2ps.cxx.

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

◆ gl2psPointSize()

GL2PSDLL_API GLint gl2psPointSize ( GLfloat  value)

Definition at line 5980 of file gl2ps.cxx.

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

◆ gl2psSetOptions()

GL2PSDLL_API GLint gl2psSetOptions ( GLint  options)

Definition at line 6015 of file gl2ps.cxx.

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

◆ gl2psSpecial()

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

Definition at line 5810 of file gl2ps.cxx.

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

◆ gl2psText()

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

Definition at line 5805 of file gl2ps.cxx.

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

◆ gl2psTextOpt()

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

Definition at line 5799 of file gl2ps.cxx.

5801 {
5802  return gl2psAddText(GL2PS_TEXT, str, fontname, fontsize, alignment, angle);
5803 }
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:124
GL2PS_TRIANGLE_PROPERTY
GL2PS_TRIANGLE_PROPERTY
Definition: gl2ps.cxx:117
GL2PSimage::height
GLsizei height
Definition: gl2ps.cxx:169
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:85
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
GL2PSprimitive::data
union GL2PSprimitive::@64 data
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:94
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:364
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