Results 1 to 4 of 4

Thread: Filling Uneven Polygon

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2000
    Location
    india
    Posts
    6

    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.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    183

    Re: Filling Uneven Polygon

    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

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2000
    Location
    india
    Posts
    6

    Re: Filling Uneven Polygon

    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(6*sizeof(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).]

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    183

    Re: Filling Uneven Polygon

    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

Similar Threads

  1. Polygon Triangulation And Layer Filling
    By Simpkin in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 08-16-2011, 04:15 PM
  2. Filling a polygon with a repeating texture
    By transparent in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-11-2011, 09:07 AM
  3. about filling colors to a polygon
    By lakgani in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-16-2008, 08:04 PM
  4. problem displaying uneven surface
    By rp_bohs in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-24-2003, 07:51 AM
  5. basic scanline polygon filling
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-07-2001, 07:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean