Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How to draw 2d polygons in OpenGL

  1. #1
    Guest

    How to draw 2d polygons in OpenGL

    Hi,
    I tested the OpenGL polygon mode. It seems the following piece of code just draw a convex polygon:

    glBegin(GL_POLYGON);
    nVert = p->numVert();
    for(i=0; i<nVert; i++)
    {
    x = p->x(i);
    y = p->y(i);
    glVertex2f((GLfloat)x, (GLfloat)y);
    }
    glEnd();
    Any pointers how to draw a non-convex polygon in OpenGL?

    Thanks

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: How to draw 2d polygons in OpenGL

    Hi !

    OpenGL itself can only render simple polygons (convex, no overlaps and no holes), if you need non convex polygons you have to break it down into triangles yourself or use the GLU tesselator.

    Mikael

Posting Permissions

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