[英]IBO worse then GL_TRIANGLE_STRIP?
for learning purposes I decide to draw a sphere using 3 methods 出于学习目的,我决定使用3种方法绘制球体
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个字节。
verticesSize=(slices*4)*(stacks+1); verticesSize =(切片* 4)*(堆叠+ 1);
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个球体
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.