Wikipedia

Java Bindings for OpenGL

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.

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:

 int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity; glTranslatef(-1.5f, 0.0f, -6.0f); // Move Left 1.5 Units glBegin(GL_TRIANGLES); //Drawing Using Triangles glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glEnd; glTranslatef(3.0f, 0.0f, 0.0f); glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd; glFlush; return TRUE; } 

Which translates to the following Java implementation:

 public void display(GLAutoDrawable glDrawable) { final GL gl = 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 Units gl.glBegin(GL.GL_TRIANGLES); // Drawing Using Triangles gl.glVertex3f( 0.0f, 1.0f, 0.0f); // Top gl.glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left gl.glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right gl.glEnd; gl.glTranslatef(3.0f, 0.0f, 0.0f); gl.glBegin(GL.GL_QUADS); // Draw A Quad gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left gl.glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right gl.glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right gl.glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left gl.glEnd; gl.glFlush; } 

Implementations

See also

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.

External links

This article is copied from an article on Wikipedia® - the free encyclopedia created and edited by its online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of Wikipedia® encyclopedia articles provide accurate and timely information, please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.

Copyright © 2003-2025 Farlex, Inc Disclaimer
All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only. This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional.