简体   繁体   English

将vbo有效用于2d精灵[opengl / android]

[英]efficient usage of vbo for 2d sprites[opengl/android]

I'm working on my own game engine these days, and I'd like to make the rendering process as efficient as I can. 这些天,我正在使用自己的游戏引擎,并且我希望使渲染过程尽可能高效。 With "immidiate mode" I found that it's very easy to implement the features I want to include. 通过“模仿模式”,我发现要实现要包含的功能非常容易。

Here's the list: 这是清单:

  • transforming(translation,rotation, scaling, pivot) 转换(平移,旋转,缩放,旋转)
  • parenting (child sprites are affected by parent sprite eg transform) 育儿(子精灵受父精灵影响,例如变换)
  • simple vector graphic - well this isn't that important now 简单的矢量图形-好吧,这现在不那么重要
  • depth management 深度管理

But with VBOs and shaders it's quite hard to determine a good rendering structure. 但是,使用VBO和着色器很难确定良好的渲染结构。 At first I put four vertices in a VBO and transformed it with matrix(gluniform), but many people said this is the worst way. 首先,我在VBO中放置了四个顶点,并用matrix(gluniform)对其进行了变换,但是很多人说这是最糟糕的方法。 So, I'd like to hear your general ideas about efficiently implement those features and how I should VBOs. 因此,我想听听您关于有效实施这些功能以及如何使用VBO的一般想法。

You could have one square VBO that you use for all of your sprites by scaling it for the width and height and transforming it with matrices and binding the right texture for each sprite. 通过缩放其宽度和高度并使用矩阵对其进行转换,并为每个子画面绑定正确的纹理,可以为所有子画面使用一个正方形VBO。 Child sprites could multiply their matrices with the matrices of their parent sprite. 子级子画面可以将其矩阵与父级子画面的矩阵相乘。 Depth management can be done with the depth buffer, just glEnable(GL_DEPTH_TEST) and GL_LEQUAL depth function and translate along the z-axis to what layer you want it drawn on. 可以使用深度缓冲区(仅glEnable(GL_DEPTH_TEST)和GL_LEQUAL深度函数)进行深度管理,然后沿z轴平移到要在其上绘制的图层。 You probably don't even need to worry about doing everything the best and fastest way for just 2D sprites anyway. 无论如何,您可能甚至不必担心以最佳和最快的方式对2D精灵进行所有操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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