Jiggling objects

Started by johnnyh, September 05, 2011, 01:15:45

Previous topic - Next topic

johnnyh

Hello all,  :)

As i am new with lwjgl, I am discovering new things every days and thats really exciting.

One thing really annoying is in my mind now. I have a box which is moving and I can walk and rotate the camera (FPS style). The point is that when I am walkking close to the box at about the same speed, I can see this box jiggling back and fordward a little. i suppose its because of the alternative reception of the camera order to move  and the bow order to move and back and forth ...

I would really like to solve that problem. Long life to LWJGL, thats great work.

johnnyh


Fool Running

Sounds like a rounding error. Your code would help.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

johnnyh

Hello, here is my code, I have got two classes :

First class :
package testlwjgl4;

import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;




public class TestLWJGL4 {
    private float vitesseDeplacement = 0.1f;
    private float vitesseRotation = 0.5f;
    private float dernierTemps;
    private float temps;
    FPCameraController camera = new FPCameraController(0,0,0);
    private int dx;
    private int dy;
    private float dernierTempsFPS;
    private int FPS;
    private float F=100000;//distance Fog
    private float pos=0;
    private float pos2=0;
    
    
    public void start(){
        try {
	    Display.setDisplayMode(new DisplayMode(800,600));
	    Display.create();
	} catch (LWJGLException e) {
	    e.printStackTrace();
	    System.exit(0);
	}
        
        init();
        
        while(!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)){
            refresh();
            Display.update();
            Display.sync(50);
        }
        
        Display.destroy();
        }
    ////////////////////////////////////////////////////////////////////////////
    
    
    
    
    
    
    public void init(){
        GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(70, (float)800/600, 1, F);
            //GL11.glOrtho(0, 800, 600, 0,1,1000 );
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);     
        Mouse.setGrabbed(true);
        dernierTemps=System.nanoTime()/1000000;
        dernierTempsFPS=dernierTemps;
        
    }
    
    public void refresh(){
        temps=System.nanoTime()/1000000;
        float delta = temps-dernierTemps;
        if (temps-dernierTempsFPS > 1000){
            dernierTempsFPS=temps;
            Display.setTitle("FPS : "+FPS);
            FPS=0;
        }FPS++;
        
        float distance = delta*vitesseDeplacement;
        dernierTemps=temps;
        
        dx=Mouse.getDX();
        dy=Mouse.getDY();

        camera.yaw(dx*vitesseRotation);
        camera.pitch(dy*vitesseRotation);

        if (Keyboard.isKeyDown(Keyboard.KEY_Z)){
            camera.avancer(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_S)){
            camera.reculer(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_Q)){
            camera.pasGauche(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_D)){
            camera.pasDroite(vitesseDeplacement*delta);
        }
        

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); 
        
        //Dessin Curseur
        GL11.glPushMatrix();
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glColor3f(1f,1f,1f);
            GL11.glVertex3f(-0.01f,0.01f,-2);
            GL11.glVertex3f(0.01f,0.01f,-2);
            GL11.glVertex3f(0.01f,-0.01f,-2);
            GL11.glVertex3f(-0.01f,-0.01f,-2);
            GL11.glEnd();
            
        camera.lookThrough();
        
        
        for(int i=0;i<10000;i=i+70){
            for(int j=0;j<1000;j=j+70){
                dessinCube(i,j,-100,60);
            }
        }

        
        for (int i=0;i<1000;i=i+1)
        {
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, -(i+1)*pos);
        dessinCube(i*70,-70,-30,60);
        GL11.glPopMatrix();
        }
        pos=pos+0.01f*delta;
        

//        GL11.glTranslatef(70,0, -pos2);
//        dessinCube(0,-60,-30,60);
//        pos2=pos2+0.02f*delta;
 
        
        
        GL11.glPopMatrix();
        

    }
    
    public void dessinCube(float xc, float yc, float zc, float h){
        GL11.glBegin(GL11.GL_QUADS);

            //face 1
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 2
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            
            //face 3
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            
            //face 4
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 5
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            
            //face 6
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            
        GL11.glEnd();
    }
    

    public static void main(String[] args) {
        TestLWJGL4 test = new TestLWJGL4();
        test.start();
    }
}


Second class :
package testlwjgl4;

import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;


public class FPCameraController {
    private Vector3f position;
    private float yaw=0.0f;
    private float pitch=0.0f;
    
    public FPCameraController(float x, float y, float z){
        position = new Vector3f(x,y,z);
    }
    
    public void yaw(float amount){
        yaw=yaw+amount;
    }
       
    public void pitch(float amount){
        float s=pitch+amount;
        if (s>90){
            pitch=90;
        }else if(s<-90){
            pitch=-90;
        }else{
        pitch=s;
        }
    }
    
