I can’t find documentation on where to install LWJGL to. Assuming that java is installed to D:\j2sdk1.4.1_03, where should I extract LWJGL to?
Thanks.
-Nick
I can’t find documentation on where to install LWJGL to. Assuming that java is installed to D:\j2sdk1.4.1_03, where should I extract LWJGL to?
Thanks.
-Nick
whatever folder you want to…
just make sure that the lwjgl.jar is on the classpath (-cp <dir\to\lwjgl>lwjgl.jar) and that the lwjgl.dll is on your library path (or same dir as where you are executing) (-Djava.library.path=<dir\to\lwjgl>)
When I dl the zip file with lwjgl and extract it to a folder there is a lwjgl.jar file. Do I need to extract that as well?
Also how do I run a class file that uses lwjgl? what besides C:<dir>\java test do I have to type in the command line?
I am relly having trouble geting anyhing lwjgl to run. I exract the zip to a directory and set the class path to that directory. I have the dll in the same directory as that of the file I am trying to run but I keep getting the
NoSuchMethodError’s for org.lwjgl.Display.create
location:class org.lwjgl.opengl.GL
and
symbol : method destroy ()
location: class org.lwjgl.Display
Display.destroy();
what am I doing wrong with the setup of lwjgl?
You need to set your classpaths explicitly to the jars not just the directory they are in…
java -classpath .;lwjgl.jar;examples.jar SomeTest
You are also going to have to make sure the dll is in your library path… either in a directory that is set in PATH or use
-Djava.library.path=.
Thanx I figured it out. I was using demos from .5 with lwjgl .6 in which methods like create and desroy were depreciated
I’m using Windows XP Home. I’ve set the classpath in environment variables to c:\lwjgl\ and extracted all files in the .zip to there. I also extracted all files to where the .java I’m trying to compile is. I get the error
D:\PROGRAM FILES\Xinox Software\JCreator LE\MyProjects\lwjgl test\Game.java:1: package org.lwjgl does not exist
import org.lwjgl.*;
Any ideas?
Did you set your classpath to the jars in your directory, or just the directory itself?
ie:
CLASSPATH=C:\mydir\lwjgl.jar;C:\mydir\another.jar
or
CLASSPATH=C:\mydir
the first should work…
Woo hoo! I got it to work! 
Now the trick is getting it to compile. I’m taking the code directly from the skeleton code from the documentation at java-game-lib.sourceforge.net. Here are my problems:
Display.Create(…) Doesn’t exist anymore. What replaced it?
It doesn’t know what GL is. Do I need to reference other .jar files other than lwjgl.jar?
it say swapBuffers(…) is private. So how do I use it?
And it has no idea what display.destroy is. For reference, I’ve posted the code I copied below.
import org.lwjgl.*;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*;
import java.nio.*;
public final class Game {
static {
try {
//find first display mode that allows us 640*480*16
int mode = -1;
DisplayMode[] modes = Display.getAvailableDisplayModes();
for (int i = 0; i < modes.length; i++) {
if (modes[i].width == 640
&& modes[i].height == 480
&& modes[i].bpp >= 16) {
mode = i;
break;
}
}
//select above found displaymode
Display.create(modes[mode], false);
System.out.println("Created display.");
} catch (Exception e) {
System.err.println("Failed to create display due to " + e);
System.exit(1);
}
}
public static final GL gl = new GL();
public static final GLU glu = new GLU(gl);
static {
try {
gl.create();
System.out.println("Created OpenGL.");
} catch (Exception e) {
System.err.println("Failed to create OpenGL due to " + e);
System.exit(1);
}
}
/** Is the game finished? */
private static boolean finished;
/** A rotating square! */
private static float angle;
/**
* No construction allowed
*/
private Game() {
}
public static void main(String[] arguments) {
try {
init();
while (!finished) {
Keyboard.poll();
mainLoop();
render();
gl.swapBuffers();
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
cleanup();
}
}
/**
* All calculations are done in here
*/
private static void mainLoop() {
angle += 1f;
if (angle > 360.0f)
angle = 0.0f;
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
finished = true;
}
}
/**
* All rendering is done in here
*/
private static void render() {
gl.clear(GL.COLOR_BUFFER_BIT);
gl.pushMatrix();
gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f);
gl.rotatef(angle, 0, 0, 1.0f);
gl.begin(GL.QUADS);
{
gl.vertex2i(-50, -50);
gl.vertex2i(50, -50);
gl.vertex2i(50, 50);
gl.vertex2i(-50, 50);
}
gl.end();
gl.popMatrix();
}
/**
* Initialize
*/
private static void init() throws Exception {
System.out.println("Press the ESCAPE key to exit");
Keyboard.create();
//reset time
Sys.setTime(0);
//set priority of this process
Sys.setProcessPriority(Sys.LOW_PRIORITY);
//print timer resolution info
System.out.println("Timer resolution: " + Sys.getTimerResolution() + " ticks per second");
// Go into orthographic projection mode.
gl.matrixMode(GL.PROJECTION);
gl.loadIdentity();
glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight());
gl.matrixMode(GL.MODELVIEW);
gl.loadIdentity();
gl.viewport(0, 0, Display.getWidth(), Display.getHeight());
//lets print out some info
ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4);
num_tex_units_buf.order(ByteOrder.nativeOrder());
int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf);
gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr);
System.out.println(
"Number of texture units: " + num_tex_units_buf.getInt());
}
/**
* Cleanup
*/
private static void cleanup() {
Keyboard.destroy();
gl.destroy();
Display.destroy();
}
}
The skeleton code is old and outdated - use one of the examples in the cource distribution for now.
I’m assuming you’re talking about lwjgl_examples.jar?
Not quite - the jar contains the class files but you need the java files. They are in the source distribution on SF.
Too late. I used a decompiler. ;D
[quote]Too late. I used a decompiler. ;D
[/quote]
ROFL! ;D