LWJGL Forum

Please login or register.

Login with username, password and session length
Pages: 1 [2]

Author Topic: LWJGL 2.9.1  (Read 58665 times)

M-ilyas

  • Newbie
  • *
  • Offline Offline
  • Posts: 7
Re: LWJGL 2.9.1
« Reply #15 on: June 25, 2014, 19:31:49 »

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();
  }

}
Logged
Pages: 1 [2]