title: LWJGL error "function is not supported" for GL11.glMatrixMode()
body: <p>I will post the code first then the problem below:</p>
  
  <pre><code>import java.util.Properties;
  
  import org.lwjgl.Sys;
  import org.lwjgl.input.Keyboard;
  import org.lwjgl.input.Mouse;
  import org.lwjgl.opengl.ContextAttribs;
  import org.lwjgl.opengl.Display;
  import org.lwjgl.opengl.DisplayMode;
  import org.lwjgl.opengl.GL11;
  import org.lwjgl.opengl.PixelFormat;
  
  import ref.Reference;
  import ref.Settings;
  
  public class Main implements Runnable {
  
  private static int width;
  private static int height;
  
  private long lastframe;
  private int fps;
  private long lastfps;
  
  private float rotation = 0;
  private float x = 400;
  private float y = 300;
  
  private boolean running = false;
  private Thread thread;
  private static Properties settings = new Properties();
  
  public static void main(String[] args) {
      Main game = new Main();
      Settings.load();
      settings = Settings.getSettings();  
      game.initDisplay(); 
      game.initGL();  
      game.start();
  }
  
  public void run() { 
      System.out.println("Start");    
      getDelta();
      lastfps = getTime();    
      while (!Display.isCloseRequested()) {           
          if (running) {
              int delta = getDelta();             
              tick(delta);                
              Display.sync(60);
          }           
          render();           
          updateFPS();            
          Display.update();
      }   
      if (Display.isCloseRequested()) {
          stop();
          cleanup();
      }
  }
  
  private void updateFPS() {
      if (getTime() - lastfps &gt; 1000) {
          System.out.println("FPS: " + fps);
          fps = 0;
          lastfps += 1000;
      }
      fps++;
  }
  
  private void tick(int delta) {
      System.out.println("Tick"); 
      rotation += 0.15f * delta;  
      if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) x -= 0.35f * delta;
      if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) x += 0.35f * delta;
      if (Keyboard.isKeyDown(Keyboard.KEY_UP)) y -= 0.35f * delta;
      if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) y += 0.35f * delta;
      if (x &lt; 0) x = 0;
      if (x &gt; 800) x = 800;
      if (y &lt; 0) y = 0;
      if (y &gt; 600) y = 600;       
  }
  
  private void render() {
      System.out.println("Render");
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glColor3f(0.5f, 0.5f, 1.0f);
      GL11.glPushMatrix();
      GL11.glTranslatef(x, y, 0);
      GL11.glRotatef(rotation, 0f, 0f, 0f);
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glVertex2f(x - 50, y - 50);
      GL11.glVertex2f(x + 50, y - 50);
      GL11.glVertex2f(x + 50, y + 50);
      GL11.glVertex2f(x - 50, y + 50);
      GL11.glEnd();
      GL11.glPopMatrix();
  }
  
  private void cleanup() {
      Mouse.destroy();
      Keyboard.destroy();
      Display.destroy();
  }
  
  public void initGL() {  
      System.out.println("initGL");
      GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);  
      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, 800, 0, 600, 1, -1);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);
  }
  
  public void initDisplay() {
      System.out.println("initDisplay");
  
      try {
          width = Integer.parseInt(settings.getProperty("width"));
          height = Integer.parseInt(settings.getProperty("height"));      
          Display.setDisplayMode(new DisplayMode(width, height));
          Display.setTitle(Reference.WINDOWTITLE);
          Display.create();
          Keyboard.create();
          Mouse.create();
      } catch (Exception e) {
  
      }
  }
  
  public void start() {
      if (running) return;
      running = true;
      thread = new Thread(this, "Display");
      thread.start();
  }
  
  public void stop() {
      if (!running) return;
      running = false;
      try {
          thread.join();
      } catch (Exception e) {
  
      }
  }
  
  private long getTime() {
      return (Sys.getTime() * 1000) / Sys.getTimerResolution();
  }
  
  public int getDelta() {
      long time = getTime();
      int delta = (int) (time - lastframe);
      lastframe = time;   
      return delta;
  }
  
  }
  </code></pre>
  
  <p>Now when starting it I get thie error:</p>
  
  <pre><code>initDisplay
  initGL
  Exception in thread "main" java.lang.IllegalStateException: Function is not supported
      at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58)
      at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:2075)
      at Main.initGL(Main.java:127)
      at Main.main(Main.java:41)
  </code></pre>
  
  <p>This is basically the code from the LWJGL Wiki, I was just copying it to see if the thread works and ran into this. It's a new thing to me so can anybody maybe help and tell me what is incorrect? Because I don't get it.</p>
  
  <p>Line 127 is the first line of initGL() (I deleted empty lines for this so it's not 127 anymore, but that was the line where the error happened):</p>
  
  <pre><code>GL11.glMatrixMode(GL11.GL_PROJECTION);
  </code></pre>
  
  <p>Works fine without the thread btw </p>