gpt4 book ai didi

c - 运行时检查失败 #0 : Why am I getting this and what does it mean?

转载 作者:行者123 更新时间:2023-11-30 16:02:16 24 4
gpt4 key购买 nike

在我的程序中(用于家庭作业),我将一个模型加载到我拥有的结构中,该模型是一堆顶点和法线等。绘制它时,我将模型传递给函数 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(&plane);

最佳答案

问题是

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

应该是这样的

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

关于c - 运行时检查失败 #0 : Why am I getting this and what does it mean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5520441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com