Java OpenGL
Developer(s) | JogAmp Community |
---|---|
Stable release | 2.5.0
/ August 18, 2023 |
Preview release | n/a
/ tbd |
Written in | Java,C |
Operating system | Cross-platform |
Type | 3D computer graphics software(library/API) |
License | BSD license |
Website | jogamp |
Java OpenGL(JOGL) is a wrapperlibrarythat allowsOpenGLto be used in theJava programming language.[1][2]It was originally developed by Kenneth Bradley Russell and Christopher John Kline, and was further developed by the Game Technology Group atSun Microsystems.Since 2010, it has been an independentopen-sourceproject under aBSD license.It is the reference implementation forJava Bindings for OpenGL(JSR-231).
JOGL allows access to most OpenGL features available toClanguage programs through the use of theJava Native Interface(JNI). It offers access to both the standard GL* functions along with the GLU* functions; however theOpenGL Utility Toolkit(GLUT) library is not available for window-system related calls, as Java has its own windowing systems:Abstract Window Toolkit(AWT),Swing,and someextensions.
Design
[edit]The baseOpenGLCAPI, as well as its associatedWindowing API,[3]are accessed in JOGL viaJava Native Interface(JNI) calls. As such, the underlying system must support OpenGL for JOGL to work.
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 theobject-oriented programmingparadigm. Indeed, most of the JOGL code is autogenerated from the OpenGL C header files via a conversion tool namedGlueGen,which was programmed specifically to facilitate the creation of JOGL.
Status and standardization
[edit]As of 2015[update],JOGL provides full access to theOpenGL4.5 specification as well as almost all vendor extensions (andOpenCL,OpenMAXandOpenAL).[4]The1.1.0version is the reference implementation forJSR-231 (Java Bindings for OpenGL).[5]The1.1.1release gave limited access toGLUNURBS,providing rendering of curved lines and surfaces via the traditional GLU APIs. The2.3.2release added support for OpenGL versions up to 4.5, and OpenGL ES versions up to 3.2.
Wayland and Vulkan support is planned.[6]
Java2D-OpenGL interoperability
[edit]Since theJava SE 6version of theJavalanguage,Java2D(theAPIfor drawing two dimensional graphics in Java) and JOGL have become interoperable, allowing it to:
- OverlaySwingcomponents (lightweight menus, tooltips, and otherwidgets) on top ofOpenGLrendering.[7]
- Draw 3DOpenGLgraphics on top ofJava2Drendering (seeherefor a button with an OpenGL icon).
- Use 3D graphics anywhere where ordinarily aSwingwidgetwould be used. (Inside a JTable, JTree,...)
- DrawJava2Dgraphics on top of 3DOpenGLrendering.
Tutorials
[edit]- OpenGL ES 2sample
- Hello Triangle,gl3 and gl4 Hello Triangle and Texture. The samples are offered in Java andKotlin
- Java OpenGL Sample Pack,porting ofg-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 calledAZDO(Almost Zero Driver Overhead).
- modern jogl examples,Porting ofLearning Modern 3D Graphics Programming, Jason L. McKessonArchived2016-09-23 at theWayback Machine.Java and Kotlin side by side.
- Immediate modesample (simplest example, using theFixed-functiongraphics pipeline)
Code examples
[edit]@Override
publicvoiddisplay(GLAutoDrawabledrawable){
GL4gl4=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);
}
See also
[edit]- Java Bindings for OpenGL,The Java Community Specification Request for which JOGL provides an implementation
- Ardor3D,a high performance, professionally oriented scene graph using several bindings for OpenGL and OpenGL-ES including JOGL
- Elflight Engine,a high performance 3D game engine optimised for the web
- JMonkey Engine,a high performance scene graph based graphics API using several bindings for OpenGL and OpenGL-ES including JOGL
- Poxnora,an online multiplayer game using JOGL
- RuneScape,a MMORPG using JOGL
- Jake2,a Java port ofQuake IIusing several bindings for OpenGL including JOGL for its low-level graphic API
- Scilab,a numerical computing program using JOGL for 2D, 3D rendering
- ClearVolume,a JOGL powered real-time live 3D visualization library designed for high-end volumetriclight sheet microscopes.
- LWJGL,an alternative open-source OpenGL wrapper library
- Java OpenAL
- Java OpenCL
References
[edit]- ^Friesen, Jeff (September 18, 2008)."Open source Java projects: Java Binding for OpenGL (JOGL)".Open Source Java Tutorials.JavaWorld.Retrieved2020-07-23.
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).
- ^Davis, Gene (February 21, 2005)."Hello JOGL".JavaWorld.Retrieved2020-07-23.
- ^"3D & Multimedia Across Platforms and Devices Using JOGL"(PDF).SIGGRAPH.2010-07-27.Retrieved2011-02-06.
- ^"JOGL - Java Binding for the OpenGL API".
- ^"JSR-000231 Java Bindings for the OpenGL API".Java Community Process.Retrieved2011-02-06.
In order to facilitate maximum community participation for the Java Binding for the OpenGL API, we use the JOGL project on java.net found athttps://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.
- ^"Bug 794 - Add Wayland Windowing/Surface Interoperability".2013-08-05.
- ^"JOGL Userguide".
External links
[edit]- Official website
- JOGL 2.3.x Specification
- JSR-231 Java Bindings for OpenGLwebsite
- tool kietArchived2009-02-09 at theWayback Machine,The OpenGL Programming Guide examples using JOGL
- NeHe's tutorials and sample code
- Setting up a JogAmp JOGL project in your favorite IDE
- Viewer3D,an applet to display interactive 3D content with JOGL
- Eclipse OpenGL PackOpenGL plugin for theEclipseIDE