I’m a somewhat new C# programmer who’s just come across OpenGL and is trying to write a program to display and edit 3D terrain. I’m using SharpGL as an OpenGL wrapper; so far I’ve succeeded in following the more basic tutorials (glBegin/glEnd, gl.TRIANGLESTRIP, basic lighting, camera, etc.) but I’m having trouble when it comes to understanding vertex arrays. Part of this, I’m sure, is my having difficulty translating C++ to C#, but I’m also unclear on how glVertexPointer actually works; and the OpenGL wiki article, as well as Google searches for “Vertex Array tutorial”, haven’t cleared it up for me. If anyone could answer some basic questions for me, I would be very grateful.
As I understand it, it’s
glVertexPointer(# of components to each vertex, GL_FLOAT, something called a stride, array with vertex data);
I’m not sure what a GL_FLOAT is; Google searches suggest it’s just a float, and that it has a special name due to some peculiarity of C++. Or maybe it’s an array of floats?
The stride I don’t understand very well at all. Tutorials say it’s only used when vertex data is not tightly packed; what does “tightly packed” mean and how does stride relate to the vertex data? Does it have to do with array indices?
Even the last bit gives me trouble. Fortunately my question is a lot simpler: what is the best way to store that vertex data? In a multi-dimensional array with a syntax like vertices[128,3] for 128 vertices with 3 coords each, or a jagged array (an array-of-arrays) like vertices[][], or just as a single array, vertices[], with the vertices’ xyz coordinates just strung out one after the other, like {x1, y1, z1, x2, y2, z2}?
Do you have to have every single vertex in your 3D world contained in one large, messy array, or can you have multiple glVertexPointers and only use glDrawElements with specific ones?
I apologize for the number of questions I have, and how basic they probably are. I’ll keep trying to figure it out, but if anyone can help me with all this, I would be very thankful.
On a slightly related note, the reference pages for OpenGL aren’t working for me; they just open a new tab which never loads completely. I’m using IE9, so according to the preface they ought to be compatible. Is there something I’m missing, or is there some other place where I might access them?