This topic is now archived and is closed to further replies.

Drawing fat lines in DirectDraw

This topic is 5780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m looking to draw thick rounded lines (Go into mspaint, select the line tool and choose the thickest line to see what i mean). The parameters are start and end coordinates, color and thickness (expressed as the radius of the line). At the moment I have engine class that draws them using circle sprites (Just blitting the same sprite from start to end coordinates). The sprites are the color and radius (thickness) of the line and are stored in a cache. At the moment it is quite fast (running on an Athlon 1200, 32mb All-In-Wonder AGP Pro 128) but I''m wondering if there is a faster method without using Direct3D.

Share this post

Link to post
Share on other sites
if the circles'' radii == width of the polygon "line" mentioned above, they will match the corners perfectly (assuming the circle''s center is at the middle of the short edges)...

Share this post

Link to post
Share on other sites
Get a handle to the DC, lock the surface, and the use the GDI line drawing functions. I''m not sure, but I think you''d use a combination of CreatePen, SelectObject, MoveToEx, LineTo, and DeleteObject.

Share this post

Link to post
Share on other sites
I wrote and tested this function based on what TerranFury wrote,
with the exception that you don't lock the surface.

BOOL DrawLine(int x1,int y1,int x2,int y2,int thickness,DWORD colour,LPDIRECTDRAWSURFACE7 lpdds)

if (FAILED(hr = lpdds->GetDC(&hDC)))
return FALSE;

Pen = CreatePen(PS_SOLID,thickness,colour);
Obj = SelectObject(hDC,Pen);


return TRUE;

Edited by - SpazBoy the Mitey on February 19, 2002 8:57:29 PM

Share this post

Link to post
Share on other sites