Java Bindings for OpenGL

Last updated

Java Binding for the OpenGL API is a JSR API specification (JSR 231) for the Java Platform, Standard Edition which allows to use OpenGL on the Java (software platform). [1] There is also Java Binding for the OpenGL ES API (JSR 239) for the Java Platform, Micro Edition.

Contents

Programming concepts

Core OpenGL API and GLU library calls are available from Java through a thin wrapper looking very much as the original OpenGL C API, Except GLU NURBS routines which are not exposed through the public API.

All platform specific libraries (available from the CGL API for Mac OS X, GLX for X Window System, and WGL for Microsoft Windows) are also abstracted out to create a platform independent way of selecting Framebuffer attributes and performing platform specific Framebuffer operations.

Platform-specific extensions are not included in the public API. Each implementation can choose to export some of these APIs via the GL.getPlatformGLExtensions() and GL.getExtension(String) method calls which return Objects whose data types are specific to the given implementation.

Example

This example shows how to draw a polygon (without initialization or repaint code). [2] Here is the reference C implementation:

intDrawGLScene(GLvoid){glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glLoadIdentity();glTranslatef(-1.5f,0.0f,-6.0f);// Move Left 1.5 UnitsglBegin(GL_TRIANGLES);//Drawing Using TrianglesglVertex3f(0.0f,1.0f,0.0f);// TopglVertex3f(-1.0f,-1.0f,0.0f);// Bottom LeftglVertex3f(1.0f,-1.0f,0.0f);// Bottom RightglEnd();glTranslatef(3.0f,0.0f,0.0f);glBegin(GL_QUADS);// Draw A QuadglVertex3f(-1.0f,1.0f,0.0f);// Top LeftglVertex3f(1.0f,1.0f,0.0f);// Top RightglVertex3f(1.0f,-1.0f,0.0f);// Bottom RightglVertex3f(-1.0f,-1.0f,0.0f);// Bottom LeftglEnd();glFlush();returnTRUE;}

Which translates to the following Java implementation:

publicvoiddisplay(GLAutoDrawableglDrawable){finalGLgl=glDrawable.getGL();gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT);gl.glLoadIdentity();gl.glTranslatef(-1.5f,0.0f,-6.0f);// Move Left 1.5 Unitsgl.glBegin(GL.GL_TRIANGLES);// Drawing Using Trianglesgl.glVertex3f(0.0f,1.0f,0.0f);// Topgl.glVertex3f(-1.0f,-1.0f,0.0f);// Bottom Leftgl.glVertex3f(1.0f,-1.0f,0.0f);// Bottom Rightgl.glEnd();gl.glTranslatef(3.0f,0.0f,0.0f);gl.glBegin(GL.GL_QUADS);// Draw A Quadgl.glVertex3f(-1.0f,1.0f,0.0f);// Top Leftgl.glVertex3f(1.0f,1.0f,0.0f);// Top Rightgl.glVertex3f(1.0f,-1.0f,0.0f);// Bottom Rightgl.glVertex3f(-1.0f,-1.0f,0.0f);// Bottom Leftgl.glEnd();gl.glFlush();}

Implementations

See also

Related Research Articles

OpenGL Cross-platform graphics API

OpenGL is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.

OCaml is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

Java Platform, Micro Edition or Java ME is a computing platform for development and deployment of portable code for embedded and mobile devices. Java ME was formerly known as Java 2 Platform, Micro Edition or J2ME.

Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware acceleration if it is available on the graphics card, allowing for hardware acceleration of the entire 3D rendering pipeline or even only partial acceleration. Direct3D exposes the advanced graphics capabilities of 3D graphics hardware, including Z-buffering, W-buffering, stencil buffering, spatial anti-aliasing, alpha blending, color blending, mipmapping, texture blending, clipping, culling, atmospheric effects, perspective-correct texture mapping, programmable HLSL shaders and effects. Integration with other DirectX technologies enables Direct3D to deliver such features as video mapping, hardware 3D rendering in 2D overlay planes, and even sprites, providing the use of 2D and 3D graphics in interactive media ties.

Jakarta XML Binding is a software framework that allows Jakarta EE developers to map Java classes to XML representations. JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, i.e. to unmarshal XML back into Java objects. In other words, JAXB allows storing and retrieving data in memory in any XML format, without the need to implement a specific set of XML loading and saving routines for the program's class structure. It is similar to xsd.exe and XmlSerializer in the .NET Framework.

Direct3D and OpenGL are competing application programming interfaces (APIs) which can be used in applications to render 2D and 3D computer graphics. As of 2005, graphics processing units (GPUs) almost always implement one version of both of these APIs. Examples include: DirectX 9 and OpenGL 2 circa 2004; DirectX 10 and OpenGL 3 circa 2008; and most recently, DirectX 11 and OpenGL 4 circa 2011. GPUs that support more recent versions of the standards are backward compatible with applications that use the older standards; for example, one can run older DirectX 9 games on a more recent DirectX 11-certified GPU.

Java 3D Java 3D graphics API

Java 3D is a scene graph-based 3D application programming interface (API) for the Java platform. It runs on top of either OpenGL or Direct3D until version 1.6.0, which runs on top of Java OpenGL (JOGL). Since version 1.2, Java 3D has been developed under the Java Community Process. A Java 3D scene graph is a directed acyclic graph (DAG).

Shader sige Type of program in a graphical processing unit (GPU)

In computer graphics, a shader is a type of computer program originally used for shading in 3D scenes. They now perform a variety of specialized functions in various fields within the category of computer graphics special effects, or else do video post-processing unrelated to shading, or even perform functions unrelated to graphics.

java.nio is a collection of Java programming language APIs that offer features for intensive I/O operations. It was introduced with the J2SE 1.4 release of Java by Sun Microsystems to complement an existing standard I/O. NIO was developed under the Java Community Process as JSR 51. An extension to NIO that offers a new file system API, called NIO.2, was released with Java SE 7 ("Dolphin").

Java OpenGL

Java OpenGL (JOGL) is a wrapper library that allows OpenGL to be used in the Java programming language. It was originally developed by Kenneth Bradley Russell and Christopher John Kline, and was further developed by the Sun Microsystems Game Technology Group. 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).

