I am trying to tesselate the interior of an irregular polygon with the following C++/Psuedo code:
I declare the following function:
const GLdouble *pointer;
pointer = (GLdouble *) vertex;
All the others callbacks (combine, begin, end, error) are declared as well.
I also declare the following struct:
double x, y, z;
I created a vector as follows:
vector <coordinate> TessPath;
To add a vertex, I do the following:
loc.x = x;
loc.y = y;
loc.z = 0.0;
gluTessVertex(tess,reinterpret_cast<double*>(&path[path.size() - 1]),reinterpret_cast<void *>(&path[path.size() - 1]));
The Tessellations are really messed up, going all over the screen.
When I run the program under valgrind, it gives the following:
==12310== Invalid read of size 4
==12310== at 0x410CD29: (within /usr/lib/libGL.so.1.2)
==12310== by 0x40F3C79: glVertex3dv (in /usr/lib/libGL.so.1.2)
==12310== by 0x408103E: (within /usr/lib/libGLU.so.1.3.060402)
==12310== by 0x40809EE: __gl_renderMesh (in /usr/lib/libGLU.so.1.3.060402)
==12310== by 0x40844C3: gluTessEndPolygon (in /usr/lib/libGLU.so.1.3.060402)
==12310== by 0x8067E28: Symbol::render() (in /home/fordj/Desktop/mlp/a.out)
What in the world am I doing wrong??? I have corrupted the heap somehow. When I comment out all of the Tessellation code, it runs beautifully sans filled interiors and valgrind has no complaints. The gluTessVertex, which in turn is calling glVertex3dv is the problem I believe.