GLTessellator crashing
I'v followed a tutorial to get the GLU tesselator working. It works except the interpolation for colors of new points causes a crash after creating a random polygon开发者_StackOverflow中文版(error reading from memory...)
This is my callback where it crashes:
void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4],
GLfloat 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];
//crashes here
**for (int i = 3; i < 6; i++)
{
vertex[i] = weight[0] * vertex_data[0][i] +
weight[1] * vertex_data[1][i] +
weight[2] * vertex_data[2][i] +
weight[3] * vertex_data[3][i];
}**
//crashes here
*dataOut = vertex;
}
I looked at memory when it crashes but can't put my finger on exactly what triggers it. I followed this tutorial: http://www.flipcode.com/archives/Polygon_Tessellation_In_OpenGL.shtml
Thanks
My guess is that vertex_data is wrong. It is the same pointer that you pass to gluTessVertex function. What does that pointer point to?
精彩评论