我已按照教程使 GLU 曲面 segmentation 器正常工作。除了新点的颜色插值在创建随机多边形后导致崩溃(从内存中读取错误...)之外它可以工作
这是我崩溃的回调:
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
谢谢
最佳答案
我的猜测是 vertex_data 是错误的。它与您传递给 gluTessVertex 函数的指针相同。该指针指向什么?
关于c++ - GLTessellator 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2894306/