运行时检查失败#0:为什么我得到这个以及它是什么意思?

时间:2011-04-02 01:13:43

标签: c visual-studio-2008

在我的程序中(用于家庭作业),我将一个顶点和法线等模型加载到我拥有的结构中。绘制时,我将模型传递给函数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函数接受指向结构的指针(我应该以...开头),但是一旦我在函数中访问它,我就会得到那个错误。< / p>

我该如何解决这个问题?为什么会发生这种情况?

这是整个功能

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(&plane);

1 个答案:

答案 0 :(得分:1)

问题是

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

应该阅读

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