PDA

View Full Version : Vertex Array Limit?



12-18-2001, 09:56 AM
I am attempting to render some terrain using Vertex Arrays. If I send more than 50,000 vertices at a time my program crashes. I was wondering if this is a limit on how many you can send at a time. It is not a problem to batch the vertices in smaller sizes but I am wondering how to ask OpenGL what the limit is.

12-18-2001, 10:07 AM
I think it a limit with vertex arrays,it can only contain 65000 vertex.

soo u need to split it up!

Syslock
12-18-2001, 10:20 AM
I think for any array, vertices, texture coordinates, normals, etc..
there's a 65535 limit. But I haven't found any GL functions that
returns this value. I'm just assuming it as I have some experience
with other 3D graphics APIs. I'm also assuming this is a hardware
limitation, and I wouldn't know if OpenGL did something special
in software if you exceeded this limit.

12-18-2001, 10:45 AM
Here is a follow-up question. My help files for OpengGL say that the 3rd parameter in glDrawArrays is the count of how many "indices" are to be rendered. I have 1 indice into my array for each of the x, y, and z coord's for each vertex. I take it the count parameter in glDrawArrays is the count of how many vertices and not indices into my array right? Also I can send exactly 50,000 vertices in glDrawArray and crashes on 50,001 so I would think that somewhere there would be a parameter or something that returns this number. Hopefully? If anyone knows I would appreciate a response....Thanks

Spiral Man
12-18-2001, 11:34 AM
an "index" as openGL calls it is a vertex. so, for instance, you have 4 vertexes in the array, thats 12 actuall elements in the array, but if you want to draw the first vertex, you refer to it as 0, and gl accesses the first, second, and third element in the actual array (assuming the array only contains vertex data). for the second, its 1, and that the fourth, fith, and sixth, etc. so, basically, yes, how many verticies, not indicies.

perhaps there is a bug in your code. are you sure that you actually have 50,001 vertexes in your array, and that you enabled the array correctly? perhaps your stride is wrong. i am currently working on an application that has a vertex array that contains 65536 verticies, and i havent had any problems with it...

presumably, the vertex array has to be able to fit in video memory. does this card have a very small amount of memory (that array takes up 6MB, assuming i didnt forget something)?

12-18-2001, 11:45 AM
If I batch the calls to glDrawArrays in batches of 30,000 it works fine, so I don't think it is how I am setting up the arrays. The stride is something I am not sure about. I am using Delphi 6 and there is a project option that I have checked off for Record Field Alignment as 8. I originally thought that my stride would be 8, but I am using GetMem to dynamically get the exact amount of memory that I need so I believe the stride should be 0 in this case, correct? All I know is that if I send it in batches of 30,000 I see exactly what I expect to see. The card is an NVidia TNT2 32 by the way.

Spiral Man
12-18-2001, 01:26 PM
hmm, i havent actually drawn the entire array in one call, but ive split it up into several calls (i dont always want to draw the entire array). perhaps you can check if gl generates an error message before the program crashes...

i dont know delphi, but in c, the stride is the number of bytes between the first element of one vertex, and the first element of the next vertex. so, if you store everything as GLfloat's with 3 values(x, y, z) it would be sizeof(GLfloat)*3

sizeof returns the number of bytes in the variable (or type) that you send it...

in c, (or c++), how you allocate the memory doesnt affect what you send to stride, but like i said, i dont know about delphi...