    public void avancer(float distance){
        position.x -= distance * (float)Math.sin(Math.toRadians(yaw));
        position.z += distance * (float)Math.cos(Math.toRadians(yaw));
    }
    
    public void reculer(float distance){
        position.x += distance * (float)Math.sin(Math.toRadians(yaw));
        position.z -= distance * (float)Math.cos(Math.toRadians(yaw));
    }
    
    public void pasGauche(float distance){
        position.x -= distance * (float)Math.sin(Math.toRadians(yaw-90));
        position.z += distance * (float)Math.cos(Math.toRadians(yaw-90));
    }
    
    public void pasDroite(float distance){
        position.x -= distance * (float)Math.sin(Math.toRadians(yaw+90));
        position.z += distance * (float)Math.cos(Math.toRadians(yaw+90));
    }
    
    public void lookThrough(){
        GL11.glRotatef(-pitch, 1.0f, 0.0f, 0.0f);
        //roatate the yaw around the Y axis
        GL11.glRotatef(yaw, 0.0f, 1.0f, 0.0f);
        //translate to the position vector's location
        GL11.glTranslatef(position.x, position.y, position.z);
    }
    
}

rollins

hello. it is my first post here, but i found this forum googling about same problem. i have exactly the same problem...anyone help?

Fool Running

Quote from: johnnyh on September 06, 2011, 20:50:49
help ! :)
Ok, I've compiled and run your code and I see the problem now.
The problem is that your calculations for delta are not correct. What I think you want to do is have stuff move without depending on the frame rate. This means you need to know how much time has passed since the last frame was drawn. What you are currently doing is calculating the delta for each timer tick (i.e. how much time has passed since the last timer tick). This creates very strange results (at least in my testing). The correct value for delta is (I switched to using the LWJGL timer for my testing, but the same thing applies for the System.nanoTime()):
temps=Sys.getTime();
        float delta = (temps-dernierTemps)/(float)Sys.getTimerResolution()

This makes your movements really slow (the movements are now in units-per-second), so I had to increase the vitesseDeplacement variable by 1000x and the pos=pos+0.01f*delta had to be changed to pos=pos+10.0f*delta.

Hope that helps.  ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

johnnyh

hmmm, thats strange cause I applied your changements but my objects are still jiggling when I am running at the SAME SPEEd of the cubes .

Set vitesseDeplacement to 100 and pos=pos+100f*delta; (ie box speed to 100 too) and run after the first box, yu should see the jiggling effect.


jediTofu

For nano time, you should be dividing by 1000000000.0 in order to convert to seconds (which is what you want for the delta).

Try a higher Display.sync, like 100, doesn't really matter if you're using delta time anyway.

Also try setting vsync to true.
cool story, bro

johnnyh

Ok but it doesnt matter because its just a question of scale. If i work in millisecond, i change the speed deplacement and thats ok.

I am going to try vsync, i dont really know what it is. Did you try my code ?

Fool Running

Quote from: johnnyh on September 08, 2011, 17:14:29
hmmm, thats strange cause I applied your changements but my objects are still jiggling when I am running at the SAME SPEEd of the cubes .

Set vitesseDeplacement to 100 and pos=pos+100f*delta; (ie box speed to 100 too) and run after the first box, yu should see the jiggling effect.
Hmmmm... It looks like it is static on my screen when following it. I'm not seeing anything that I would consider "Jiggling" when following the first block at the same speed (100). Could you describe in more detail what you are seeing?
Also what OS and video card are you using?

EDIT: Could you also post your modified code. Maybe I changed something else in my testing that I forgot to post. :-\
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

johnnyh

ok here is my modified code :

first class :
package testlwjgl4;

import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;




public class TestLWJGL4 {
    private float vitesseDeplacement = 100f;
    private float vitesseRotation = 0.5f;
    private float dernierTemps;
    private float temps;
    FPCameraController camera = new FPCameraController(0,-20,0);
    private int dx;
    private int dy;
    private float dernierTempsFPS;
    private int FPS;
    private float F=100000;//distance Fog
    private float pos=0;
    private float pos2=0;
    private int cubeTerre;
    
    
    public void start(){
        try {
	    Display.setDisplayMode(new DisplayMode(800,600));
	    Display.create();
	} catch (LWJGLException e) {
	    e.printStackTrace();
	    System.exit(0);
	}
        
        init();
        
        while(!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)){
            refresh();
            Display.update();
            Display.sync(50);
        }
        
