Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Java Bindings for OpenGL

From Wikipedia, the free encyclopedia
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Java Bindings for OpenGL" – news ·newspapers ·books ·scholar ·JSTOR
(August 2010) (Learn how and when to remove this message)
This articlemay containexcessive orirrelevant examples. Please helpimprove it by removingless pertinent examples andelaborating on existing ones.(August 2010) (Learn how and when to remove this message)

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

Programming concepts

[edit]

Core OpenGL API andGLU library calls are available fromJava through a thin wrapper looking very much as the original OpenGLC API, Except GLUNURBS routines which are not exposed through the public API.

All platform specific libraries (available from theCGL API forMac OS X,GLX forX Window System, andWGL forMicrosoft Windows) are also abstracted out to create a platform independent way of selectingFramebuffer 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 theGL.getPlatformGLExtensions()Archived February 17, 2011, at theWayback Machine andGL.getExtension(String)Archived February 17, 2011, at theWayback Machine method calls which return Objects whose data types are specific to the given implementation.

Example

[edit]

This example shows how to draw a polygon (without initialization or repaint code).[2] Here is the referenceC 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 followingJava 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

[edit]

See also

[edit]

References

[edit]
  1. ^"JSR 231: JavaBinding for the OpenGL API".Java Community Process. RetrievedFebruary 6, 2011.
  2. ^Borrowed from theNehe tutorialArchived April 6, 2007, at theWayback Machine, whose code is free to use elsewhere.
  3. ^"JSR-000231 Java Bindings for the OpenGL API".Java Community Process. RetrievedFebruary 6, 2011.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.

External links

[edit]
Java desktop
APIs
Deprecated APIs
Open-source
Retrieved from "https://en.wikipedia.org/w/index.php?title=Java_Bindings_for_OpenGL&oldid=1278524552"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp