Some LWJGL 3d help?

Hello All!
I am currently trying to learn opengl 3d rendering. I am using LWJGL as my engine. But I have got this problem. I follow tutorials from all over the internet, but when I run it in Eclipse, I just get a black screen:

This is the source code:


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

public class Main {
    
	public static void main(String args[]) {
		Main game = new Main();
		game.run();
	}
	
	private void run() {
		
		try {
			Display.setDisplayMode(new DisplayMode(500, 400));
			Display.setTitle("Hello World!");
			Display.create();
		} catch (LWJGLException ex) {
			ex.printStackTrace();
			System.exit(0);
		}
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(45.0f,((float)500)/((float)400),0.1f,100.0f);
		glEnable(GL_DEPTH_TEST);
		glMatrixMode(GL_MODELVIEW);
		
		while (!Display.isCloseRequested()) {
			
			render();
			
			Display.update();
			Display.sync(60);
			
			if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
				System.exit(0);
			}
		}
		
	}
	
	public static void render() {
		
		glPushMatrix();
		
		glColor3f(0.0f, 0.5f, 0.0f);
		
		glBegin(GL_QUADS);
			glVertex3f(0.0f, 1.0f, 0.0f);
			glVertex3f(0.0f, 1.0f, -1.0f);
			glVertex3f(1.0f, 1.0f, -1.0f);
			glVertex3f(1.0f, 1.0f, 0.0f);
		glEnd();
		
		glPopMatrix();
		
	}
	
}


Please Help! If you have any more questions, then ask!

Some things:

First of all, you forgot glClear. You have to call it in order for the quad to be visible. So your code should look like this:

      while (!Display.isCloseRequested()) {
         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	  
    	 render();
         
         Display.update();
         Display.sync(60);
         
         if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
            System.exit(0);
         }
      }

The second thing; The coordinates of your quad were pretty weird, especially the z-coords:

glVertex3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, 0.0f);

I think you missunderstood something here. The function’s parameters are like following:
glVertex3f(x, y, z);

The z-axis is in your case the depth of the whole scene. The way you specified the z-coords would mean that your quad had some weird rotation. Also, some coordinates have the same x and y coordiantes which doesn’t really make sense in this case. I changed the coordinates a little bit so that the quad gets displayed:

glBegin(GL_QUADS);
	      glVertex3f(-1.0f, 1.0f, -5.0f);
	      glVertex3f(1.0f, 1.0f, -5.0f);
	      glVertex3f(1.0f, -1.0f, -5.0f);
	      glVertex3f(-1.0f, -1.0f, -5.0f);
glEnd();

The third thing; You don’t seem to be really familiar with the OpenGL coordinate system or other basic stuff. You better stick to 2D rendering for a little bit longer to gain more knowledge.


The fourth thing; Immediate mode is wicked (yes, wicked)! It appeared in the first OpenGL version (if I’m right) which was released around 1992. I think it should be quite obvious that it is by now totally deprecated. In newer OpenGL versions these functions don’t even exist anymore. You should better skip Immediate-Mode rendering and start with more modern techniques like using VAOs & VBOs or whatever.

Edit: This post should help you: http://www.java-gaming.org/topics/hello/24411/msg/205121/view.html#msg205121

Hi!
Thanks for youre help! :) I think I will try a bit more of 2d! Thanks for youre help ;D