Java does not natively support accessing the OpenGL API. A wrapper library called “JOGL” was introduced to ease the pain of making this integration happen. JOGL allows access to most features available to C programming language programmers, with the notable exception of window-system related calls in GLUT (as Java contains its own windowing systems, AWT and Swing), and some extensions.
JOGL homepage is located at http://kenai.com/projects/jogl/pages/Home. The JOGL team has made the wrapper available for all widely popular platforms Windows, Linux, Solaris and Mac. There nightly builds can be obtained from http://download.java.net/media/jogl/builds/nightly/ you can download the platform specific JOGL package from here. The zip downloaded should be extracted and the installation instructions can be found in Userguide.html included in the zip.
The basic install procedure requires setting environment variables. On the windows platform this can be achieved by going to Control panel > System > Advanced tab.
Extract the contents of the zip downloaded to lets say c:\jogl, inside it you will find the “lib” folder. If a value for CLASSPATH doesn’t already exist in the environment variables, then create one and you in the paths for these files jogl.all.jar, nativewindow.all.jar, gluegen-rt.jar and optionally newt.all.jar. The path might eventually look something like the following:
.;c:\jogl\lib\jogl.all.jar;c:\jogl\lib\nativewindow.all.jar;c:\jogl\lib\gluegen-rt.jar;c:\jogl\lib\newt.all.jar
Make sure there is a “.” at the start or end of the path, this is required for java applications to work properly.
The next step is to put the lib path in the PATH environment variable, just find the PATH environment variable, click edit and then append “;c:\jogl\lib” to it.
There is a sample code attached at the end of the tutorial which should work once the above steps have been completed.
Normally this is what is required to setup JOGL however the easiest and speedier method to get started is to use Netbeans.
Using Netbeans
Download Netbeans, probably the best IDE for java developers from http://www.netbeans.org, make sure the package you download includes “Java SE”. Once the download is complete, follow the installation instructions to complete the install.
Now download the Netbeans OpenGL pack from http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3260, once the download is complete extract the contents of the zip.
If you are using Windows vista or Windows 7, you will need to start Netbeans as an administrator, you can do this by right clicking on the Netbeans icon and clicking on “Run as Administrator”. Once Netbeans has been fully loaded go to the “Tools” menu and click “Plugins”. Now in the dialogue box click the Settings tab and tick the option “force install into shared directories”. Now goto the “Downloaded” tab and click “Add plugins” and browse for the extracted folder contents, select all the files in the folder and click open.
After that click the install button and follow instructions to complete the install procedure, you will be required to restart Netbeans after the plugin installations are complete.
The following screenshot shows how the plugin files are selected and opened.
After restart, now Netbeans is ready for you to start coding away amazing OpenGL based applications.
To test your installation, click on File menu in Netbeans, click “New Project”, select Java from the list and then select “JOGL Application” from the second list, click next and set your project preferences and click Finish. This will load a simple JOGL project, which can act as a guide for you to get started with OpenGL development in Java. Just build and run the application to see OpenGL in action. Some more sample JOGL projects are also available for testing in the “Samples” section of the Project type list.
Obtaining Help
As JOGL is a work in progress, it is recommended to follow the wiki and the forum on regular basis to keep you updated with the latest developments. A lot of source code found around the internet would be obsolete as it would belong to the earlier versions of the JOGL.
User Guide: http://download.java.net/media/jogl/doc/userguide/
Java Docs for JOGL 2.x: http://download.java.net/media/jogl/jogl-2.x-docs/
JOGL Demos: http://download.java.net/media/jogl/demos/www/


Comments