Skip to main content
gamedev.net
🔒 Locked

[java] Could use some basic Eclipse help with LWJGL

Started by OOBradm 4 replies 1.2k views
Original Post
OOBradm
OOBradm
I'll start out by saying roughly 2 years ago I attempted to learn OpenGL in C++, and had a very difficult time with it. Now, two years later, I've become proficient in java and would like to use my java knowledge as a base to finally learn OpenGL. I just need some help understanding the basics of how OpenGL is "imported" into my eclipse so i have access to its methods. Ive spent ~5 hours browsing the web looking at things, but i still do not have a solid understand of what im trying to do here. I'll start by asking a few questions: - It seems I need to have a SWT enabled window to attach a graphics context to in order to use openGL, is this true? - How do I set all of my classpaths and such so that I can actually use LWJGL? - Once i have eclipse set up correctly, I can use OpenGL just like I could in c++, correct? and will i have to set it up for each new project i create? UPDATE: I've gotten the jar files and the DLL's to work properly, i think, as I can import org.lwjgl.*. As of now, my mock program has no errors but it fails at link time with the following message: Exception in thread "main" java.lang.NoClassDefFoundError Which I find to be very puzzling. For some reason, i have a feeling that my CLASSPATH enviroment variable is indorrect, but right now it points to the path to my JRE, . , and the path to the lwjgl jar files. Any ideas? Thanks for the help in advance, ~Brad [Edited by - OOBradm on May 25, 2006 7:32:00 PM]
Fred304
Fred304
Quote:
Original post by OOBradm
I just need some help understanding the basics of how OpenGL is "imported" into my eclipse so i have access to its methods.

clicky

Quote:

- Once i have eclipse set up correctly, I can use OpenGL just like I could in c++, correct?

I believe you have to call glVertex3f(x, y, z) on an object of type GL or something... at least that's the way it's done in JOGL. But apart from that, the usage is just the way you are used to it, yes.

Quote:

and will i have to set it up for each new project i create?

Yes.

Quote:

Exception in thread "main" java.lang.NoClassDefFoundError

This means that your classpath is wrong. If you use the "add external JARs" from the jwgl installation notes, it should work if you start the game from eclipse.

Quote:

CLASSPATH [...] points to [...] the path to the lwjgl jar files.

You need to have the jar files themselves in the classpath, not the path containing the jar files.
OOBradm
OOBradm
Thanks, Fred. I'll try this out tomorrow after some shut eye.
OrangyTang
OrangyTang
Quote:
Original post by OOBradm
- It seems I need to have a SWT enabled window to attach a graphics context to in order to use openGL, is this true?

Ideally you'll use LWJGL's Display class to create a native display window (or fullscreen display). This is likely more robust but you won't be able to put SWT gui controls in it.

Quote:
- Once i have eclipse set up correctly, I can use OpenGL just like I could in c++, correct? and will i have to set it up for each new project i create?

Unlike C there isn't any global functions so a call like glEnable() becomes GL11.glEnable. OpenGL functions are split depending on which version/extension they belong to (so for most of the time you need GL1.1 stuff which is in GL11).

If you set things up with a LWJGL in a separate Eclipse project (as Fred's link shows) then new projects just have to list it as a dependant project, and it'll reuse all the setup you've already done (you still need to respecify the "-Djava.library.path" argument for any run configs though).
Thygrrr
Thygrrr
Quote:
Original post by princec
If you're using Java 5.0 compiler settings you can statically import GL.* methods which makes them look almost identical to C ones.


What's the exact name of the Java 5.0 language feature that does this? "Static Imports"?

It's remarkable, I'll definitely keep that in mind. Unfortunately, I make a living writing J2ME, which is stuck somewhere between Java 1.1 and Java 1.4...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.