        Display.destroy();
        }
    ////////////////////////////////////////////////////////////////////////////
    
    
    
    
    
    
    public void init(){
        GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(70, (float)800/600, 1, F);
            //GL11.glOrtho(0, 800, 600, 0,1,1000 );
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);     
        buildLists();
        Mouse.setGrabbed(true);
        dernierTemps=Sys.getTime();
        dernierTempsFPS=dernierTemps;
        
    }
    
    public void refresh(){
        temps=Sys.getTime();
        float delta = (temps-dernierTemps)/(float)Sys.getTimerResolution();
        if (temps-dernierTempsFPS > 1000){
            dernierTempsFPS=temps;
            Display.setTitle("FPS : "+FPS);
            FPS=0;
        }FPS++;
        
        float distance = delta*vitesseDeplacement;
        dernierTemps=temps;
        
        dx=Mouse.getDX();
        dy=Mouse.getDY();

        camera.yaw(dx*vitesseRotation);
        camera.pitch(dy*vitesseRotation);

        if (Keyboard.isKeyDown(Keyboard.KEY_Z)){
            camera.avancer(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_S)){
            camera.reculer(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_Q)){
            camera.pasGauche(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_D)){
            camera.pasDroite(vitesseDeplacement*delta);
        }
        
        
        System.out.println("X=" +camera.getX()+"  Y="+camera.getY()+"  Z="+camera.getZ() );
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); 
        
        //Dessin Curseur
        GL11.glPushMatrix();
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glColor3f(1f,1f,1f);
            GL11.glVertex3f(-0.01f,0.01f,-2);
            GL11.glVertex3f(0.01f,0.01f,-2);
            GL11.glVertex3f(0.01f,-0.01f,-2);
            GL11.glVertex3f(-0.01f,-0.01f,-2);
            GL11.glEnd();
            
        camera.lookThrough();
        
        
        for(int i=0;i<10000;i=i+70){
            for(int j=0;j<10000;j=j+70){
                dessinCube(i,j,-100,60);
            }
        }

        
        for (int i=0;i<1000;i=i+1)
        {
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, -(i+1)*pos);
        dessinCube(i*70,-70,-30,60);
        GL11.glPopMatrix();
        }
        pos=pos+100f*delta;
        
//Avec les listes
        
//        for(int i=1;i<100;i++){
//            GL11.glTranslatef(0, 0, 20);
//            GL11.glCallList(cubeTerre);
//        }

 
        
        
        GL11.glPopMatrix();
        

    }
    
    public void dessinCube(float xc, float yc, float zc, float h){
        GL11.glBegin(GL11.GL_QUADS);

            //face 1
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 2
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            
            //face 3
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            
            //face 4
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 5
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            
            //face 6
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            
        GL11.glEnd();
    }
    
    private void buildLists(){
        cubeTerre = GL11.glGenLists(1);
        GL11.glNewList(cubeTerre, GL11.GL_COMPILE);
            GL11.glBegin(GL11.GL_QUADS);
            
            float h=10;
            float xc=10,yc=10,zc=10;
            //face 1
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 2
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            
            //face 3
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            
            //face 4
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 5
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            
            //face 6
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            
            GL11.glEnd();
        GL11.glEndList();
    }
    

    public static void main(String[] args) {
        TestLWJGL4 test = new TestLWJGL4();
        test.start();
    }
}

Second class :
[code]

package testlwjgl4;

import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;


public class FPCameraController {
    private Vector3f position;
    private float yaw=0.0f;
    private float pitch=0.0f;
    
    public FPCameraController(float x, float y, float z){
        position = new Vector3f(x,y,z);
    }
    
    public void yaw(float amount){
        yaw=yaw+amount;
    }
       
    public void pitch(float amount){
        float s=pitch+amount;
        if (s>90){
            pitch=90;
        }else if(s<-90){
            pitch=-90;
        }else{
        pitch=s;
        }
    }
    
    public void avancer(float distance){
        position.x -= distance * (float)Math.sin(Math.toRadians(yaw));
        position.z += distance * (float)Math.cos(Math.toRadians(yaw));
    }
    
    public void reculer(float distance){
        position.x += distance * (float)Math.sin(Math.toRadians(yaw));
        position.z -= distance * (float)Math.cos(Math.toRadians(yaw));
    }
    
    public void pasGauche(float distance){
        position.x -= distance * (float)Math.sin(Math.toRadians(yaw-90));
        position.z += distance * (float)Math.cos(Math.toRadians(yaw-90));
    }
    
    public void pasDroite(float distance){
        position.x -= distance * (float)Math.sin(Math.toRadians(yaw+90));
        position.z += distance * (float)Math.cos(Math.toRadians(yaw+90));
    }
    
    public void lookThrough(){
        GL11.glRotatef(-pitch, 1.0f, 0.0f, 0.0f);
        //roatate the yaw around the Y axis
        GL11.glRotatef(yaw, 0.0f, 1.0f, 0.0f);
        //translate to the position vector's location
        GL11.glTranslatef(position.x, position.y, position.z);
    }
    
