Hi , I am new java game dev but I am not newbie in Java ;D. Since one of the paradigm of Java is to keep it simple as possible I want to show me a tut just how to make a 3d object add move it.
First you’ll need something to help you with 3D rendering, for simply drawing a cube I’d suggest LWJGL, then I’d take a look at some tutorials for whatever tool you choose to use for your 3D rendering. (LWJGL Tutorials)
Some of the other 3D rendering tools can be found in JGO’s Java Gaming Resources section under 3D Enginges and Libraries
EDIT:
I forgot to mention that LWGL is simply a Java binding to OpenGL, it isn’t a full game library. This means you’ll have to write more boilerplate code than you would if you chose a 3D game library. LWJGL is still a good choice IMHO
Ok.I have an error
Description Resource Path Location Type
Access restriction: The type DisplayMode is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar main.java /javax.media/src line 3 Java Problem
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class DisplayExample {
public void start() {
try {
Display.setDisplayMode(new DisplayMode(800,600));
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(0);
}
// init OpenGL here
while (!Display.isCloseRequested()) {
// render OpenGL here
Display.update();
}
Display.destroy();
}
public static void main(String[] argv) {
DisplayExample displayExample = new DisplayExample();
displayExample.start();
}
}
Help?
I have never seen that error before in my life. Did you break Java? ;D
Funny thing, DisplayMode is in the LWJGL JAR file, not rt.jar. Maybe it’s using the AWT DisplayMode class? But that’s “restricted” either
How did you setup LWGJL? It looks like you get that kind of error when you try to replace a standard Java class with a custom class. I quick google found this maybe it’ll help.
Restriction? Hmm
It could be windows requiring administrator privileges to access the jars, or something is blocking them (antivirus?).
Does this error pops out on every code you type?
Check the runtime environment you have selected in Eclipse. If you have something funky like j2me selected, you’ll get this when you try to use jars with classes that are incompatible with your environment.
Sometimes it’s just Eclipse being stupid (shocker, I know) and removing lwjgl.jar from your depencies and adding it back might fix it.
Ok.On testing i got this ndowCreationTest
The following keys are available:
ESCAPE: Exit test
ARROW Keys: Move window when in non-fullscreen mode
L: List selectable display modes
0-8: Selection of display modes
F: Toggle fullscreen
SHIFT-F: Toggle fullscreen with Display.destroy()/create() cycle
Found 24 display modes
Problem retrieving mode with 640x480x24@-1
Problem retrieving mode with 800x600x24@-1
Problem retrieving mode with 1024x768x24@-1
And now i got error on line 8
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
class DisplayExample {
public void start() {
try {
Display.setDisplayMode(new DisplayMode(800,600));
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(0);
}
// init OpenGL here
while (!Display.isCloseRequested()) {
// render OpenGL here
Display.update();
}
Display.destroy();
}
public static void main(String[] argv) {
DisplayExample displayExample = new DisplayExample();
displayExample.start();
}
}
help?
Well “I get an error” is not very descriptive for us
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
at InputExample.start(InputExample.java:11)
at InputExample.main(InputExample.java:71)
Where is the problem?
Well that’s because you haven’t included the natives in the java.library.path
If you’re using Eclipse, see here how to set LWJGL properly.
Click here for Netbeans.
Ok.Now how to make a 3d object and how to move it ?
But I want it for java.
But ra4king is right anyway. You have to understand the basis of OpenGL even though you plan to use it with a Java binding (JOGL, LWJGL) and as far as I know, Nehe tutorials have been ported to both APIs.