是否可以使用 libGdx(适用于 Android/桌面的 Java 引擎)中的 SpriteBatch 渲染到纹理?如果是这样,怎么办?
基本上我想将所有内容渲染到 512 x 256 纹理的 320 x 240 区域,然后缩放区域以适合屏幕(在横向模式下)。这样我想消除当我独立缩放 alpha 混合纹理时发生的伪影。如果有任何其他方法可以删除此类工件,请指出:)
有 libGdx 的在线文档吗?
这段代码是在 LibGDX 论坛上给我的,它运行得非常完美。
private float m_fboScaler = 1.5f;
private boolean m_fboEnabled = true;
private FrameBuffer m_fbo = null;
private TextureRegion m_fboRegion = null;
public void render(SpriteBatch spriteBatch)
{
int width = Gdx.graphics.getWidth();
int height = Gdx.graphics.getHeight();
if(m_fboEnabled) // enable or disable the supersampling
{
if(m_fbo == null)
{
// m_fboScaler increase or decrease the antialiasing quality
m_fbo = new FrameBuffer(Format.RGB565, (int)(width * m_fboScaler), (int)(height * m_fboScaler), false);
m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture());
m_fboRegion.flip(false, true);
}
m_fbo.begin();
}
// this is the main render function
my_render_impl();
if(m_fbo != null)
{
m_fbo.end();
spriteBatch.begin();
spriteBatch.draw(m_fboRegion, 0, 0, width, height);
spriteBatch.end();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)