I am trying out the LWJGL library, but I am a little confused. When I try to render a quad with 2d vertices: glVertex2f(0, 0); glVertex2f(0, 1000); glVertex2f(1000, 1000); glVertex2f(1000, 0);, then everything seems fine, but when I use the code below, I only see a black screen. Am I using the wrong coordinates, so it doesn't show up on the screen, or is something else wrong?
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.util.glu.GLU.*;
import static org.lwjgl.opengl.GL11.*;
public class main {
public void start() throws LWJGLException {
int height = 600;
int width = 800;
DisplayMode standard = new DisplayMode(width, height);
Display.setDisplayMode(standard);
Display.create();
// init OpenGL here
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, 0, -1);
glMatrixMode(GL_MODELVIEW);
while (!Display.isCloseRequested()) {
// clear the screen and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set the color of the quad (R,G,B,A)
glColor3f(0.5f, 0.5f, 1.0f);
// draw quad
glBegin(GL_QUADS);
glVertex3f(0, 0, 10);
glVertex3f(0, 1000, 10);
glVertex3f(1000, 1000, 10);
glVertex3f(1000, 0, 10);
glEnd();
Display.update();
}
Display.destroy();
}
public static void main(String[] argv) throws LWJGLException {
main displayExample = new main();
displayExample.start();
}
}