dotdot line

Eloo everyone…

just need help how to draw a line like this using this bresenham method…

1st line—> - - - - - - -
2nd line—> …

this line I’m using to draw a straight line…the problem only how to alter this code to draw a line I just mention

 
void bresLine(int aX, int aY, int bX, int bY) {
      int dX = abs(bX - aX);
      int dY = abs(bY - aY);
	 
      
      int CurrentX = aX;
      int CurrentY = aY;
      
      int Xincr, Yincr;
      if (aX > bX) { Xincr=-1; } else { Xincr=1; }      
      if (aY > bY) { Yincr=-1; } else { Yincr=1; }      
      
    glBegin(GL_POINTS);
      if (dX >= dY) {  
            int dPr       = dY<<1;                                       
            int dPru       = dPr - (dX<<1);                        
            int P             = dPr - dX;                                    

            for (; dX >= 0; dX--) {                                    
            glVertex2i(CurrentX, CurrentY);         
                  if (P > 0) {                            
                        CurrentX += Xincr;                              
                        CurrentY += Yincr;                               
                        P += dPru;                                          
                  }
                  else {                                                      
                        CurrentX += Xincr;                              
                        P += dPr;                                          
                  }
            }            
      }
      else {                  
            int dPr       = dX<<1;                                       
            int dPru       = dPr - (dY<<1);                           
            int P             = dPr - dY;                                    

            for (; dY >= 0; dY--) {                                    
            glVertex2i(CurrentX, CurrentY);         
                  if (P > 0) {                            
                        CurrentX += Xincr;                               
                        CurrentY += Yincr;                              
                        P += dPru;                                          
                  }
                  else {                                                      
                        CurrentY += Yincr;                              
                        P += dPr;                                          
                  }
            }            
      }            
    glEnd();
}
 

any guide or walkthrough would be great…

tq…

Let me guess… this would be an assignment?

Each iteration of your loop is plotting the next rastered pixel of the line you want to draw. The pixel is only sent to the graphics pipe with the glVertex() call (which assembles these vertices into points with your glBegin(GL_POINTS)), hence to get ###_… effect (where _=missing pixel), you DON’T send a vertex to OpenGL every second iteration of your loop. This technique can, of course, be extended to any arbitary long line-stipple bitstring .

cheers
John