    public float getX(){
        return this.position.x;
    }
    
    public float getY(){
        return this.position.y;
    }
    
    public float getZ(){
        return this.position.z;
    }
    
}

[/code]

johnnyh

And i am on OS windows 7 with ATI card.

What am I seeing is the first box a little bit blurred, i Mean jiggling while moving, when I am following it. I hope it helps.

johnnyh


Fool Running

Well, apparently I'm blind. Besides changing the time-controlling variables to longs, I can't find a difference, but my code runs significantly smoother then yours. Maybe you can spot the difference since I don't remember what I did:
public class TestLWJGL4 {
    private float vitesseDeplacement = 100.0f;
    private float vitesseRotation = 0.5f;
    private long dernierTemps;
    private long temps;
    FPCameraController camera = new FPCameraController(0,0,0);
    private int dx;
    private int dy;
    private long dernierTempsFPS;
    private int FPS;
    private float F=100000;//distance Fog
    private float pos=0;
    private float pos2=0;
    
    
    public void start(){
        try {
	    Display.setDisplayMode(new DisplayMode(800,600));
	    Display.create();
	} catch (LWJGLException e) {
	    e.printStackTrace();
	    System.exit(0);
	}
        
        init();
        
        while(!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)){
            refresh();
            Display.update();
            Display.sync(50);
        }
        
        Display.destroy();
        }
    ////////////////////////////////////////////////////////////////////////////
    
    
    
    
    
    
    public void init(){
        GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(70, (float)800/600, 1, F);
            //GL11.glOrtho(0, 800, 600, 0,1,1000 );
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);     
        Mouse.setGrabbed(true);
        dernierTemps=Sys.getTime();
        dernierTempsFPS=dernierTemps;
        
    }
    
    public void refresh(){
        temps=Sys.getTime();
        float delta = (temps-dernierTemps)/(float)Sys.getTimerResolution();
        //System.out.println(delta);
        if (temps-dernierTempsFPS > 1000){
            dernierTempsFPS=temps;
            Display.setTitle("FPS : "+FPS);
            FPS=0;
        }FPS++;
        
        float distance = delta*vitesseDeplacement;
        dernierTemps=temps;
        
        dx=Mouse.getDX();
        dy=Mouse.getDY();

        camera.yaw(dx*vitesseRotation);
        camera.pitch(dy*vitesseRotation);

        if (Keyboard.isKeyDown(Keyboard.KEY_Z)){
            camera.avancer(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_S)){
            camera.reculer(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_Q)){
            camera.pasGauche(vitesseDeplacement*delta);
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_D)){
            camera.pasDroite(vitesseDeplacement*delta);
        }
        

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        
        //Dessin Curseur
        GL11.glPushMatrix();
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glColor3f(1f,1f,1f);
            GL11.glVertex3f(-0.01f,0.01f,-2);
            GL11.glVertex3f(0.01f,0.01f,-2);
            GL11.glVertex3f(0.01f,-0.01f,-2);
            GL11.glVertex3f(-0.01f,-0.01f,-2);
            GL11.glEnd();
            
        camera.lookThrough();
        
        
        for(int i=0;i<10000;i=i+70){
            for(int j=0;j<1000;j=j+70){
                dessinCube(i,j,-100,60);
            }
        }

        
        for (int i=0;i<1000;i=i+1)
        {
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, -(i+1)*pos);
        dessinCube(i*70,-70,-30,60);
        GL11.glPopMatrix();
        }
        pos=pos+100.00f*delta;
        

//        GL11.glTranslatef(70,0, -pos2);
//        dessinCube(0,-60,-30,60);
//        pos2=pos2+0.02f*delta;
 
        
        
        GL11.glPopMatrix();
        

    }
    
    public void dessinCube(float xc, float yc, float zc, float h){
        GL11.glBegin(GL11.GL_QUADS);

            //face 1
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 2
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            
            //face 3
            GL11.glColor3f(1f,0f,0f);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            
            //face 4
            GL11.glColor3f(0f,1f,0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            
            //face 5
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc+h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc+h/2,zc-h/2);
            
            //face 6
            GL11.glColor3f(0f,0f,1.0f);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc+h/2);
            GL11.glVertex3f(xc+h/2,yc-h/2,zc-h/2);
            GL11.glVertex3f(xc-h/2,yc-h/2,zc-h/2);
            
        GL11.glEnd();
    }
    

    public static void main(String[] args) {
        TestLWJGL4 test = new TestLWJGL4();
        test.start();
    }
}


Hope that helps. ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

rollins

auch...my eyes are tired of staring at the codes, but still no help :/