Java OpenGL

Wrapper library providing access to OpenGL from Java
title: "Java OpenGL" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["3d-graphics-software", "java-(programming-language)-libraries", "opengl", "software-using-the-bsd-license"] description: "Wrapper library providing access to OpenGL from Java" topic_path: "general/3d-graphics-software" source: "https://en.wikipedia.org/wiki/Java_OpenGL" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Wrapper library providing access to OpenGL from Java ::
::data[format=table title="Infobox software"]
| Field | Value |
|---|---|
| name | JOGL |
| screenshot | JOGL Refrection Demo Screenshot.png |
| screenshot size | 200px |
| caption | A demo screenshot illustrating real-time refraction using JOGL on Mac OS X |
| developer | JogAmp Community |
| latest release version | 2.6.0 |
| latest release date | |
| latest preview version | n/a |
| latest preview date | tbd |
| programming language | Java, C |
| operating system | Cross-platform |
| genre | 3D computer graphics software (library/API) |
| license | BSD license |
| website | |
| :: |
| name = JOGL | logo = | logo caption = | screenshot = JOGL Refrection Demo Screenshot.png | screenshot size = 200px | caption = A demo screenshot illustrating real-time refraction using JOGL on Mac OS X | developer = JogAmp Community | latest release version = 2.6.0 | latest release date = | latest preview version = n/a | latest preview date = tbd | programming language = Java, C | operating system = Cross-platform | genre = 3D computer graphics software (library/API) | license = BSD license | website =
Java OpenGL (JOGL) is a wrapper library that allows OpenGL to be used in the Java programming language.{{cite web |last1=Friesen |first1=Jeff |date=2008-09-18 |df=mdy |url=https://www.infoworld.com/article/2077906/open-source-java-projects-java-binding-for-opengl-jogl.html |title=Open source Java projects: Java Binding for OpenGL (JOGL) |department=Open Source Java Tutorials |work=JavaWorld |access-date=2020-07-23 |quote=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). |last1=Davis |first1=Gene |date=2005-02-21 |df=mdy |url=https://www.infoworld.com/article/2071845/hello-jogl.html |title=Hello JOGL |work=JavaWorld |access-date=2020-07-23
JOGL allows access to most OpenGL features available to C language programs through the use of the Java Native Interface (JNI). It offers access to both the standard GL* functions along with the GLU* functions; however the OpenGL Utility Toolkit (GLUT) library is not available for window-system related calls, as Java has its own windowing systems: Abstract Window Toolkit (AWT), Swing, JavaFX, SWT, its own NEWT and some extensions.
Design
The base OpenGL C API, as well as its associated Windowing API,{{cite web |url=http://jogamp.org/doc/siggraph2010/jogamp-siggraph2010.pdf |title=3D & Multimedia Across Platforms and Devices Using JOGL |publisher=SIGGRAPH |date=2010-07-27 |access-date=2011-02-06
JOGL differs from some other Java OpenGL wrapper libraries in that it merely exposes the procedural OpenGL API via methods on a few classes, rather than trying to map OpenGL functionality onto the object-oriented programming paradigm. Indeed, most of the JOGL code is autogenerated from the OpenGL C header files via a conversion tool named GlueGen, which was programmed specifically to facilitate the creation of JOGL.
Status and standardization
, JOGL provides full access to the OpenGL 4.6 and OpenGL ES 3.2 specification as well as almost all vendor extensions (and OpenCL, OpenMAX and OpenAL). The 2.5.0 version is the reference implementation for JSR-231 (Java Bindings for OpenGL).{{cite web |url=http://jcp.org/aboutJava/communityprocess/final/jsr231/index.html |title=JSR-000231 Java Bindings for the OpenGL API |publisher=Java Community Process |access-date=2011-02-06 |quote=In order to facilitate maximum community participation for the Java Binding for the OpenGL API, we use the JOGL project on java.net found at jogl.dev.java.net. The JOGL source code can be found there, licensed under a liberal source code license (mostly licensed as BSD except where we use other parties' licensed code). We take a snapshot of the code from this project every few months, run the Technology Compatibility Kit on the source code, and then officially make it the Reference Implementation for each formal Java Binding for the OpenGL API release.
Wayland and Vulkan support is planned.
Java2D-OpenGL interoperability
Since the Java SE 6 version of the Java language, Java2D (the API for drawing two dimensional graphics in Java) and JOGL have become interoperable, allowing it to :
- Overlay Swing components (lightweight menus, tooltips, and other widgets) on top of OpenGL rendering.
- Draw 3D OpenGL graphics on top of Java2D rendering (see here for a button with an OpenGL icon).
- Use 3D graphics anywhere where ordinarily a Swing widget would be used. (Inside a JTable, JTree, ...)
- Draw Java2D graphics on top of 3D OpenGL rendering.
Tutorials
- OpenGL ES 2 sample
- Hello Triangle, gl3 and gl4 Hello Triangle and Texture. The samples are offered in Java and Kotlin
- Java OpenGL Sample Pack, porting of g-truc OpenGL Sample Pack. The over 230 samples illustrate almost all OpenGL features ranging from ES 2.0 up to the last GL extensions, same of them usually also called AZDO (Almost Zero Driver Overhead).
- modern jogl examples, Porting of Learning Modern 3D Graphics Programming, Jason L. McKesson . Java and Kotlin side by side.
- Immediate mode sample (simplest example, using the Fixed-function graphics pipeline)
Code example
::code[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 /*target*/, 1 /*TRANSFORM0, index*/, bufferName.get(2) /*TRANSFORM, buffer*/);
gl4.glBindTextureUnit(0 /*diffuse*/, textureName.get(0));
gl4.glBindSampler(0 /*diffuse*/, samplerName.get(0));
gl4.glDrawElements(GL.GL_TRIANGLES, elementCount, GL.GL_UNSIGNED_SHORT, 0);
}
::
References
References
- "JOGL - Java Binding for the OpenGL API".
- (2013-08-05). "Bug 794 - Add Wayland Windowing/Surface Interoperability".
- "JOGL Userguide".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::