title: Transparent background behind font
body: <p>With LWJGL and OpenGL, I want to draw a textured rectangle. 
  Above that, I want to write some Text using the Slick Library. 
  My Problem is that when I draw the Text before the rectangle, the font has a transparent background. See it here:</p>
  
  <p><img src="https://i.stack.imgur.com/qToos.png" alt="enter image description here"></p>
  
  <p>If I draw the text after the rectangle, I cant see it. Now I've googled about an hour and found several possible solutions but none worked for me.</p>
  
  <p>The Code : </p>
  
  <p>FontVeranda.java</p>
  
  <pre><code>    /*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package bunchofpunch.fonts;
  
  import java.nio.FloatBuffer;
  import org.lwjgl.opengl.GL11;
  import org.newdawn.slick.SlickException;
  import org.newdawn.slick.UnicodeFont;
  import org.newdawn.slick.font.effects.ColorEffect;
  
  /**
   *
   * @author Alex
   */
  public class FontVeranda 
  {
      private UnicodeFont font;
      private boolean shouldRenderFont = true;
  
      public void loadFont()
      {
          java.awt.Font awtFont = new java.awt.Font("Veranda", java.awt.Font.BOLD, 14);
          font = new UnicodeFont(awtFont);
          font.getEffects().add(new ColorEffect(java.awt.Color.black));
          font.addAsciiGlyphs();
          try {
              font.loadGlyphs();
          } catch (SlickException e) {
              e.printStackTrace();
              System.exit(-1);
          }
      }
  
      public void toggleRender()
      {
          if(shouldRenderFont){
              shouldRenderFont = false;
          }else{
              shouldRenderFont = true;
          }
      }
      public void toggleRender(boolean doRender)
      {
          shouldRenderFont = doRender;
      }
  
      public void renderFont(float x, float y, String text, FloatBuffer orthographicProjectionMatrix, FloatBuffer perspectiveProjectionMatrix)
      {
          if(!shouldRenderFont) { return; }
  
          GL11.glMatrixMode(GL11.GL_PROJECTION);
          GL11.glLoadMatrix(orthographicProjectionMatrix);
          GL11.glMatrixMode(GL11.GL_MODELVIEW);
  
              GL11.glPushMatrix();
  
                  GL11.glLoadIdentity();
                  GL11.glDisable(GL11.GL_LIGHTING);
  
                  font.drawString(x, y, text);
  
                  GL11.glEnable(GL11.GL_LIGHTING);
  
              GL11.glPopMatrix();
  
          GL11.glMatrixMode(GL11.GL_PROJECTION);
          GL11.glLoadMatrix(perspectiveProjectionMatrix);
          GL11.glMatrixMode(GL11.GL_MODELVIEW);
      }
  }
  </code></pre>
  
  <p>Thats how I call it : </p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package bunchofpunch.game;
  
  import bunchofpunch.fonts.FontVeranda;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import org.lwjgl.LWJGLException;
  import static org.lwjgl.opengl.GL11.*;
  import org.lwjgl.opengl.GLContext;
  
  /**
   *
   * @author Alex
   */
  public class GameScreenHUD extends GameScreen
  {
      float space = 20f;
      float width = 250f;
      float height = 200f;
  
      World world;
  
      public GameScreenHUD(World world){this.world = world;}
  
      @Override
      public void renderScreen() {
  
          //this is a instace of "FontVeranda.java"
          world.font.renderFont(Game.WIDTH-width+50, Game.WIDTH-height-space-160, "My Text is here", 
          World.orthographicProjectionMatrix, World.perspectiveProjectionMatrix);
  
          glMatrixMode(GL_PROJECTION);
          glLoadMatrix(World.orthographicProjectionMatrix);
          glMatrixMode(GL_MODELVIEW);
  
              glPushMatrix();
  
                  glLoadIdentity();
                  glDisable(GL_LIGHTING);
  
                  TextureManager.hud.bind();
  
                  glBegin(GL_QUADS);
  
                      glTexCoord2f(0, 1);
                      glVertex2f(Game.WIDTH-space-width, Game.HEIGHT-space);
                      glTexCoord2f(1, 1);
                      glVertex2f(Game.WIDTH-space, Game.HEIGHT-space);
                      glTexCoord2f(1,0);
                      glVertex2f(Game.WIDTH-space, Game.HEIGHT-height-space);
                      glTexCoord2f(0, 0);
                      glVertex2f(Game.WIDTH-space-width, Game.HEIGHT-height-space);
  
                  glEnd();
  
                  glEnable(GL_LIGHTING);
  
              glPopMatrix();
  
          glMatrixMode(GL_PROJECTION);
          glLoadMatrix(World.perspectiveProjectionMatrix);
          glMatrixMode(GL_MODELVIEW);
      }
  
  }
  </code></pre>