简体   繁体   English

IBO比GL_TRIANGLE_STRIP差吗?

[英]IBO worse then GL_TRIANGLE_STRIP?

for learning purposes I decide to draw a sphere using 3 methods 出于学习目的,我决定使用3种方法绘制球体

  1. Display List 显示列表
  2. Voa Vbo (GL_TRIANGLE_STRIPE) Voa Vbo(GL_TRIANGLE_STRIPE)
  3. Vao Vbo and Ibo (GL_TRIANGLES) Vao Vbo和Ibo(GL_TRIANGLES)

I read that using ibo makes program runs faster, but is this really true? 我读到使用ibo让程序运行得更快,但这是真的吗? For a sphere of 100 slices and 100 stacks 2nd method produces 40400 vertices while 3rd "only" 19802.By doing that I save 20598vertices each 32bytes = 659136 bytes. 对于100个切片和100个堆栈的球体,第二个方法产生40400个顶点,而第三个“仅”19802。通过这样做,我保存20598个每个32字节= 659136个字节。

  1. verticesSize=(slices*4)*(stacks+1); verticesSize =(切片* 4)*(堆叠+ 1);

  2. IBO verticesSize=(slices*2)*(stacks-1)+2; IBO verticesSize =(slices * 2)*(stacks-1)+2;

However I need to make array of indices which in this case is a size of 118800(number of indexes needed to create all faces)*4(size of unsigned int)=475200 bytes! 但是我需要创建索引数组,在这种情况下,大小为118800(创建所有面所需的索引数)* 4(unsigned int的大小)= 475200字节! While 2nd methods renders 1000 spheres with 15fps ,the 3rd renders 1000 with barely 6pfs 虽然第二种方法使用15fps渲染1000个球体,但第三种方法使用仅仅6pfs渲染1000个球体

  1. Does converting indices array from GL_TRIANGLES to GL_TRIANGLE_STRIP will provide more efficiently method then 2nd method? 将指数数组从GL_TRIANGLES转换为GL_TRIANGLE_STRIP会提供更有效的方法,然后第二种方法吗?
  2. Does rendering sphere using ibo is bad idea? 使用ibo渲染球体是不是很糟糕?
  3. Why it is slower?Does the order in indices array have any matter? 为什么它更慢?indices数组中的顺序是否有任何问题?

Or maybe I wrote my code completely wrong and that why it struggles so much :( If someone is interested ,here is my code http://pastebin.com/raw.php?i=74jLKV5M 或许我写的代码完全错了,为什么它如此挣扎:(如果有人有兴趣,这里是我的代码http://pastebin.com/raw.php?i=74jLKV5M

The glDrawElements call is wrong. glDrawElements调用是错误的。 The count parameter should be the number of indices, not the number times 4. Try changing that. count参数应该是索引的数量,而不是数字的次数4.尝试更改它。

Using indices instead of triangle strips should almost always be faster. 使用索引而不是三角形条带几乎总是更快。 In fact I wouldn't be surprised if the driver was using indices behind the scenes to render triangle strips as well. 事实上,如果驾驶员在幕后使用索引来渲染三角形条带,我也不会感到惊讶。

Also as I mentioned in the comments, the order in which you have your indices can impact the performance. 正如我在评论中提到的那样,索引的顺序会影响性能。 However for your sphere, the indexing pattern you are using is probably the most optimal, and even so, the difference it makes is small. 但是对于您的球体,您使用的索引模式可能是最佳的,即便如此,它所产生的差异也很小。

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

相关问题 将GL_TRIANGLE_STRIP显示为线框 - Display GL_TRIANGLE_STRIP as wireframe GL_TRIANGLE_STRIP的glDrawRangeElements无法正常工作(使用glMapBuffer) - glDrawRangeElements of GL_TRIANGLE_STRIP not working properly (using glMapBuffer) OpenGL-使用GL_TRIANGLE_STRIP从OBJ绘制索引 - OpenGL - drawing indices from OBJ using GL_TRIANGLE_STRIP 用 GL_TRIANGLE_STRIP 将每一列相互连接起来 - Connecting each column with each other with GL_TRIANGLE_STRIP OpenGL:跳过GL_TRIANGLE_STRIP中的每n个四边形 - OpenGL: skip every n quad in a GL_TRIANGLE_STRIP 我可以纹理这个在 GL_TRIANGLE_STRIP 模式下渲染的立方体吗? - Can I texture this cube that is rendered in GL_TRIANGLE_STRIP mode? 是否可以使用G_TRIANGLE_FAN或GL_TRIANGLE_STRIP绘制两个单独的四边形? - Is it Possible to draw two separate quad using G_TRIANGLE_FAN or GL_TRIANGLE_STRIP? 使用GL_TRIANGLE_STRIP或索引GL_TRIANGLES绘制动态数量的四边形是否更有效 - Is It More Efficient to Use GL_TRIANGLE_STRIP or Indexed GL_TRIANGLES to a Draw a Dynamic Number of Quads 如何在OpenGL中为GL_TRIANGLE_STRIP创建的圆柱体做纹理映射以及如何使圆柱体变细 - How to do texture mapping for cylinder created by GL_TRIANGLE_STRIP in OpenGL and how to taper a cylinder 为什么三角形条带中使用的z坐标打开gl - Why is z coordinates used in a triangle strip open gl
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM