[SOLVED] LWJGL Visual Illusion Problem

Hi, so I obtained source code from http://www.youtube.com/watch?v=O0xtgfcxcq0&feature=plcp but noticed a strange visual effect.

I plugged in the code and when looking directly down onto a block this occurred.

I have jumped around with learning OpenGL but I’ve firmly started recently but I havn’t been able to resolve the issue, yet.

Here is parts of the code that hopefully explains the problem

      static int width=800, height=600;
// ---------------------------------------------------------------------------------
		DisplayMode dm = new DisplayMode(width,height);
		for(DisplayMode mode : Display.getAvailableDisplayModes()){
			if(mode.getWidth() == 800 && mode.getHeight() == 600 && mode.isFullscreenCapable() && mode.getBitsPerPixel() == 32){
				dm = mode;
				break;
			}
		}
		if(dm.isFullscreenCapable()) Display.setFullscreen(false);
		Display.setDisplayMode(dm);
		Display.create();
// ------------------------------------------------------------------------------------

	private void initGL3() {
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glLoadIdentity();

		GLU.gluPerspective((float) 100, App.width / App.height, 0.001f, 1000);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);

		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glShadeModel(GL11.GL_SMOOTH);
		GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
		GL11.glClearDepth(1.0f);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glDepthFunc(GL11.GL_LEQUAL);
	}

//    This is one of the crates that are being drawn.
//    float startX, float startY, float startZ, float endX, float endY, float endZ, Texture texSurround
		collidable.add(new PolyVoxel(20, 0.1f, 2, 22, 2, 4, texCrate));

// Rotation values are created from mouse movement (FPS camera).
	public void translateCamera() {
		GL11.glRotatef(rotation.x, 1, 0, 0);
		GL11.glRotatef(rotation.y, 0, 1, 0);
		GL11.glRotatef(rotation.z, 0, 0, 1);
		GL11.glTranslatef(-vector.x, -vector.y - 1.4f, -vector.z);
	}

Sorry for the long post, if someone could point me in the right direction I would be grateful, thanks for your time.

Your call to GLU.gluPerspective() most likely screws up the aspect ratio. App.width and App.height are both ints, right? That means that App.width / App.height = 1 in most cases since effectively the decimals are getting cut off. You should just change it to

(float)App.width / App.height

which should solve the problem.

That usually means you’ve got your aspect ratio (second parameter to gluPerspective) wrong.

Are App.width and App.height ints? Because you may be getting integer divide so your aspect is incorrectly 1 rather than 1.6 (or whatever).

Edit: Spooky double post! :persecutioncomplex:

18 seconds too slow, sucker! ;D

Excellent! Thank you so much, that solved the issue. (Credits go to the answer that is 18 seconds faster of course :point:)

Yatta! 8)