Java OpenGL: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Isaidnoway
/* See also → remove Elflight Engine and Java OpenCL, there's nothing to see since articles don't exist
 
imported>Sgothel
m JogAmp Release 2.6.0 and added windowing systems JavaFX, SWT and NEWT as well as OpenGL ES spec
 
Line 7: Line 7:
| caption = A [[demoware|demo]] screenshot illustrating real-time [[refraction]] using '''JOGL''' on [[macOS|Mac OS X]]
| caption = A [[demoware|demo]] screenshot illustrating real-time [[refraction]] using '''JOGL''' on [[macOS|Mac OS X]]
| developer = [http://jogamp.org/ JogAmp Community]
| developer = [http://jogamp.org/ JogAmp Community]
| latest release version = 2.5.0
| latest release version = 2.6.0
| latest release date = {{Start date and age|2023|08|18}}
| latest release date = {{Start date and age|2025|08|31}}
| latest preview version = n/a
| latest preview version = n/a
| latest preview date = tbd
| latest preview date = tbd
Line 36: Line 36:
}}</ref> It was originally developed by Kenneth Bradley Russell and Christopher John Kline, and was further developed by the Game Technology Group at [[Sun Microsystems]]. Since 2010, it has been an independent [[open-source software|open-source]] project under a [[BSD licenses|BSD license]]. It is the reference implementation for [[Java Bindings for OpenGL]] (JSR-231).
}}</ref> It was originally developed by Kenneth Bradley Russell and Christopher John Kline, and was further developed by the Game Technology Group at [[Sun Microsystems]]. Since 2010, it has been an independent [[open-source software|open-source]] project under a [[BSD licenses|BSD license]]. It is the reference implementation for [[Java Bindings for OpenGL]] (JSR-231).


JOGL allows access to most OpenGL features available to [[C (programming language)|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 (Java)|Swing]], and some [[OpenGL#Development|extensions]].
JOGL allows access to most OpenGL features available to [[C (programming language)|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 (Java)|Swing]], [[JavaFX]], [[Standard Widget Toolkit|SWT]], its own NEWT and some [[OpenGL#Development|extensions]].


==Design==
==Design==
Line 50: Line 50:


==Status and standardization==
==Status and standardization==
{{As of|2023}}, JOGL provides full access to the [[OpenGL]] 4.5 specification as well as almost all vendor extensions (and [[OpenCL]], [[OpenMAX]] and [[OpenAL]]).<ref>{{cite web |url=http://jogamp.org/jogl/www/ |title = JOGL - Java Binding for the OpenGL API}}</ref> The '''2.5.0''' version is the reference implementation for [[Java Bindings for OpenGL|JSR-231 (Java Bindings for OpenGL)]].<ref>{{cite web
{{As of|2025}}, 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]]).<ref>{{cite web |url=http://jogamp.org/jogl/www/ |title = JOGL - Java Binding for the OpenGL API}}</ref> The '''2.5.0''' version is the reference implementation for [[Java Bindings for OpenGL|JSR-231 (Java Bindings for OpenGL)]].<ref>{{cite web
  |url=http://jcp.org/aboutJava/communityprocess/final/jsr231/index.html
  |url=http://jcp.org/aboutJava/communityprocess/final/jsr231/index.html
  |title=JSR-000231 Java Bindings for the OpenGL API
  |title=JSR-000231 Java Bindings for the OpenGL API
Line 56: Line 56:
  |access-date=2011-02-06
  |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.''
  |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.''
}}</ref> The '''1.1.1''' release gave limited access to [[OpenGL Utility Library|GLU]] [[Nonuniform rational B-spline|NURBS]], providing rendering of curved lines and surfaces via the traditional GLU APIs. The '''2.3.2''' release added support for OpenGL versions up to 4.5, and OpenGL ES versions up to 3.2.
}}</ref> The '''1.1.1''' release gave limited access to [[OpenGL Utility Library|GLU]] [[Nonuniform rational B-spline|NURBS]], providing rendering of curved lines and surfaces via the traditional GLU APIs. The '''2.6.0''' release added support for OpenGL versions up to 4.6, and OpenGL ES versions up to 3.2.


Wayland and Vulkan support is planned.<ref>{{cite web|url=https://jogamp.org/bugzilla/show_bug.cgi?id=794 |title=Bug 794 - Add Wayland Windowing/Surface Interoperability |date=2013-08-05}}</ref>
Wayland and Vulkan support is planned.<ref>{{cite web|url=https://jogamp.org/bugzilla/show_bug.cgi?id=794 |title=Bug 794 - Add Wayland Windowing/Surface Interoperability |date=2013-08-05}}</ref>
Line 74: Line 74:
* [https://jogamp.org/wiki/index.php/Rudimentary_standalone_example_using_the_fixed_pipeline_by_Julien_Gouesse Immediate mode] sample (simplest example, using the [[Fixed-function]] [[graphics pipeline]])
* [https://jogamp.org/wiki/index.php/Rudimentary_standalone_example_using_the_fixed_pipeline_by_Julien_Gouesse Immediate mode] sample (simplest example, using the [[Fixed-function]] [[graphics pipeline]])


==Code examples==
==Code example==
<syntaxhighlight lang=java>
<syntaxhighlight lang=java>
     @Override
     @Override
Line 122: Line 122:
==External links==
==External links==
* {{Official website}}
* {{Official website}}
* [http://jogamp.org/deployment/jogamp-current/javadoc/jogl/javadoc/ JOGL 2.3.x Specification]
* [http://jogamp.org/deployment/jogamp-current/javadoc/jogl/javadoc/ JOGL 2.6.x Specification]
* [http://www.jcp.org/en/jsr/detail?id=231 JSR-231 Java Bindings for OpenGL] website
* [http://www.jcp.org/en/jsr/detail?id=231 JSR-231 Java Bindings for OpenGL] website
* [http://ak.kiet.le.googlepages.com/theredbookinjava.html tool kiet] {{Webarchive|url=https://web.archive.org/web/20090209203335/http://ak.kiet.le.googlepages.com/theredbookinjava.html |date=2009-02-09 }}, The OpenGL Programming Guide examples using JOGL
* [http://ak.kiet.le.googlepages.com/theredbookinjava.html tool kiet] {{Webarchive|url=https://web.archive.org/web/20090209203335/http://ak.kiet.le.googlepages.com/theredbookinjava.html |date=2009-02-09 }}, The OpenGL Programming Guide examples using JOGL
Line 128: Line 128:
* [http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE Setting up a JogAmp JOGL project in your favorite IDE]
* [http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE Setting up a JogAmp JOGL project in your favorite IDE]
* [http://demo.dzzd.net/Viewer3D/ Viewer3D], an applet to display interactive 3D content with JOGL
* [http://demo.dzzd.net/Viewer3D/ Viewer3D], an applet to display interactive 3D content with JOGL
* [http://sourceforge.net/projects/eclipse-opengl/ Eclipse OpenGL Pack] OpenGL plugin for the [[Eclipse (software)|Eclipse]] IDE
* [https://sourceforge.net/projects/eclipse-opengl/ Eclipse OpenGL Pack] OpenGL plugin for the [[Eclipse (software)|Eclipse]] IDE


{{Java desktop}}
{{Java desktop}}

Latest revision as of 16:19, 31 August 2025

Script error: No such module "Infobox".Template:Template other Script error: No such module "Check for unknown parameters".Script error: No such module "Check for conflicting parameters".

Java OpenGL (JOGL) is a wrapper library that allows OpenGL to be used in the Java 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 at Sun Microsystems. Since 2010, it has been an independent open-source project under a BSD license. It is the reference implementation for Java Bindings for OpenGL (JSR-231).

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,[3] are accessed in JOGL via Java 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 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

since 2025Template:Dated maintenance category (articles)Script error: No such module "Check for unknown parameters"., 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).[4] The 2.5.0 version is the reference implementation for JSR-231 (Java Bindings for OpenGL).[5] The 1.1.1 release gave limited access to GLU NURBS, providing rendering of curved lines and surfaces via the traditional GLU APIs. The 2.6.0 release added support for OpenGL versions up to 4.6, and OpenGL ES versions up to 3.2.

Wayland and Vulkan support is planned.[6]

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.[7]
  • 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

Code example

    @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);
    }

See also

Script error: No such module "Portal".

  • 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
  • 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 of Quake II using 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 volumetric light sheet microscopes.
  • LWJGL, an alternative open-source OpenGL wrapper library
  • Java OpenAL

References

<templatestyles src="Reflist/styles.css" />

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. Script error: No such module "citation/CS1".
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".

Script error: No such module "Check for unknown parameters".

External links

Template:Java desktop