2

Possible Duplicate:
Rendering meshes with multiple indices

In my application I have a lot of quads that are rendered using the same vertex buffer, I have optimized it by erasing repeated vertices and using indices, like normal. The problem is the texture coordinates for these quads aren't continuous, they all use the same texture coordinates in fact just (0.0,0.0 , 1.0,0.0 , 1.0,1.0 , 0.0,1.0) over and over (what a waste). When rendering, the first quad comes ok, but the following ones use the wrong texture coordinates, because they reuse the ones from the reused vertices, and the second quad, which is adyacent to the first, uses this coordinates (1.0,1.0, 0.0,1.0, 1.0,1.0, 0.0,1.0) instead of the former ones which isn't ok obviously.

What I want is something like this:

(two quads and texture coordinates)
| 0,0 0,1 | 0,0 0,1 |
| 1,0 1,1 | 1,0 1,1 |

But instead I get this:

| 0,0 0,1 | 0,1 0,1 |
| 1,0 1,1 | 1,1 1,1 |

This is normal, it's just that I wasn't expecting it because I did the texture stuff after vertices and indices, and I'm more used to normal models..

I want to know if there is a way to efficiently do this because I'm starting to think the only way is by avoiding using indices andd repeating all those vertices or using instancing (which I don't want to use). These are only two quads but my app has a lot of them at any given time and using indices makes a huge difference in terms of memory usage. Also, I want to know if there is some way to get rid of all those repeated texture coordinates and just use them once, instead of 10000 times, because it looks like a big waste of memory. It's just rendering a bunch of individual quads efficiently with the same texture coords using the same buffers, Thanks!

Community
  • 1
  • 1

0 Answers0