Okay, I haven’t used vertex arrays before, and am about to attempt them (hopefully successfully). However, I’m having trouble understanding something before I begin.
Let’s say I have these two quads I want to render:
0 1 2
| | |
3 4 5
Now, obviously vertices 1 and 4 are shared. Let’s now suppose a) there is a bend at 14 so that N(0143) is different from N(1254) and b) I want the same texture on both (so UV at 1 of 0143 is 1.0,1.0 and UV at 1 of 1254 is 0.0,1.0).
I don’t understand how to specify two different normals for the same vertex or two different UV coordinates for the same vertex. In the Red book, it appears as though each vertex has 1 color, 1 UV and 1 normal associated with it.
I’m sure this is an easy problem. Thanks in advance!
Well you’re asking 2 questions
if you want the same texture, no problem, just
use GL_REPEAT instead of GL_CLAMP as a texture parameter. Then, provide the following texcoords :
for vertice 0 , U = 0, V = 0
for vertice 3 , U = 0, V = 1
for vertice 1 , U = 1, V = 0
for vertice 4 , U = 1, V = 1
for vertice 2 , U = 2, V = 0
for vertice 5 , U = 2, V = 1
got it ?
for normals the problem’s more tough. As you have noticed, you can’t specify more than 1 normal vector per vertex. So in your case you have no choice but duplicating your vertex into 2 vertices, which have the same position, same texcoord, but different normals.
In my opinion, vertex arrays are designed for smooth objects. For non-smooth objects, you must either duplicate vertices into a larger vertex array, or split your verrtex array into 2 (or more) smaller arrays, each one describing a smooth part of your object. I believe that the first solution is faster.
Hope that helps