开发者

glDrawElements and multiple images

Word on the street is that glDrawElements is much faster then glDrawArrays.

So I want t开发者_运维技巧o display everything using glDrawElements. The problem I have is that I have a bunch of images I want to pop onto the screen. Each image is in a different texture.

Is it possible to use glDrawElements to do this?

How can I switch the texture


Vertex indexing (i.e., glDrawElements) can greatly reduce the size of your vertex buffer if you often have vertices that are shared between multiple primitives.

For example, if you're drawing a mesh with GL_TRIANGLES, you'd definitely want to use indexing. If you're simply drawing a bunch of disjoint triangles, there's not much reason to use indexing.

Regardless of whether you use glDrawElements or glDrawArrays, it's always desirable to minimize the number of draw calls. Using a texture atlas allows you to combine multiple draw calls that would otherwise be separated with calls to glBindTexture.


You can't, directly.

What you can do is make a texture atlas, by making one big texture containing all of your little textures, and then adjust your texture coordinates accordingly.

Also, where did you hear about the comparison between glDrawArrays and glDrawElements? I've never seen a convincing, all-cases-included comparison.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