Pio*_*trK 36 android opengl-es libgdx
是否可以在libGdx(Android/Desktop的Java引擎)中使用SpriteBatch渲染到纹理?如果是这样,怎么办?
基本上我想将所有内容渲染到512 x 256纹理的320 x 240区域,而不是缩放区域以适合屏幕(在横向模式下).这样我想消除当我独立缩放alpha混合纹理时发生的伪像.如果有任何其他方法来删除这些工件,请指出它们:)
还有libGdx的在线文档吗?
Pio*_*trK 63
这个片段是在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();
}
}
Run Code Online (Sandbox Code Playgroud)