title: LWJGL - everything is gone after loading font
body: <p>I had a weird problem when I tried to display some text on the screen. I followed this tutorial <a href="http://www.ninjacave.com/slickutil3" rel="nofollow">Slick Util - TrueType Fonts for LWJGL</a>. The text was displayed properly but everything else was gone. This happens even when no text is rendered. And it will go back to normal when I remove the code to load the font.</p>
  
  <p>Here is my code:(The rectangle won't show when I have this line of code: this.font = this.loadDefaultFont(30);)</p>
  
  <pre><code>import static org.lwjgl.opengl.GL11.GL_BLEND;
  import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
  import static org.lwjgl.opengl.GL11.GL_MODELVIEW;
  import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
  import static org.lwjgl.opengl.GL11.GL_PROJECTION;
  import static org.lwjgl.opengl.GL11.GL_QUADS;
  import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
  import static org.lwjgl.opengl.GL11.glBegin;
  import static org.lwjgl.opengl.GL11.glBlendFunc;
  import static org.lwjgl.opengl.GL11.glClear;
  import static org.lwjgl.opengl.GL11.glClearColor;
  import static org.lwjgl.opengl.GL11.glColor4f;
  import static org.lwjgl.opengl.GL11.glEnable;
  import static org.lwjgl.opengl.GL11.glEnd;
  import static org.lwjgl.opengl.GL11.glLoadIdentity;
  import static org.lwjgl.opengl.GL11.glMatrixMode;
  import static org.lwjgl.opengl.GL11.glOrtho;
  import static org.lwjgl.opengl.GL11.glVertex2i;
  
  import java.awt.Font;
  
  import org.lwjgl.LWJGLException;
  import org.lwjgl.opengl.Display;
  import org.lwjgl.opengl.DisplayMode;
  import org.newdawn.slick.Color;
  import org.newdawn.slick.TrueTypeFont;
  
  public class TrueTypeFontDemo {
      private TrueTypeFont font;
  
      public TrueTypeFontDemo() {
          try {
              Display.setDisplayMode(new DisplayMode(800, 600));
              Display.setTitle("TrueTypeFont Demo");
              Display.create();
          } catch (LWJGLException e) {
              e.printStackTrace();
          }
  
          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
          glOrtho(0, 800, 600, 0, 1, -1);
          glMatrixMode(GL_MODELVIEW);
          glEnable(GL_BLEND);
          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
          this.font = this.loadDefaultFont(30);
  
          while (!Display.isCloseRequested()) {
              glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
              glClear(GL_COLOR_BUFFER_BIT);
  
              this.font.drawString(100, 100, "Hello world", Color.red);
  
              glColor4f(1.0f, 0.0f, 0.0f, 0.5f);
              glBegin(GL_QUADS);
              {
                  glVertex2i(500, 500);
                  glVertex2i(500, 50);
                  glVertex2i(600, 50);
                  glVertex2i(600, 500);
              }
              glEnd();
  
              Display.update();
              Display.sync(60);
          }
  
          Display.destroy();
      }
  
      private TrueTypeFont loadDefaultFont(int size) {
          // load a default java font
          Font awtFont = new Font("Times New Roman", Font.PLAIN, size);
          return new TrueTypeFont(awtFont, false);
      }
  
      public static void main(String[] args) {
          new TrueTypeFontDemo();
      }
  }
  </code></pre>