PDA

View Full Version : errors



jono_123
09-30-2002, 06:03 PM
i am getting the error:
Unhandled exception in myprogram.exe (OPENGL32.DLL): 0xC0000005 : Access violation.
what is going wrong here?

Deiussum
10-01-2002, 04:31 AM
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.

jono_123
10-05-2002, 03:58 PM
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).]

t0y
10-05-2002, 05:04 PM
Maybe you're passing NULL parameters, or not using pointers properly...

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

jono_123
10-08-2002, 09:21 PM
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[index*2]);
//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();

Gavin
10-09-2002, 12:47 AM
have you got 156 indicies then?

nexusone
10-09-2002, 02:30 AM
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:
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[index*2]);
//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();

Deiussum
10-09-2002, 04:36 AM
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?

jono_123
10-10-2002, 08:03 PM
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:
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?



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

nexusone
10-11-2002, 04:08 AM
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:
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).]

Deiussum
10-11-2002, 06:12 AM
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.