1
我有一些没有透明像素的背景,然后有一些透明像素的精灵。继libGDX文档,我在做这样的事情:每次更改libGDX enableBlending时都需要开始/结束?
spriteBatch.begin();
spriteBatch.disableBlending();
spriteBatch.draw(background, ...);
spriteBatch.enableBlending();
spriteBatch.draw(sprite, ...);
spriteBatch.end();
不过,我刚刚看了这个博客帖子,暗示你必须使用开始/每次结束。
http://www.rengelbert.com/tutorial.php?id=179&show_all=true
spriteBatch.disableBlending();
spriteBatch.begin();
spriteBatch.draw(backgroundRegion, 0, 0, 320, 480);
spriteBatch.end();
spriteBatch.enableBlending();
spriteBatch.begin();
spriteBatch.draw(someTextureRegion1, 10, 30);
spriteBatch.draw(someTextureRegion2, 50, 20);
spriteBatch.draw(someTextureRegion3, 30, 90);
spriteBatch.end();
这是真的需要?
我的代码似乎工作,没有错误报告,但我不知道如何测试,如果它比第二个例子更好或更差。
谢谢。冲洗比渲染单个800x480纹理与混合启用与未启用之间的区别更昂贵? –
冲洗与混合无关。改变混合(或纹理)只是意味着刷新,导致批处理(直到那一刻)被渲染。因此,刷新被认为是一种昂贵的操作,但渲染单个纹理相对(仅四个顶点)更昂贵。 – Xoppa