View Full Version : U V Coords and Vertex Arrays

04-27-2001, 04:21 AM
The rendering in the engine I currently work on is preformed using vertex arrays. My job is to write code that calculates the U and V texture coordinate of each vertex of some models, and write the vertices into a vertex array.

That is obvious that most of the vertex coordinates in the vertex array will have more then one UV coordinate (for example, the coord (1,2,3) in one poly has the different UV values then in another one that shares the same vertex-coord). Because of that, I will have to write the same coordinate couple of times into the vertex array just because the UV values are different!

It seems that this will result in a very big vertex array! Are there any other techniques for texture mapping without writing the same vertex into the vertex array couple of times?

Thanx for reading http://www.opengl.org/discussion_boards/ubb/smile.gif, Max

04-27-2001, 04:32 AM
Use primitives like triangle strips/fans or quad strips/fans. They have shared vertices, and every vertex in a strip is only defined once.

04-27-2001, 08:25 AM
Originally posted by Maxim:

That is obvious that most of the vertex coordinates in the vertex array will have more then one UV coordinate

As far as I understand, you want different textures to be on most of adjacent polies.
If so, you probably have to write your vertex coordinates repeatedly. This also
implies that you have to render your geometry by polygons. That can make a huge call overhead.
However, you can consider another way. Use, as Dodger said, strips (or other primitives)
in a vertex array and apply only one texture to the array. You can compose that single texture from many small textures and change it "on fly" with TexSubImage.
It would be faster.

04-27-2001, 12:30 PM
First of all, I think both of you mis-diagnosed Maxim's problem. What he is saying is that adjacent polygons may have different sets of texture coordinates. Because of that, he is forced to dupicate a vertex position, which increases the size of the vertex array.

Unfortunately, this is the nature of vertex arrays. Your index is an index into each of your separate arrays, so if you need a vertex that has a certain position, but two sets of UVs, you will need to have that position in two places in your vertex array.

04-27-2001, 08:13 PM
Maybe there was some misunderstanding. I thought that Max asked about other techniques of texture mapping. If you use a composite texture, you need only one set of texture coordinates at each vertex. It was just a suggestion.

04-28-2001, 12:40 AM
Thanx a lot Korval, that was exactly what I wanted to know!

04-28-2001, 02:44 AM
Told you...