Jump to content
  • Advertisement

Archived

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

Michalson

Drawing fat lines in DirectDraw

This topic is 6056 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
Advertisement
The lines need to be from any point P1 to any other point P2, they are normally not going to be perfectly vertical or horizontal.

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)
{
HDC hDC;
HPEN Pen;
HGDIOBJ Obj;
HRESULT hr;

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

Pen = CreatePen(PS_SOLID,thickness,colour);
Obj = SelectObject(hDC,Pen);
MoveToEx(hDC,x1,y1,NULL);
LineTo(hDC,x2,y2);
DeleteObject(Obj);

lpdds->ReleaseDC(hDC);

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!