Draw a line from point a to point b
How would I tell OpenGL to start draw at point a(x, y, z) and end the line at point b(x, y, z). So for example the line would start at (1, 0, 0) and end at (0, 2, -3)
thx
nuke
yep... and you can change it's thickness by going:
glLineWidth(width); //1.0f is defalt
-PmanC
lol... i've been programming too much... i just commented instead of writing a sentence.
[edited by - PmanC on June 4, 2002 10:23:24 PM]
glLineWidth(width); //1.0f is defalt
-PmanC
lol... i've been programming too much... i just commented instead of writing a sentence.
[edited by - PmanC on June 4, 2002 10:23:24 PM]
and if you didnt know you can also use simple bresenham to draw lines (no 3d you requested sorry this time pal)
dx=x1-x0; dy=y1-y0; if (dx>0) { sx=1; } else if (dx<0) { sx=-1; dx=-dx; } else { sx =0; } if (dy>0) { sy=1; } else if (dy<0) { sy=-1; dy=-dy; } else { sy =0; } int ax =2*dx; int ay =2*dy; if (dy<=dx) { for (int decy=ay-dx; /**/;x +=sx, decy+=ay) { draw pixel (x, y) /* take bresenham step */ if (x==x1) { break; } if (decy>=0) { decy -=ax; y +=sy; } } } else { for (int decx=ax-dy; /**/; y+=sy, decx +=ax) {draw pixel (x, y) /* take bresenham step */ if (y==y1) { break; } if (decx>=0) { decx -=ay; x +=sx; } } }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement