【问题标题】:Run-Time Check Failure #0: Why am I getting this and what does it mean?运行时检查失败#0:为什么我会得到这个,这是什么意思?
【发布时间】:2011-04-02 01:13:42
【问题描述】:

在我的程序中(用于家庭作业),我将一个模型加载到我拥有的结构中,该模型是一堆顶点和法线等。绘制它时,我将模型传递给函数void drawModel(Model model)。这样做会给我这个错误:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

我环顾四周,一个答案似乎是因为我传递的内容太大而且它弄乱了编译器。所以我尝试更改它,以便drawModel 函数接受一个指向结构的指针(我应该从一开始就这样做......),但是一旦我在函数中访问它,我就会得到那个错误。

我该如何解决这个问题?为什么会这样?

这是整个函数

void drawModel(Model * model)
{
    int i, g; //i is the main iterator, g keeps track of what part we're on
    int edge; //The current edge we're on
    g = 0;

    for(i = 0; i < (model->faceCount); i++) //This is just to test why it's occuring
    {
    }
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, model->vertices);
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(3, GL_FLOAT, 0, model->normals);
    for(i = 0; i < (model->faceCount); i++) //Right here is where i get the error
    {
        if(i == model->parts[g])
        {
            //Set colour to the part colour

            g++;
        }

        glDrawElements(GL_POLYGON, model->faces[i].edges, GL_UNSIGNED_BYTE,
            model->faces[i].edge);
    }
}

注意:我以前从未使用过 GL 顶点数组,这是我的第一次尝试。

我是这样调用 drawModel 的:drawModel(&amp;plane);

【问题讨论】:

  • 向我们展示您如何称呼drawModel,以及该行中出现的所有内容的定义。
  • 我认为这实际上可能更像是一个 OpenGL 问题
  • 杰夫:你如何调用它。
  • 我会把它放在那里,但我发现了问题,它是 glNormalPointer。它不需要第一个参数

标签: c visual-studio-2008


【解决方案1】:

问题是

glNormalPointer(3, GL_FLOAT, 0, model->normals);

它应该读过

glNormalPointer(GL_FLOAT, 0, model->normals);

【讨论】:

    猜你喜欢
    • 2011-11-12
    • 2019-11-24
    • 1970-01-01
    • 2018-01-15
    • 1970-01-01
    • 2011-08-23
    • 1970-01-01
    • 2011-05-26
    相关资源
    最近更新 更多