JOGL in Eclipse

(Need Java)

Intro

This tutorial is meant to be a lesson on how to setup an eclipse project using jogl; hopefully it will be found useful. The opengl code is based on the excellent NeHe lessons 01-05. You should have basic knowledge of java, eclipse and jogl/opengl.

What you need

Create Project

The first thing you need to do is create a new project. I suggest using java 1.4 if you plan on doing a public binary release. I also like having separate folders for my source and class files.


Add Dependencies

Create a new directory in your project called lib. Add jogl.jar and gluegen-rt.jar to the new lib directory. Take the platform specific libraries libjogl/libjogl_cg/libjogl_awt/libgluegen-rt and place them in the top level directory of your project. Go to Project->Properties->Java Build Path and switch to the Libraries tab. Add jogl.jar and gluegen-rt.jar.


Your project should now look something like this:


Now place the jogl source zip (jogl-1.1.0-src.zip) in the lib directory. Hit ctrl+shift+t you should be prompted to enter a class name. Type GLEventListener and hit OK.

Notice that there is no source? Click Attach source and add the jogl source zip (jogl-1.1.0-src.zip).


The first classes

Right click on the source directory and go to New->Class. Set the name and package as desired. Add the interface of GLEventListener.


This should have created a new class and stubbed in the interfaces methods with the correct variable names. You can fill in the methods with the code from this file: Lesson01.java. If you want more information on what is actually going on in this file I suggest the NeHe tutorials and the jogl javadoc. Now you will need classes to launch this file in either an applet or a frame. Add these two files to your project: Lesson01Applet.java Lesson01Window.java. Launching the window should be straight forward. However the applet you will have to set its working directory to the root of your project.


Files

Additional Resources.


Home