CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010

    [RESOLVED] [2008] How to texture a triangle (2D)


    Currently working on a 2D engine, not for gaming but for design software / visualisation for machines. So far it is comming along quite fine. I started to wonder if it were possible to draw a triangle and fill it with some form of a a texture, or even better a polygon and fill that with a texture.

    I know that DX can do that for me :P but I am realy focussing on GDI+ at the moment.

    Anyone got any experiance with this and can tell me how to achieve this?

  2. #2
    Join Date
    Nov 2010

    Re: [2008] How to texture a triangle (2D)

    Unfortunatly almost directly after I posted this message and went back to VS I accedently found the texturebrush and after a quick test I found that that was also the answer to the question. For completeness I'll post a example of a textured Polygon:

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            Dim myBrush As New Drawing.TextureBrush(My.Resources.TestTexture, Drawing2D.WrapMode.Tile)
            Dim myBox As Point() = New Point() {New Point(0, 0), New Point(300, 0), New Point(300, 300)}
            e.Graphics.FillPolygon(myBrush, myBox)
    End Sub
    Easy as pie.
    I am still amazed how complete GDI+ is, it is almost Direct3D :P.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)