LWJGL 2.9.1

Started by Matzon, December 02, 2013, 20:25:29

Previous topic - Next topic

M-ilyas

Please help
glfrustum is not working. ,
i learned that if a model has different z-axis, i will draw far and look smaller, but its not working.

my example is below..

public class Example1
{

  float z = 0f;

  public Example1()
  {
    try
    {
      Display.setDisplayMode(new DisplayMode(800, 600));
      Display.create();
      Keyboard.create();
    } catch (LWJGLException ex)
    {
      Logger.getLogger(Example1.class.getName()).log(Level.SEVERE, null, ex);
    }
   

   
    glMatrixMode(GL_PROJECTION);
    glFrustum(-5, 5, -5, 5, -5, 5);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
   

    glClearColor(0, 0, 0, 0);

    while (!Display.isCloseRequested())
    {
      if (Keyboard.isKeyDown(Keyboard.KEY_A))
      {
        z += 0.1f;
      }
      else if(Keyboard.isKeyDown(Keyboard.KEY_S))
      {
        z -= 0.1f;
      }

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glColor3f(1, 1, 1);
      glLoadIdentity();
      glBegin(GL_QUADS);
     
      glVertex3f(-0.5f, -0.5f, z);
      glVertex3f(0.5f, -0.5f, z);
      glVertex3f(0.5f, 0.5f, z);
      glVertex3f(-0.5f, 0.5f, z);
           
      glEnd();

      glFlush();
     
      Display.update();
      Display.sync(60);
    }

    Display.destroy();
    Keyboard.destroy();
  }

  public static void main(String args[])
  {
    new Example1();
  }

}