c++ - GLTessellator 崩溃

标签 c++ c opengl glu

我已按照教程使 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/

相关文章:

c++ - 为什么我在赋值后得到不同的指针值?

c++ - 如何异步更新listmodel和listview

C++ 运算符重载返回

c - 如何扫描 C 语言中的一个句子

c - Internet Explorer 地址空间

c++ - glClearColor 不起作用

c++ - Linux下的socket开发

c - 如何将 AVX vector 与 clang 原生 vector 语法(无内在函数)混合?

performance - "non power of 2 textures"的 GL_TEXTURE_2D 性能如何?

c++ - 使用 Wavefront Obj 了解法线指标