我按照教程让 GLU tesselator 工作。它的工作原理是新点颜色的插值在创建随机多边形后导致崩溃(从内存中读取错误......)
这是我崩溃的回调:
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;
}
当它崩溃时,我查看了内存,但无法确定触发它的确切原因。我遵循了本教程:http ://www.flipcode.com/archives/Polygon_Tessellation_In_OpenGL.shtml
谢谢