Hello Everyone,
I have been trying to clip polygons. The basic process works, but I am not able to get the desired result. I want to get the result of subtraction of polygon B from A.
links for images to help understand desired result:
1)
http://i48.tinypic.com/14m8hls.jpg[
^]
2)
http://i45.tinypic.com/apllh.jpg[
^]
Also, below is the code(I have tried all the Winding rules!!!):
GLUtesselator *tess = gluNewTess(); if(!tess) return 0;
GLdouble quad2[8][3] = { {0,0,0}, {3,0,0}, {3,4,0}, { 0,4,0},
{1,1,0}, {4,1,0}, {4,2,0}, { 1,2,0} };
gluTessCallback(tess, GLU_TESS_BEGIN, (void (__stdcall*)(void))tessBeginCB);
gluTessCallback(tess, GLU_TESS_END, (void (__stdcall*)(void))tessEndCB);
gluTessCallback(tess, GLU_TESS_ERROR, (void (__stdcall*)(void))tessErrorCB);
gluTessCallback(tess, GLU_TESS_VERTEX, (void (__stdcall*)())tessVertexCB);
gluTessCallback(tess, GLU_TESS_COMBINE, (void (__stdcall*)(void))tessCombineCB);
gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);
glNewList(id, GL_COMPILE);
glColor3f(1,1,1);
gluTessBeginPolygon(tess, 0);
gluTessBeginContour(tess); gluTessVertex(tess, quad2[0], quad2[0]);
gluTessVertex(tess, quad2[1], quad2[1]);
gluTessVertex(tess, quad2[2], quad2[2]);
gluTessVertex(tess, quad2[3], quad2[3]);
gluTessEndContour(tess);
gluTessBeginContour(tess); gluTessVertex(tess, quad2[4], quad2[4]);
gluTessVertex(tess, quad2[5], quad2[5]);
gluTessVertex(tess, quad2[6], quad2[6]);
gluTessVertex(tess, quad2[7], quad2[7]);
gluTessEndContour(tess);
gluTessEndPolygon(tess);
glEndList();
gluDeleteTess(tess);
Thanks In Advance