I have a problem when trying to tesselate a polygon using GLU. The vertex callback always calls back with the last vertex defined by gluTessVertex. It seems as though the values stored in GLdouble v[3] are getting GC'd in each iteration of the for loop. How can I store each GLdouble v[3] so it does not get GC'd?
for(int i = 0; i < vtxcnt; i++)
{
float lon = dbls[i * 2];
float lat = dbls[(i * 2)+1];
GLdouble v[3] = {lon, lat, 0.0f};
gluTessVertex(tess, v, v);
}
* EDIT: This seems to fix the problem... *
GLdouble *vtxs = new GLdouble[vtxcnt * 3];
for(int i = 0; i < vtxcnt; i++)
{
lon = dbls[i * 2];
lat = dbls[(i * 2)+1];
vtxs[(i * 3) + 0] = (double)lon;
vtxs[(i * 3) + 1] = (double)lat;
vtxs[(i * 3) + 2] = (double)0;
gluTessVertex(tess, &vtxs[(i * 3) + 0], &vtxs[(i * 3) + 0]);
}