开发者

OpenGL display lists: For drawing 2D sprites?

开发者 https://www.devze.com 2023-02-15 21:58 出处:网络
Is it a g开发者_开发问答ood or bad idea to use display lists for drawing textured rectangles? The display list would be re-compiled only if the texture the sprite is using changes.For drawing a singl

Is it a g开发者_开发问答ood or bad idea to use display lists for drawing textured rectangles?

The display list would be re-compiled only if the texture the sprite is using changes.


For drawing a single sprite, there's no real problem in doing it that way, but there's no advantage to it either, assuming you're using glRotate/glTranslate to position the sprite. Plenty of games have been written that way.

In my games, I use a vertex buffer object with GL_DYNAMIC_DRAW to store all the sprites which share each texture atlas. I update the vert positions on the CPU and send the whole batch in one draw call. I can draw many more sprites using this approach. I could do the positions in a vertex shader if I needed to draw even more.

Also, keep in mind that OpenGL ES2 doesn't support display lists, so if you're thinking of porting to an ES2 device you'd have to re-do it. (iPhone/iPad support ES1 but you can't mix and match with ES2, you can use display lists OR shaders but not both).

0

精彩评论

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