Skip to content

Commit

Permalink
Fixed transparency by disabling transparency in framebuffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Jun 10, 2024
1 parent 32f1009 commit 3bdfbb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/src/main/java/dev/ultreon/bubbles/render/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ public void end() {

public void enableBlend() {
this.batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Gdx.gl20.glEnable(GL20.GL_BLEND);
Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
this.blendingEnabled = true;
}

Expand Down Expand Up @@ -997,10 +999,13 @@ public void blurred(float overlayOpacity, float radius, boolean grid, int guiSca
this.toBatch();

try {
var blurTargetA = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
var blurTargetB = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
var blurTargetA = new FrameBuffer(Pixmap.Format.RGB888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
var blurTargetB = new FrameBuffer(Pixmap.Format.RGB888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
var fboRegion = new TextureRegion(blurTargetA.getColorBufferTexture());

Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

//Start rendering to an offscreen color buffer
blurTargetA.begin();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public World getWorld() {

@Override
public void render(Renderer renderer, int mouseX, int mouseY, float deltaTime) {
renderer.enableBlend();

var world = this.getWorld();
if (world == null) return;
if (world.shuttingDown) return;
Expand Down

0 comments on commit 3bdfbb1

Please sign in to comment.