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…