I tried the "Basic OpenGL Rendering" Tutorial of the wiki-page, but instead of a rotating square there is only a black screen. I tried it on Mac OSX and WindowsXP. This is the Code:
package lwjgl;
import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
public class Main {
public static final String GAME_TITLE = "My Game";
private static final int FRAMERATE = 60;
private static boolean finished;
private static float angle;
public static void main(String[] args) {
boolean fullscreen = (args.length == 1 && args[0].equals("-fullscreen"));
try {
init(fullscreen);
run();
} catch (Exception e) {
e.printStackTrace(System.err);
Sys.alert(GAME_TITLE, "An error occured and the game will exit.");
} finally {
cleanup();
}
System.exit(0);
}
private static void init(boolean fullscreen) throws Exception {
Display.setTitle(GAME_TITLE);
Display.setFullscreen(fullscreen);
Display.setVSyncEnabled(false);
Display.create();
}
private static void run() {
while (!finished) {
Display.update();
if (Display.isCloseRequested()) {
finished = true;
}
else if (Display.isActive()) {
logic();
render();
Display.sync(FRAMERATE);
}
else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
logic();
if (Display.isVisible() || Display.isDirty()) {
render();
}
}
}
}
private static void cleanup() {
Display.destroy();
}
private static void logic() {
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
finished = true;
}
angle += 2.0f % 360;
}
private static void render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
GL11.glPushMatrix();
GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
GL11.glRotatef(angle, 0, 0, 1.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2i(-50, -50);
GL11.glVertex2i(50, -50);
GL11.glVertex2i(50, 50);
GL11.glVertex2i(-50, 50);
GL11.glEnd();
GL11.glPopMatrix();
}
}
Can someone help me please???