Many objects with different textures in OpenGL ES 2.0

前端 未结 1 723
南旧
南旧 2021-01-26 22:23

I\'m new to OpenGL ES 2.0 with it\'s programmable pipeline and I\'m porting application that renders many objects all with different textures. So this will require calling glDr

相关标签:
1条回答
  • 2021-01-26 22:48

    Unfortunately, there is not a simple built-in way to apply multiple textures in a single batch glDrawArrays call. There are, however, ways to make it work. One of the most common strategies is known as a Texture Atlas. Basically, the idea is to combine many images together into one larger texture, with each sub-image occupying a known sub-rectangle of the texture. When you map those onto your primitives, you supply the coordinates of the sub-rectangle corresponding to the image you want to display.

    A texture atlas will work in a large number of cases, but can be comparatively complex to set up. If you don't have to do a different texture for every single object, the first thing to try would be to simply batch together as many primitives that use the same texturing as possible.

    If you were not using OpenGL ES, you might also look into using Texture Arrays, if your textures are all of the same size.

    0 讨论(0)
提交回复
热议问题