Hi everybody,

I attached a test program, which shows a problem in line stippling with
long line strips/loops.

All lines should have the same stipple, but the last ones don't.

The bug is in render_vb_line_strip(), render_vb_line_loop() and friends 
(render_tmp.h, somewhere around line 80). VB->ctx->StippleCounter is set
zero, even we don't know here, if render_vb_line_strip() was called
because of a vertex buffer flush or a glEnd(). The stipple counter should
only be reset at glEnd() for line strips and loops.

- Holger
#include <GL/glut.h>



void display(void)
{
   float x;

   glClear (GL_COLOR_BUFFER_BIT);

   glEnable (GL_LINE_STIPPLE);
   
   glLineStipple (1, 0x00FF);  /*  dashed  */

   glBegin (GL_LINE_STRIP);
   glVertex2f (0.0, 1.0);
   glVertex2f (1.0, 1.0);
   glEnd ();

   glBegin (GL_LINE_STRIP);
   for (x=0.0; x<1.0; x+=0.1) {
      glVertex2f (x, 0.75);
      glVertex2f (x+0.1, 0.75);
   }
   glEnd ();

   glBegin (GL_LINE_STRIP);
   for (x=0.0; x<1.0; x+=0.01) {
      glVertex2f (x, 0.5);
      glVertex2f (x+0.01, 0.5);
   }
   glEnd ();

   glBegin (GL_LINE_STRIP);
   for (x=0.0; x<1.0; x+=0.001) {
      glVertex2f (x, 0.25);
      glVertex2f (x+0.001, 0.25);
   }
   glEnd ();

   glBegin (GL_LINE_STRIP);
   for (x=0.0; x<1.0; x+=0.0005) {
      glVertex2f (x, 0.125);
      glVertex2f (x+0.0005, 0.125);
   }
   glEnd ();

   glBegin (GL_LINE_STRIP);
   for (x=0.0; x<1.0; x+=0.0001) {
      glVertex2f (x, 0.0);
      glVertex2f (x+0.0001, 0.0);
   }
   glEnd ();

   glFlush ();
}

void reshape (int w, int h)
{
   glViewport (0, 0, (GLsizei) w, (GLsizei) h);
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   gluOrtho2D (-0.2, 1.2, -0.2, 1.2);
   glMatrixMode (GL_MODELVIEW);
}

/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
{
   switch (key) {
      case 27:
         exit(0);
         break;
   }
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (400, 400); 
   glutCreateWindow (argv[0]);
   glutDisplayFunc(display); 
   glutReshapeFunc(reshape);
   glutKeyboardFunc(keyboard);
   glutMainLoop();
   return 0;
}

Reply via email to