0

I recently completed my system for loading an array of quads into VBOs. This system allows quads to share vertices in order to save a substantial amount of memory. For example, an array of 100x100 quads would use 100x100x4=40000 vertices normally (4 vertices per quad), but with this system, it would only use 101x101=10201 vertices. That is a huge amount of space saving when you get into even larger scales.

My problem is is that in order to texture each quad individually, each vertex needs a "UV" coordinate pair (or "ST" coordinate) to map one part of the texture to. This leads to the problem, how do I texture each quad independently of each other? Even if two of the same textured quads are next to each other, I cannot use the same texture coordinate for both of the quads. This is illustrated below: enter image description here

*Each quad being 16x16 pixels in dimension and the texture coordinates having a range of 0 to 1.

To make things even more complicated, some quads in the array might not even be there (because that part of the terrain is just an empty block). So as you might have guessed, this is for a rendering engine for those 2D tile games everyone is trying to make.

Is there a way to texture quads using the vertex saving technique or will I just have to trash this method and just use the way less efficient way?

4

1 回答 1

2

你不能。

OpenGL 中的顶点是数据的集合。它们可能包含位置,但它们也包含纹理坐标或其他内容。每个顶点,位置/坐标/等的每个集合都必须是唯一的。因此,如果您需要将相同的位置与不同的纹理坐标配对,那么您就有不同的vertices

于 2013-08-05T20:20:34.373 回答