Skip to main content
gamedev.net
🔒 Locked

[java] Using JOGL with Eclipse on Intel Mac

Started by elford 4 replies 1.5k views
Original Post
elford
elford
I've having a difficult time getting JOGL and Eclipse 3.2 set up on my Intel Mac. I've added the 3 jnilib native librarys to /Library/Java/Extensions and jogl.jar to the build classpath, but Eclipse is still unable to find any of the packages I need. I found this previous thread on a related topic: http://www.gamedev.net/community/forums/topic.asp?topic_id=351573, but the ideas posted there haven't helped me get a working JOGL applicaion yet. Anyone have experience with this situation?
elford
elford
I'm still having problems, but to clarify what I've done so far, I've tried moving jogl.jar to the /Library/Java/Extensions folder too, and it still doesn't work. I've told Eclipse to Add External Jar to its class path, and pointed it to the jogl.jar file, as well as told it that the jnilib files are located in /Library/Java/Extensions.

I have an example piece of code using JOGL I found on the Net that I'm trying to get to run. It compiles fine, but I get the runtime error "Exception in thread "main" java.lang.Error: Unresolved compilation problem" and all references to anything GL are highlighted as an error. Eclipse can't make heads or tails of the "import net.java.games.jogl.*;" statement because it can't find that library.

Again, can anyone assist me? All help is greatly appreciated.
Michael Nischt
Michael Nischt
You probably have to set the library path -Djava.library.path="path_to_jogl_native_libs". I don't no about much about eclipse, but in netbeans you can specify VM args and I guess thats possible there to.

I also recommend not to put the jogl files in the extension folder, because AFAIK this breaks webstart apps that require jogl libs of another version. Btw. it seems you using an old one because of the net.java.games.jogl package, new ones have the main classes located in javax.media.opengl. AFAIK the old native libs don't run on intel macs, better get the latest beta or nighlty build from http://jogl.java.net.

Again I don't know eclipse, but it should be sufficient to add the jogl.jar file to the project and set the library path to the native libs, e.g. -Djava.library.path="/Users/John Doe/Code/Library/OpenGL/"

hope that helps
elford
elford
This is a step in the right direction!

I've made a folder for the jogl.jar and the native libraries and put it at /Users/Me/jogl/. I then told Eclipse where to find the jogl.jar and the native libraries at this new location. I was using the nightly build for the Mac OS X Universal binary from last night because I knew the PPC versions don't work with Rosetta. I also added the VM arguement to the native library in Eclipse.

As I stated, I was tryign to run a demo I found online (http://today.java.net/pub/a/today/2003/09/11/jogl2d.html). I wasn't aware that the libraries are now located at javax.media.opengl. I changed the import statement to this, and most of the build errors I was facing went away. However, there are still a few build errors left, which I'm assuming is because the example is older. One of the specific errors is on the line:
GL gl = drawable.getGL();
with the error "getGL is undefined for the type GLDrawable"
Can anyone tell me what the prefered method for setting this up now is? Links to up-to-date example code is also much appreciated.
Michael Nischt
Michael Nischt
GLAutoDrawable was introduced in the new version and is roughly similiar to the old GLDrawable, which is still present but without the mentioned methods. Note that GLCanvas/GLJPanel, which implement the new interface, are created differently:

final GLCanvas canvas = new GLCanvas();.. // set properties like sizefinal GLCapabilities caps = new GLCapabilities();.. // set properties like the depth-bitsfinal GLDrawableFactory factory = GLDrawableFactory.getFactory();factory.getGLDrawable(canvas, caps, new DefaultGLCapabilitiesChooser());.. // create GLEventListenercanvas.addGLEventListener(..);


I don't know if that's important for application you're trying to port, but two other important changes are:
Some methods of the GL Object with arrays in the methods signature now require an additional int compared to the old or the C OpenGL Versions, an offset. Just use 0 there. Further java nio Buffers' position is now important, so you have to rewind a newly filled one.

There are still a lot more changes, therfore have look at the official jogl support forum at javagaming.org. The first, sticky topic JSR-231 beta 5 released (last beta before 1.0) probably has some interesting information for you.
Michael Nischt
Michael Nischt
You can find some small examples here: NeHe Java ports (using the new JSR-231 api - javax.media.opengl).
Note that at nehe.gamedev.net only source code for the old libs can be downloaded - you could use those for 'learning by comparing' :)

Topic Locked

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

Sign in to reply to this topic.