[gl2ps] Artifacts generated by GL2PS_OCCLUSION_CULL option, and empty LaTeX output

Olumide 50295 at web.de
Sun Oct 26 02:26:01 CET 2008


Hello -

I'm a new GL2PS user, and I've got two questions regarding the utility:

1. I've noticed that the GL2PS_OCCLUSION_CULL option appears to generate 
unwanted artifacts in the form of a mesh edges in the PS and EPS 
outputs, although no such mesh edge display option was enabled (I need 
to use the GL2PS_OCCLUSION_CULL option in order to cut down the number 
of faces in my out put file). I've include below a sample C source file 
that produces this artifact. What can I do to avoid this problem (its a 
slimmer version of gl2psSimpleTest).

2. The LaTeX output option produces no drawing code, just a file 
containing something like this:

\setlength{\unitlength}{1pt}
\begin{picture}(0,0)
\includegraphics{filename}
\end{picture}%
\begin{picture}(400,323)(0,0)
\end{picture}

Is this how its supposed to work?

Thanks,

- Olumide


/*****************************************************************/

#ifdef __APPLE__
#  include <GLUT/glut.h>
#else
#  include <GL/glut.h>
#endif

#include <string.h>
#include "gl2ps.h"

void display(void){
   unsigned int i;
   int N = 50;
   char *help = "Press 's' to save image or 'q' to quit";

   glClearColor(0.3, 0.5, 0.8, 0.);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   /* draw a smooth-shaded torus */
   glPushMatrix();
   glRotatef(-60., 2., 0., 1.);
   glEnable(GL_LIGHTING);
   /* glutSolidTorus(0.3, 0.6, 30, 30); */
   glutSolidTeapot(0.7);
   glDisable(GL_LIGHTING);
   glPopMatrix();

   glFlush();
}

void keyboard(unsigned char key, int x, int y){
   FILE *fp;
   int state = GL2PS_OVERFLOW, buffsize = 0;

   switch(key){
   case 'q':
     exit(0);
     break;
   case 's':
     fp = fopen("demo.eps", "w");
     printf("Writing file ... ");
     while(state == GL2PS_OVERFLOW){
       buffsize += 1024*1024;
	gl2psEnable( GL2PS_POLYGON_OFFSET_FILL );
       gl2psBeginPage("demo", "demo", NULL, GL2PS_EPS, GL2PS_BSP_SORT,
                      GL2PS_USE_CURRENT_VIEWPORT | 
GL2PS_TIGHT_BOUNDING_BOX | GL2PS_OCCLUSION_CULL , /*  */
                      GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "demo.eps");
       display();
       state = gl2psEndPage();
     }
     fclose(fp);
     printf("Done!\n");
     break;
   }
}

int main(int argc, char **argv){
   GLfloat pos[4]={1.,1.,-1.,0.};

   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DEPTH);
   glutInitWindowSize(400, 400);
   glutInitWindowPosition(200, 200);
   glutCreateWindow(argv[0]);

   glEnable(GL_DEPTH_TEST);
   glDepthFunc(GL_LESS);
   glShadeModel(GL_SMOOTH);
   glEnable(GL_LIGHT0);
   glLightfv(GL_LIGHT0, GL_POSITION, pos);

   glutDisplayFunc(display);
   glutKeyboardFunc(keyboard);
   glutMainLoop();
   return 0;
}