I'm writing a 2d game engine using libgdx where multiple layers of sprites have to be rendered using SpriteBatch with an OrthgraphicCamera. My layers are sorted with az component: higher z layers should be rendered on top of layers with a lower z.
Currently, I have to render layers sorted by their z component to achieve that. Is there a way, using opengl Z-buffer, to have them rendered out of order, and still show up correctly?
Fixed by switching to DecalBatch
instead of SpriteBatch. Here are the GL commands I use before drawing with the DecalBatch to enable depth-testing:
Gdx.gl.apply {
glClearColor(0f, 0f, 0f, 0f);
glEnable(GL20.GL_DEPTH_TEST)
glClear(GL20.GL_COLOR_BUFFER_BIT or GL20.GL_DEPTH_BUFFER_BIT)
glClearDepthf(1f)
glDepthFunc(GL20.GL_LESS)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.