import org.lwjgl.*;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*;
public class Game {
//variables
static boolean finished = false;
// set up the window
static {
try {
Window.create("HELLO WORLD",50,50,640,480,32,0,8,0); // create a window
} catch (Exception e) { e.printStackTrace(); System.exit(0); }
}
public static void main(String argv[]) {
try {
{
Keyboard.create(); // create the keyboard, must be after creation of the window, so keyboard can focus on the window
GL.glClearColor(0.0f,0.0f,0.0f,0.0f); // set clearing color,
GL.glMatrixMode(GL.GL_PROJECTION); // init viewing values
GL.glLoadIdentity(); // reset matrix
GL.glOrtho(0.0f,1.0f,0.0f,1.0f,0.0f,0.0f); // coordinate system
}
while (!finished) {
render(); // and check for events
Window.update(); // update window state in order to handle close requests, moves and paints
Window.paint(); // paints the window, swaps buffers
}
Window.destroy();
Keyboard.destroy();
}
catch (Exception exp) { exp.printStackTrace(); }
}
public static void render() {
// handled events
if (Window.isCloseRequested()) { // is the close button clicked
finished = true; // if yes break out of the rendering loop and exit
return;
}
Keyboard.poll(); // poll keyboard
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { // is escape key pressed
finished = true; // if yes break out of the rendering loop and exit
return;
}
GL.glClear(GL.GL_COLOR_BUFFER_BIT); // clear the screen (color buffer)
GL.glColor3f(0.0f,1.0f,0.0f); // color that the square will be
GL.glBegin(GL.GL_POLYGON); // begin the square
{
GL.glVertex3f(0.25f,0.25f,0.0f); // pt 1
GL.glVertex3f(0.75f,0.25f,0.0f); // pt 2
GL.glVertex3f(0.75f,0.75f,0.0f); // pt 3
GL.glVertex3f(0.25f,0.75f,0.0f); // pt 4
}
GL.glEnd(); // end the square
}
}
this is my first lwjgl prog… i understand mostly how everything there works, which is why all it does it make a square. but when i run the program it looks like a rectangle? why is that?
thanks.
