I tried my best to fix this code to compile with version 0.94a but I still have problems:
Severity Description Resource In Folder Location Creation Time
2 The imported type org.lwjgl.opengl.Win32Display is not visible Lesson01.java Lesson01/lesson01 line 12 December 26, 2004 12:51:09 PM
2 Window cannot be resolved Lesson01.java Lesson01/lesson01 line 65 December 26, 2004 12:51:09 PM
2 Window cannot be resolved Lesson01.java Lesson01/lesson01 line 84 December 26, 2004 12:51:09 PM
2 Window cannot be resolved Lesson01.java Lesson01/lesson01 line 97 December 26, 2004 12:51:09 PM
2 Window cannot be resolved Lesson01.java Lesson01/lesson01 line 135 December 26, 2004 12:51:09 PM
2 Window cannot be resolved Lesson01.java Lesson01/lesson01 line 138 December 26, 2004 12:51:09 PM
2 The method getHeight() is undefined for the type Display Lesson01.java Lesson01/lesson01 line 172 December 26, 2004 12:51:09 PM
2 The method getWidth() is undefined for the type Display Lesson01.java Lesson01/lesson01 line 172 December 26, 2004 12:51:09 PM
2 Window cannot be resolved Lesson01.java Lesson01/lesson01 line 187 December 26, 2004 12:51:09 PM
/*
* This Code Was Created By Jeff Molofee 2000
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing This Code, Making It More Flexible!
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/
import org.lwjgl.util.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Win32Display;
import org.lwjgl.opengl.glu.GLU;
import org.lwjgl.input.Keyboard;
/**
* @author Mark Bernard
* date: 16-Nov-2003
*
* Port of NeHe's Lesson 1 to LWJGL
* Title: Setting Up An OpenGL Window
* Uses version 0.8alpha of LWJGL http://www.lwjgl.org/
*
* Be sure that the LWJGL libraries are in your classpath
*
* Ported directly from the C++ version
*
* 2004-05-08: Updated to version 0.9alpha of LWJGL.
* Changed from all static to all instance objects.
*/
public class Lesson01 {
private boolean done = false;
private boolean fullscreen = false;
private final String windowTitle = "NeHe's OpenGL Lesson 1 for LWJGL (Setting Up An OpenGL Window)";
private boolean f1 = false;
/**
* Everything starts and ends here. Takes 1 optional command line argument.
* If fullscreen is specified on the command line then fullscreen is used,
* otherwise windowed mode will be used.
* @param args command line arguments
*/
public static void main(String args[]) {
boolean fullscreen = false;
if(args.length>0) {
if(args[0].equalsIgnoreCase("fullscreen")) {
fullscreen = true;
}
}
Lesson01 l1 = new Lesson01();
l1.run(fullscreen);
}
/**
* Launch point
* @param fullscreen boolean value, set to true to run in fullscreen mode
*/
public void run(boolean fullscreen) {
this.fullscreen = fullscreen;
try {
init();
while (!done) {
mainloop();
render();
Window.update();
}
cleanup();
}
catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
/**
* All updating is done here. Key and mouse polling as well as window closing and
* custom updates, such as AI.
*/
private void mainloop() {
Keyboard.poll();
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { // Exit if Escape is pressed
done = true;
}
if(Window.isCloseRequested()) { // Exit if window is closed
done = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_F1) && !f1) { // Is F1 Being Pressed?
f1 = true; // Tell Program F1 Is Being Held
switchMode(); // Toggle Fullscreen / Windowed Mode
}
if(!Keyboard.isKeyDown(Keyboard.KEY_F1)) { // Is F1 Being Pressed?
f1 = false;
}
}
private void switchMode() {
Window.destroy();
fullscreen = !fullscreen;
try {
createWindow();
}
catch(Exception e) {
e.printStackTrace();
System.exit(0);
}
initGL();
}
/**
* For rendering all objects to the screen
* @return boolean for success or not
*/
private boolean render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
GL11.glLoadIdentity(); // Reset The Current Modelview Matrix
return true;
}
/**
* Create a window depending on whether fullscreen is selected
* @throws Exception Throws the Window.create() exception up the stack.
*/
private void createWindow() throws Exception {
if (fullscreen) {
DisplayMode d[] = Display.getAvailableDisplayModes(0,1,2,3,4,5,6,7);
int mode = 0;
for (int i = 0; i < d.length; i++) {
if (d[i].getWidth() == 640
&& d[i].getHeight() == 480
&& d[i].getBitsPerPixel() == 32) {
mode = i;
break;
}
}
Window.create(windowTitle, 32, 0, 8, 0);
}
else {
Window.create(windowTitle, 0, 0, 640, 480, 32, 0, 8, 0);
}
}
/**
* Do all initilization code here. Including Keyboard and OpenGL
* @throws Exception Passes any exceptions up to the main loop to be handled
*/
private void init() throws Exception {
createWindow();
Keyboard.create();
initGL();
}
/**
* Initialize OpenGL
*
*/
private void initGL() {
GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
GL11.glClearDepth(1.0); // Depth Buffer Setup
GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do
GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
GL11.glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(
45.0f,
(float) Display.getWidth() / (float) Display.getHeight(),
0.1f,
100.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix
// Really Nice Perspective Calculations
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}
/**
* Cleanup all the resources.
*
*/
private void cleanup() {
Keyboard.destroy();
Window.destroy();
}
}