[SOLVED] [LibGDX] Depth Testing in an FBO causes graphical issues

Here’s the code for sorting out the FBO (the gist of it anyway)

gameFBO.begin();
Gdx.gl.glEnable(GL11.GL_DEPTH_TEST);
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

batch.draw(x);
batch.draw(y); // Maybe this is causing it (z fighting), but I've disabled all the draw calls except one and it's the same issue.

Gdx.gl.glDisable(GL11.GL_DEPTH_TEST);
gameFBO.end();

If this weird pattern looks familiar to someone, I’d appreciate the help!
An additional note: sometimes the white overlay is straight vertical lines separated by one pixel.

EDIT: Here’s the block for rendering the FBO

batch.begin();
batch.disableBlending();
batch.setColor(1, 1, 1, 1);
batch.setProjectionMatrix(camera.combined); // Orthographic, near = 0, far = 100
batch.draw(fboFlippedTexture, camera.position.x - fbo.getColorBufferTexture().getWidth() / 2, camera.position.y - fbo.getColorBufferTexture().getHeight() / 2, fbo.getColorBufferTexture().getWidth(), fbo.getColorBufferTexture().getHeight());
batch.flush();
batch.enableBlending();

Another note: disabling depth testing causes the issues to go away, but I still need the depth buffer.
Here’s the initialization for the main FBO, notice it has depth enabled:
[icode]gameFBO = new FrameBuffer(Format.RGBA8888, viewportWidth, viewportHeight, true);[/icode]

[s]I seem to have fixed it!
[icode]gameFBO = new FrameBuffer(Format.RGBA8888, viewportWidth, viewportHeight, true);[/icode]
to
[icode]gameFBO = new FrameBuffer(Format.RGB888, viewportWidth, viewportHeight, true);[/icode]

It could have been something with the alpha channel, either way… It’s cleaner now[/s]

Nope, broken again. Any help would be appreciated!

Herp derp, I was drawing a framebuffer texture over the game’s framebuffer with depth test enabled… Disabled the depth testing while rendering that framebuffer texture and it all works!

What you did was almost like rubber duck debugging…lol

Congrats on managing to resolve the issue yourself :slight_smile: In OpenGL, it’s pretty hard to debug and figure out what the heck you did wrong :stuck_out_tongue: