errors

i am getting the error:
Unhandled exception in myprogram.exe (OPENGL32.DLL): 0xC0000005 : Access violation.
what is going wrong here?

More info is needed. Just some general things to look at. Make sure you’re not going outside the bounds of an array, or telling OpenGL to with glDrawArrays, glDrawElements, etc.

I’ve said this many times before, but here goes. Exception errors are almost always caused by somehow touching memory you have no right to touch.

when i comment out all the glVertex3fv’s then the program works fine but it just doesnt draw anything does this mean that i might be feeding opengl data that it can’t take into glVertex3fv??

[This message has been edited by jono_123 (edited 10-05-2002).]

Maybe you’re passing NULL parameters, or not using pointers properly…

Without a more detailed explanation (example code?) it’s very difficult to help.

it is a program that reads vertices,normals and texcoords from a file and draws the object to the screen it works fine when i load a model with mesh.nIndices = 153 but is crashes when mesh.nIndices = 156

glBegin(GL_TRIANGLES);
for (int i = 0,int k = 0; i(mesh.nIndices); i += 3, k++) {
index = mesh.indices[i];
//glTexCoord2fv(&texcoords[index2]);
//glNormal3fv(&mesh.normals[index
3]);
glVertex3fv(&mesh.coordinates[index*3]);

	index = mesh.indices[i + 1];
	//glTexCoord2fv(&texcoords[index*2]);
    //glNormal3fv(&mesh.normals[index*3]);
    glVertex3fv(&mesh.coordinates[index*3]);

	index = mesh.indices[i + 2];
	//glTexCoord2fv(&texcoords[index*2]);
    //glNormal3fv(&mesh.normals[index*3]);
    glVertex3fv(&mesh.coordinates[index*3]);
}
glEnd();

have you got 156 indicies then?

Do you have a array of of 156?
See following example:

int array[157]; = 0 to 156 locations
int array[156]; = 0 to 155 locations

Originally posted by jono_123:
[b]it is a program that reads vertices,normals and texcoords from a file and draws the object to the screen it works fine when i load a model with mesh.nIndices = 153 but is crashes when mesh.nIndices = 156

glBegin(GL_TRIANGLES);
for (int i = 0,int k = 0; i(mesh.nIndices); i += 3, k++) {
index = mesh.indices[i];
//glTexCoord2fv(&texcoords[index2]);
//glNormal3fv(&mesh.normals[index
3]);
glVertex3fv(&mesh.coordinates[index*3]);

  index = mesh.indices[i + 1];
  //glTexCoord2fv(&texcoords[index*2]);
    //glNormal3fv(&mesh.normals[index*3]);
    glVertex3fv(&mesh.coordinates[index*3]);
  index = mesh.indices[i + 2];
  //glTexCoord2fv(&texcoords[index*2]);
    //glNormal3fv(&mesh.normals[index*3]);
    glVertex3fv(&mesh.coordinates[index*3]);
}
glEnd();[/b]

for (int i = 0,int k = 0; i(mesh.nIndices); i += 3, k++)

Shouldn’t i(mesh.nIndices) be i < mesh.nIndices? And where is k being used?

Also, you could just do i++, and then just do the first glVertex3fv. Your way works as well, but is just a bit more code.

I’m assuming coordinates is a float array, which is why you do the *3 on it?

yea that was just a typo it should read i < mesh.nIndices
and ill try your idea
and also is there any quick way that i can check that the size of the array is 156?

Originally posted by Deiussum:
[b]for (int i = 0,int k = 0; i(mesh.nIndices); i += 3, k++)

Shouldn’t i(mesh.nIndices) be i < mesh.nIndices? And where is k being used?

Also, you could just do i++, and then just do the first glVertex3fv. Your way works as well, but is just a bit more code.

I’m assuming coordinates is a float array, which is why you do the *3 on it?[/b]

[This message has been edited by jono_123 (edited 10-10-2002).]

Yes, you can check your array by looking at your code and making sure you have defined it correctly.

But I think you problem is a math one, and that at some point you are addressing memory above the 156 that you have reserved for the array.

You could try the following just make the array larger, say increase to 200 when you try 156.

Originally posted by jono_123:
[b]yea that was just a typo it should read i < mesh.nIndices
and ill try your idea
and also is there any quick way that i can check that the size of the array is 156?

[This message has been edited by jono_123 (edited 10-10-2002).][/b]

You actually want to make sure your vertex array has a size of 156*3 if you have 156 indices. 3 floats per-index (x,y,z), 156 indices.