I'd like to make a little 2d game with lwjgl and Opengl.
The Problem is, that whenever i resize the Window, the content won't resize and just staysthe old size.
Thats my current code:
I just can't see the fault.
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
public class QuadExample {
public void start() {
try {
Display.setDisplayMode(new DisplayMode(800,600));
Display.create();
Display.setResizable(true);
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(0);
}
// init OpenGL
System.out.print(Math.sqrt(4));
while (!Display.isCloseRequested()) {
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
// Clear the screen and depth buffer
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
// set the color of the quad (R,G,B,A)
GL11.glColor3f(0.5f,0.5f,1.0f);
// draw quad
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(10,10);
GL11.glVertex2f(Display.getWidth()-10,10);
GL11.glVertex2f(Display.getWidth()-10,Display.getHeight()-10);
GL11.glVertex2f(10,Display.getHeight()-10);
GL11.glEnd();
Display.update();
}
Display.destroy();
}
public static void main(String[] argv) {
QuadExample quadExample = new QuadExample();
quadExample.start();
}
}