Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Simple Fill Polygon in OpenGL

with one comment

I am wondering around to find the fill polygon routine in OpenGL. I have closed shape as I am developing CAD/CAM application. And i needed to fill the close shape. In start, it seems difficult, but it is as simple as to eat PIZZA

Just convert the close shape to polygon and call following code to fill the polygon .

GL.Color3((System.Drawing.Color)color);
GL.Disable(EnableCap.Texture2D);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
GL.Begin(BeginMode.Polygon);
for (int j = 0; j < sides; j++)
{
GL.Vertex2(xPoints[j], yPoints[j]);
}
GL.End();
GL.Enable(EnableCap.Texture2D);
GL.Flush();
GL.Finish();

 

That’s all and the thing work like charm.

Simple but thought that it should be shared !!!

Advertisements

Written by Manish

March 20, 2009 at 3:45 pm

Posted in .NET, .NET 3.0, OpenGL

One Response

Subscribe to comments with RSS.

  1. But this not is to Irregular polygons. Only for simple polygons …… and the practical is very common found have irregular polygons

    Tavo

    December 15, 2011 at 1:46 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: