If you're planning to develop a game engine or other Java software that needs 3D graphics, consider using Java Binding for OpenGL (JOGL). This low-level Java API acts as a bridge to the underlying platform's OpenGL technology. In this installment of the Open source Java projects series, Jeff Friesen introduces JOGL. Learn how to use JOGL to bring OpenGL's high performance and powerful features (such as shaders) to your Java-based games.
The open source Java Binding for OpenGL (JOGL) project introduces hardware-supported 3D graphics to Java programs running on Solaris, Linux, Windows, and Mac OS X platforms. JOGL provides access to the OpenGL 2.0 APIs, and to most OpenGL vendor extensions. Also, JOGL supports Java 1.4 and later versions.
Here are some more facts about JOGL:
- JOGL provides AWT and Swing components for integrating 3D graphics into GUIs.
- JOGL supports the OpenGL Architecture Review Board (ARB)'s GLSL and Nvidia's Cg shader languages.
- JOGL only supports truecolor (15 bits per pixel and higher) rendering.
- JOGL uses New I/O (NIO) internally in its implementation.
- JOGL is written almost entirely in Java. Most of its native code is autogenerated during the build process by a tool called GlueGen.
- JOGL supports some of the most popular features introduced by Magician, GL4Java, and other Java bindings for OpenGL. For example, JOGL supports Magician's "composable pipeline" paradigm, which can provide faster debugging for JOGL applications.
JOGL past, present, and future
JOGL originated as a project named Jungle, which was created by 3D graphics experts Ken Russell (of Sun Microsystems) and Chris Kline (of Irrational Games). JOGL is currently maintained on the java.net-hosted JOGL project site, under the leadership of Russell. JOGL is evolving into the official reference implementation for JSR 231: Java Binding for the OpenGL API.
This article explores JOGL by first showing you how to obtain the current release build, and how to compile and run JOGL-based applications. After discussing JOGL's demos, the article teaches you how to create your own JOGL programs, animate their scenes, and take pictures of these scenes. Finally, you examine JOGL's texture support.
Lack of space prevents me from providing a comprehensive overview of JOGL and its foundations in OpenGL. To learn more about JOGL, I recommend that you read the JOGL user guide (located in the release build archive). To learn about OpenGL, I recommend that you read the OpenGL programming guide -- version 1.1 is freely available on the Web.
Get started with JOGL
The JOGL project site's main page presents a link to the current release build of the JOGL software. Follow this link to download a release build for your platform, along with documentation, demos, source code, and signed JAR files for use with Java Web Start. For example, I downloaded the version 1.1.1 release build for my Windows platform.
Open source licenses
Each of the open source Java projects covered in this series is subject to a license, which you should understand before integrating the project with your own projects. JOGL is subject to the Berkeley Software Distribution (BSD) License.
Specifically, I downloaded and unzipped the
jogl-1.1.1-windows-i586.zip release build archive. The resulting
jogl-1.1.1-windows-i586 home directory contains some text files, a user guide HTML file, and (most importantly) a
lib subdirectory. This subdirectory contains the JOGL implementation in terms of JAR files and native Windows libraries (DLLs):