Java OpenGL
| Company type | Open-source software |
|---|---|
| Industry | Software development, Graphics programming |
| Founder | Kenneth Bradley Russell, Christopher John Kline |
Area served | Worldwide |
| Products | Java bindings for OpenGL |
| Owner | Independent open-source initiative (since 2010) |
Java OpenGL (JOGL) is a binding library that facilitates the integration of OpenGL within the Java environment. Initially created by Kenneth Bradley Russell and Christopher John Kline, and later enhanced by Sun Microsystems' Game Technology Group, JOGL has operated as an independent open-source initiative under a BSD license since 2010. It functions as the official reference implementation for Java Bindings for OpenGL (JSR-231).
Through the use of the Java Native Interface (JNI), JOGL grants access to nearly all OpenGL capabilities available in C. It supports both GL* and GLU* standard functions but does not include the OpenGL Utility Toolkit (GLUT) for window management, instead relying on Java's native windowing frameworks such as Abstract Window Toolkit (AWT) and Swing.
Design
JOGL interfaces directly with the core OpenGL C API and its corresponding windowing system via JNI calls, necessitating that the host platform supports OpenGL.
Unlike certain other Java OpenGL wrappers, JOGL presents the procedural OpenGL API through a limited set of class methods without converting it into an object-oriented paradigm. The majority of its source code is automatically generated from OpenGL C header files using GlueGen, a specialized utility designed to simplify JOGL development.
Status and standardization
By 2023, JOGL offers comprehensive support for the OpenGL 4.5 specification along with nearly all vendor-specific extensions, including OpenCL, OpenMAX, and OpenAL. Version 2.5.0 acts as the official reference implementation for JSR-231 (Java Bindings for OpenGL). The 1.1.1 update introduced partial support for GLU NURBS, enabling rendering of curved lines and surfaces through classic GLU APIs. Version 2.3.2 expanded compatibility to include OpenGL 4.5 and OpenGL ES 3.2.
Future plans include adding support for Wayland and Vulkan.
Java2D-OpenGL interoperability
Starting with Java SE 6, interoperability between Java2D and JOGL has been established, allowing:
- Swing components such as menus, tooltips, and widgets to be layered over OpenGL-rendered content.
- Displaying 3D OpenGL graphics above Java2D elements.
- Incorporating 3D graphics within Swing components like JTable and JTree.
- Rendering Java2D graphics atop 3D OpenGL scenes.
Tutorials
- OpenGL ES 2 example
- Hello Triangle, samples demonstrating gl3 and gl4 Hello Triangle and Texture in both Java and Kotlin
- Java OpenGL Sample Pack, a port of g-truc's OpenGL Sample Pack featuring over 230 examples covering ES 2.0 through the latest GL extensions including AZDO (Almost Zero Driver Overhead)
- modern jogl examples, a Java and Kotlin adaptation of "Learning Modern 3D Graphics Programming" by Jason L. McKesson
- Immediate mode demonstration showcasing a basic fixed-function pipeline example
Code example
<syntaxhighlight lang=java>
@Override
public void display(GLAutoDrawable drawable) {
GL4 gl4 = drawable.getGL().getGL4();
gl4.glClearBufferfv(GL2ES3.GL_COLOR, 0, clearColor);
gl4.glClearBufferfv(GL2ES3.GL_DEPTH, 0, clearDepth);
{
FloatUtil.makeLookAt(view, 0, eye, 0, at, 0, up, 0, tmp);
FloatUtil.makePerspective(projection, 0, reset, 45f, aspect, near, far);
FloatUtil.multMatrix(projection, view); // projection *= view
transformPointer.asFloatBuffer().put(projection);
}
gl4.glUseProgram(programName);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBufferBase(GL2ES3.GL_UNIFORM_BUFFER, 1, bufferName.get(2));
gl4.glBindTextureUnit(0, textureName.get(0));
gl4.glBindSampler(0, samplerName.get(0));
gl4.glDrawElements(GL.GL_TRIANGLES, elementCount, GL.GL_UNSIGNED_SHORT, 0); }
</syntaxhighlight>
See also
- Java Bindings for OpenGL, the Java Community Specification Request implemented by JOGL
- Ardor3D, a professional scene graph using OpenGL bindings including JOGL
- JMonkey Engine, a high-performance graphics API using OpenGL and JOGL
- Poxnora, an online multiplayer game utilizing JOGL
- RuneScape, a MMORPG built with JOGL
- Jake2, a Java port of Quake II using JOGL for graphics
- Scilab, numerical computing software leveraging JOGL for 2D and 3D rendering
- ClearVolume, a real-time 3D visualization library powered by JOGL for advanced microscopy
- LWJGL, an alternative open-source OpenGL wrapper
- Java OpenAL
External links
- JOGL 2.3.x Specification
- JSR-231 Java Bindings for OpenGL
- tool kiet, OpenGL Programming Guide examples using JOGL
- NeHe's tutorials and sample code
- Setting up a JogAmp JOGL project in IDEs
- Viewer3D, applet for interactive 3D content with JOGL
- Eclipse OpenGL Pack, OpenGL plugin for the Eclipse IDE