简体   繁体   中英

How to draw different tiles using an IBO?

My aim is to draw a bunch of "blocks" using a mesh in OpenGL. I can draw a mesh with a VBO and an IBO. But I don't know how to handle texture coordinates because in my "concept" not each adjacent block shares the same texture coordinates. But by using an IBO each vertex has just one texture coordinate?

So is there any way to achieve my aim using an IBO or do I have to draw each block independently? The latter is what I want to avoid because it needs much more memory space.

Yes, you can still gain benefits from IBO.

Instead of sharing vertices between block faces, make new vertexes at each block corner, for each face, and assign them different texCoords. This will allow you to have different textures on each block. You'll still be able to share vertices with the triangles in the same block face, so IBO will net you some benefit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM