Advertisement

Line drawing algorithms.....

Started by November 07, 2000 05:52 AM
2 comments, last by Quantum 24 years, 2 months ago
Does anyone have a working line drawing algorithm handy? GDI is sooo slow, and I cant get the one Lamothe provides in WGPFD to work propley... I think it has something to do with the surface pitch... and it doesn''t even look very good. I''m just attempting to write a simple wireframe 3d engine using DDraw . Thanks...
quote: Original post by Quantum

Does anyone have a working line drawing algorithm handy? GDI is sooo slow, and I cant get the one Lamothe provides in WGPFD to work propley... I think it has something to do with the surface pitch... and it doesn''t even look very good. I''m just attempting to write a simple wireframe 3d engine using DDraw .

Thanks...


    void line(int x, int y, int x2, int y2) {float step = ((float)(x2-x+1))/((float)(y2-y+1)); float fx= (float)x;for (; y<=y2; y++) {plotpixel((int)fx, y);fx+=step;}}    
cmaker- I do not make clones.
Advertisement
With VERY little effort, one could get the above algo working with >> floating points << to make it a hellofalot faster .
"a low level aho master like you couldn't kill me even if I let you"
Get yourself a copy of virtually any book on graphics algorithms and look up Bresenham in the index. That''s what you want to use.

I really wonder if you''re going to be able to beat GDI though. Have you tried using Polyline or PolyPolyline? They are lots faster then drawing lines one at a time.

-Mike

This topic is closed to new replies.

Advertisement