Filling Uneven Polygon

I am having a set of vertices which will plot an uneven polygon. It is like this(in the form x-y)100-100, 400-100,400-400, 100-400, 100-100,200-200, 300-200, 300-300, 200-300, 200-200. Plotting these points will give two rectangles one inside another with a connecting line from the top left vertices.
If i draw a polygon using GDI, with a brush selected to the hdc, the intermediate area
between the two rectangles will get filled.
How do i achive the same in opengl with the same set of vertices.

Hi there!

Well first things first, you shouldn’t (and can’t compare) OGL with GDI. There are completly different in this manner. While the
GDI performs an interior fill, OGL is of course different. At the lowest level (not really true, but to make things easy to explain) OGL is based on triangles. Triangles are always concave and planar, which makes them easy to interpolate (in software as well as in hardware). Therefor there nothing like the GDI interior fill.

To make a (very) long story short, I suggest to you the following:

You should write some code that takes your input coordinates and generates the visible triangles out of this (try the most famous book about computer graphics from Foley, van Dam, …) You probably know it (you should )

Hope that helped you!

(I really hope so!)

Best regards,

LG

Hi LG,
Thanks for your replay. Sorry for not contacting you.I managed to extract the same from OpenGL using Tessilation technique. Here is the code for that.Please go through it.

/* variable declaration */
/* vertices is 2D array containing the polygon vertices */
/* vcount is the number of vertices */

GLUtesselator *tess;
GLdouble vertices[n][3];
int i=0;	

glPushMatrix();

glIndexi(20); //I am using  Index Mode

tess = gluNewTess();
gluTessCallback(tess, GLU_BEGIN, glBegin);
gluTessCallback(tess, GLU_VERTEX, glVertex3dv);
gluTessCallback(tess, GLU_END, glEnd);
gluTessCallback(tess, GLU_TESS_COMBINE, combineCallback);

gluBeginPolygon(tess);

for(i=0; i<vcount; i++)
gluTessVertex(tess, vertices[i], vertices[i]);

gluEndPolygon(tess);

gluDeleteTess(tess);

glPopMatrix();

glFlush();

}

void CALLBACK combineCallback(GLdouble coords[3],
GLdouble *vertex_data[4],
GLdouble weight[4],GLdouble **dataout)
{
GLdouble *vertex;
int i;
vertex = (GLdouble )malloc(6sizeof(GLdouble));
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];
*dataout = vertex;

}

i got this stuff from OpenGl Reference mannual. Any way now the things are working perfectly for me.

Waiting for your suggession.

Sajith

[This message has been edited by sajith (edited 04-08-2000).]

[This message has been edited by sajith (edited 04-08-2000).]

Yeah tesselation was what I meant.

I prefer to us me own tesselator, but
if the OpenGL tesselator is working for
you, fine

Until you run into performance problems I don’t have any further suggestions to you

May the vector be with you!

Regards,

LG