运行时检查失败#0:为什么我会得到这一点,这是什么意思? [英] Run-Time Check Failure #0: Why am I getting this and what does it mean?
问题描述
在我的程序(它是一个家庭作业),我加载一个模型,它是一堆顶点和法线等成一个结构我有。当画它,我的模型传递给函数无效drawModel(型号模型)
。这样做,让我这个错误:
In my program (it is for a homework assignment), I load in a model which is a bunch of vertices and normals etc into a struct I have. When drawing it, I pass the model to a function void drawModel(Model model)
. Doing that gives me this error:
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
函数接受一个指向结构(这是我应该做了,开始与...),但只要我访问在功能上,我得到这个错误。
I was looking around, and one answer seemed to be that it was because what I'm passing is too large and it's messing up the compiler. So I tried changing it so the drawModel
function accepts a pointer to the struct (which I should've done to begin with...), but as soon as I access it in the function I get that error.
我怎样才能解决这个问题?以及为什么会出现这种情况?
How can I get around this? And why is this happening?
下面是整个函数
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顶点数组,这是我第一次尝试。
Note: I've never used GL vertex arrays before, this is my first attempt.
我打电话drawModel像这样: drawModel(安培;平面);
I was calling drawModel like so: drawModel(&plane);
推荐答案
的问题是
glNormalPointer(3, GL_FLOAT, 0, model->normals);
应该读过
glNormalPointer(GL_FLOAT, 0, model->normals);
这篇关于运行时检查失败#0:为什么我会得到这一点,这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!