title: libgdx Transparent Overlay
body: <p>I'm working on writing a JWindow type UI with OpenGL using libgdx. For some reason my app still has a black background even after enabling <code>GL20.GL_BLEND</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>package com.mygdx.game;
  
  import com.badlogic.gdx.ApplicationAdapter;
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.graphics.Color;
  import com.badlogic.gdx.graphics.GL20;
  import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
  import com.badlogic.gdx.scenes.scene2d.Stage;
  import com.badlogic.gdx.utils.viewport.FitViewport;
  
  public class MyGdxGame extends ApplicationAdapter {
  
      Stage stage;
      SpriteBatch batch;
      ShapeRenderer shapeRenderer;
  
      @Override
      public void create() {
          stage = new Stage(new FitViewport(2560, 1440));
          batch = new SpriteBatch();
          shapeRenderer = new ShapeRenderer();
          shapeRenderer.setAutoShapeType(true);
      }
  
      @Override
      public void render() {
          Gdx.gl.glEnable(GL20.GL_BLEND);
          Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
  
          Gdx.gl.glClearColor(0, 0, 0, .25f);
          Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
  
  
          batch.begin();
          shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
          shapeRenderer.setColor(Color.RED);
          shapeRenderer.rect(100, 25, 200, 450);
  
          shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
          shapeRenderer.setColor(Color.GREEN);
          shapeRenderer.rect(303, 24, 10, 451);
          shapeRenderer.end();
          batch.end();
  
          Gdx.gl.glDisable(GL20.GL_BLEND);
      }
  
      @Override
      public void resize(int width, int height) {
          stage.getViewport().update(width, height, true);
      }
  
      @Override
      public void dispose() {
          stage.dispose();
          batch.dispose();
          shapeRenderer.dispose();
      }
  
  }
  </code></pre>
  
  <p>I've found a thread of someone asking the same thing but in C (<a href="https://stackoverflow.com/questions/4052940/how-to-make-an-opengl-rendering-context-with-transparent-background">How to make an OpenGL rendering context with transparent background?</a>). I even tried adding a LwglAWTCanvas to a JWindow but I'm still unable to make the background transparent.</p>
  
  <p>I'd like to have a clear background so I can draw rects/shapes over the users screen.</p>
  
  <p>Thanks!</p>