How Do You Draw A Line With Direct Draw?

Is there a Direct Draw or DirectX function to allow you to draw a line on the back buffer?  I couldn’t find one so I’m currently using the LineTo() GDI function to draw straight on the screen.  If there isn’t a function available can you use LineTo() to draw on the back buffer?  If not is there another way of doing it.

Thanks a lot for your help
Who is Participating?
mh2Connect With a Mentor Commented:

I have not worked with DirectX since 7, but I know in these versions there were no routines for plotting primitives like lines or circles, DirectDraw was basically a bitmap blitter.

I rarely need to draw lines, but I know of only 2 ways:
1. Use GDI like you are now
2. Lock the surface and use an algorithm such as Bresenhams to plot you pixels into your surface buffer.

As far as I know, DX 8 has know combined DirectDraw and Direct3D, so you may be able to draw lines using the 3D pimitives linking vertexts ( like a one-line wireframe ). This would probably mean requiring some form of 3D hardware, way overkill if your app does not require this ( the increased compatibility problems and raised hardware requirments will not be worth the develpment time saved ).

What version of directX are you using and what language?
Plague1392Author Commented:
Ooops, Sorry about that.  I'm using C and DirectX 8, but the book I'm reading is actually based on version 6 so a lot of what I'm using is probably more version 6.  I've been using the latest version of the DirectX data types though, e.g. LPDIRECTDRAW7, LPDIRECTDRAWSURFACE7 etc.  
I draw my lines and other curves by using algorithms and plotting individual pixels.

Plague1392Author Commented:
Thanks for the help and for naming an algorithm.  I'd been searching for an appropriate algorithm but couldn't find one.
All Courses

From novice to tech pro — start learning today.