OpenGL Shading Language

OpenGL Shading Language (GLSL) is a high-level shading language with a syntax based on the C programming language. It was created by the OpenGL ARB to give developers more direct control of the graphics pipeline without having to use ARB assembly language or hardware-specific languages.

A triangle strip is a series of connected triangles from the triangle mesh, sharing vertices, allowing for more efficient memory usage for computer graphics. They are more efficient than triangle lists without indexing, but usually equally fast or slower than indexed triangle lists. The primary reason to use triangle strips is to reduce the amount of data needed to create a series of triangles. The number of vertices stored in memory is reduced from 3N to N+2, where N is the number of triangles to be drawn. This allows for less use of disk space, as well as making them faster to load into RAM.

GlueGen is a Java tool which automatically generates the Java and Java Native Interface (JNI) code needed to call C libraries from Java code. It reads in ANSI C header files and GlueGen configuration files, and emits C code. As JNI can be complex, Gluegen simplifies the process of binding Java to C native libraries.

Perl OpenGL

Perl OpenGL (POGL) is a portable, compiled wrapper library that allows OpenGL to be used in the Perl programming language.

The phoneME project is Sun Microsystems reference implementation of Java virtual machine and associated libraries of Java ME with source, licensed under the GNU General Public License.

A vertex buffer object (VBO) is an OpenGL feature that provides methods for uploading vertex data to the video device for non-immediate-mode rendering. VBOs offer substantial performance gains over immediate mode rendering primarily because the data reside in video device memory rather than system memory and so it can be rendered directly by the video device. These are equivalent to vertex buffers in Direct3D.

InfiniteReality Graphics subsystem by Silicon Graphics

InfiniteReality refers to a 3D graphics hardware architecture and a family of graphics systems that implemented the aforementioned hardware architecture that was developed and manufactured by Silicon Graphics from 1996 to 2005. The InfiniteReality was positioned as Silicon Graphics' high-end visualization hardware for their MIPS/IRIX platform and was used exclusively in their Onyx family of visualization systems, which are sometimes referred to as "graphics supercomputers" or "visualization supercomputers". The InfiniteReality was marketed to and used by large organizations such as companies and universities that are involved in computer simulation, digital content creation, engineering and research.

EGL (API) Application programming interface

EGL is an interface between Khronos rendering APIs and the underlying native platform windowing system. EGL handles graphics context management, surface/buffer binding, rendering synchronization, and enables "high-performance, accelerated, mixed-mode 2D and 3D rendering using other Khronos APIs." EGL is managed by the non-profit technology consortium Khronos Group.

Mobile 3D Graphics API

The Mobile 3D Graphics API, commonly referred to as M3G, is a specification defining an API for writing Java programs that produce 3D computer graphics. It extends the capabilities of the Java ME, a version of the Java platform tailored for embedded devices such as mobile phones and PDAs. The object-oriented interface consists of 30 classes that can be used to draw complex animated three-dimensional scenes. M3G was developed under the Java Community Process as JSR 184. As of 2007, the current version of M3G is 1.1, but version 2.0 is in development as JSR 297.

This is a glossary of terms relating to computer graphics.

References

  1. "JSR 231: JavaBinding for the OpenGL API". Java Community Process . Retrieved 2011-02-06.
  2. Borrowed from the Nehe tutorial, whose code is free to use elsewhere.
  3. "JSR-000231 Java Bindings for the OpenGL API". Java Community Process . Retrieved 2011-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 at https://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.