Re: Drawing polygon

From: Fabian Schmied (REMOVETHISfabianDOTschmied_at_fhs-hagenbergDOTacDOTat)
Date: 05/13/04


Date: Thu, 13 May 2004 15:56:52 +0200

maka3 schrieb:
> Hi,
> What's the best way to draw a polygon with 4 corners in directdraw?
> I only see a DrawBox or DrawRectangle function. I've tried this gdi
> approach but it slows down the app.
> IntPtr dc=surface.GetDc();
> Graphics g=Graphics.FromHdc(dc);
> g.DrawPolygon(...);
> surface.Release(dc);

This is a GDI+ approach. It might be faster to p/invoke the GDI
function Polyline, but it's still GDI and not DirectDraw. You can't use
DirectDraw to efficiently draw lines (although there is a DrawLine
method, but it uses GDI) unless you lock the surface and implement a
Bresenham line drawing algorithm or something yourself (which is
difficult in managed DirectX bacause of Lock bugs).

BTW: You need to dispose of the Graphics object before you release the DC.

Fabian



Relevant Pages

  • Re: DirectDraw CE6.0
    ... DDraw has primitives that are similar to what the hardware supports, ... you'll need to use the GDI ... the ability to select surfaces in hardware for page flipping etc if the ... device context to the DirectDraw Surface. ...
    (microsoft.public.windowsce.embedded)
  • Re: How do I make a brush paint tool in Direct3D (Or DirectDraw)
    ... Just like the brush tool I want to paint with nice soft edges. ... > The GDI+ I find annoyingly slow, ... Create a new control, let's call it Canvas. ... Using DirectDraw, it is difficult, since you need to use alpha blending ...
    (microsoft.public.win32.programmer.directx.managed)
  • Drawing polygon
    ... What's the best way to draw a polygon with 4 corners in directdraw? ... I only see a DrawBox or DrawRectangle function. ... I've tried this gdi ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: DirectDraw and GDI+
    ... > improvements of image filtering using DD7 instead of GDI+. ... > DirectDraw - don't hybrid the solution. ... do you think maybe a DirectDraw solution would be better ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Drawing polygon
    ... but it's still GDI and not DirectDraw. ... > DirectDraw to efficiently draw lines (although there is a DrawLine ... > difficult in managed DirectX bacause of Lock bugs). ...
    (microsoft.public.win32.programmer.directx.managed)