<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-30081901</id><updated>2011-12-06T01:31:32.360+11:00</updated><title type='text'>PC's JOGL Blog</title><subtitle type='html'>Learning the Java JOGL OpenGL Bindings</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-30081901.post-116959021096539178</id><published>2007-01-24T09:03:00.000+11:00</published><updated>2007-01-25T07:54:35.136+11:00</updated><title type='text'>Blending with glPolygonOffset</title><content type='html'>glPolygonOffset() is used to offset the polygon being rendered, and thus the pixels in the polygon, from the others currently in the displaybuffer. This does not actually effect the values written to the ZBuffer and is useful when blending two textures or polygons together.&lt;p&gt;The following images give an example of the problem and the effect of using glPolygonOffset. There are two polygons are rendered, the first being red, with the second being yellow blended over it in the same position in 3D space. The aim of the blending is to make a clean transition between red and yellow, or between 2 textures, in an animation. The second yellow polygon is a little bigger that the first red polygon be show the effect more clearly. In the first image, the "popping" of the red polygon through the yellow polygon occurs because the pixels values of the yellow polygon do not exactly match the Z buffer values of the first.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/4439/3219/1600/557515/PolygonOffset.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/4439/3219/320/129831/PolygonOffset.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;By enabling polygon offset the second polygon depth tests are performed using the following calculation...&lt;/p&gt;&lt;quote&gt;"The value of the offset is factor * DZ + r * units, where DZ is a measurement of the change in depth relative to the screen area of the polygon, and r is the smallest value that is guaranteed to&lt;br /&gt;produce a resolvable offset for a given implementation. The offset is added before the depth test is performed and before the value is written into the depth buffer *" &lt;a href="http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonoffset.html"&gt;OpenGL Reference Documentation&lt;/a&gt;&lt;br /&gt;&lt;/quote&gt;&lt;br /&gt;The result is that the second yellow polygon gives the desired result and blends nicely over the red polygon. This effect is very useful when blended between textures, for example, when changing a models level of detail. It is important when using this method that the polygons are drawn in a particular order. The offset yellow polygon must be draw original red polygon otherwise the effect does not work.&lt;p&gt;&lt;/p&gt;&lt;pre&gt;// Render first polygon&lt;br /&gt;gl.glEnable(GL.GL_POLYGON_OFFSET_FILL) ;&lt;br /&gt;gl.glPolygonOffset(-1.0f, 1.0f) ;&lt;br /&gt;// Render second polygon&lt;br /&gt;gl.glDisable(GL.GL_POLYGON_OFFSET_FILL) ;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Note that offsets can be used for the lines and the points in a polygon as well by enabling GL.GL_POLYGON_OFFSET_LINE and/or GL.GL_POLGON_OFFSET_POINT.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-116959021096539178?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/116959021096539178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=116959021096539178' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/116959021096539178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/116959021096539178'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2007/01/blending-with-glpolygonoffset.html' title='Blending with glPolygonOffset'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115311014040210967</id><published>2006-07-17T14:07:00.000+10:00</published><updated>2006-10-04T06:43:17.233+10:00</updated><title type='text'>JNLP Download Error</title><content type='html'>I came in to work this morning and decided to test my JNLP program. I was using Firefox to launch the application from my computer, which is behind a firewall and a proxy server, and web start was giving me "Download Error" message. &lt;br /&gt;&lt;pre&gt;An error occurred while launching/&lt;br /&gt;running the application.&lt;br /&gt;&lt;br /&gt;Title: Simple Blending Example&lt;br /&gt;Vendor: Peter Finch&lt;br /&gt;Category: Download Error&lt;br /&gt;&lt;br /&gt;Unable to load resource: http://www.homepla.net/webstart &lt;br /&gt;/simpleblending/simpleblending.jnlp&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I found this was due to my proxy settings in IE, which was  not setup to go through the proxy server (testing reasons), so web start could not get through the firewall to the Internet and load the program. It appears that web start uses the IE internet connection settings to get to the Internet by default. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4439/3219/1600/proxy.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/4439/3219/200/proxy.png" border="0" alt="" /&gt;&lt;/a&gt;You can change this using "javaws". Start "javaws" and go to the "Edit", "Preferences" menu to get the "Java Control Panel" dialog. From there go to the "General" tab and select "Network Settings". You'll probably find "Use Browser Settings" checked by default, so just set it to "use proxy server" and enter the appropriate details. It will now be independent of your browser settings.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115311014040210967?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115311014040210967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115311014040210967' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115311014040210967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115311014040210967'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/07/jnlp-download-error.html' title='JNLP Download Error'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115294665290701947</id><published>2006-07-15T16:29:00.000+10:00</published><updated>2006-07-15T17:18:33.970+10:00</updated><title type='text'>JOGL Java Webstart (JNPL)</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4439/3219/1600/simpleblending.0.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/4439/3219/200/simpleblending.png" border="0" alt="" /&gt;&lt;/a&gt;Turning a JOGL application into a Java webstart application was relatively easy and just involves building a JAR file and creating a JNLP (Java Net Launch Protocol) file. After doing this once I bet you'll probably end up always using webstart to distribute you applications. It is just so easy to work with and installing applications on any browser with Java installed is a snap. &lt;br /&gt;&lt;p&gt;However, I did have a problem when trying to start the application from the browser for the first time. Webstart kept giving me an error message “Java Web Start – Unexpected Error - Unable to launch simpleblending”. When I asked for details, I got the following information (not the most helpful message).&lt;br /&gt;&lt;pre&gt;An error occurred while launching/running &lt;br /&gt;the application.&lt;br /&gt;&lt;br /&gt;Title: simpleblending&lt;br /&gt;Vendor: Peter Finch&lt;br /&gt;Category: Unexpected Error&lt;br /&gt;&lt;br /&gt;Unexpected exception: java.lang.Exception&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I tracked it down to the location I was getting the JOGL extension from. I originally used the prescribed location of &lt;I&gt;https://jogl.dev.java.net/webstart/jogl-1-1.jnlp&lt;/I&gt;, however, when I changed this to &lt;I&gt;http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp&lt;/I&gt; the problem disappeared and the application started. Perhaps this is a library version problem or something. I understand it is possible to have your own copies of the libraries, which is probably a good idea so that you always know what version or JOGL your application running against. I'll work that out later...&lt;br /&gt;&lt;p&gt;Below is the JNPL file I used and &lt;a href="http://www.homepla.net/webstart/simpleblending/simpleblending.jnlp"&gt;here&lt;/a&gt; is a link to the webstart application. Just create a JAR file as you normally would. I like to use Ant scripts to automate the building and deployment for this sort of thing, as it is really easy and built into Eclipse. Note that the first time you load this it will go off and download the JOGL jar and native libraries for your platform. This could take a while (it's about 1.5MB's of data), but the great thing is that once it is downloaded, if any of you other applications use the same location they will reuse the already downloaded version and start up a lot quicking. JNPL even handles version changes (it's so cool!)&lt;br /&gt;&lt;pre class="code"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;jnlp spec="1.0+" codebase="http://www.homepla.net/webstart/simpleblending" href="simpleblending.jnlp"&amp;gt;&lt;br /&gt;  &amp;lt;information&gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Simple Blending&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;vendor&amp;gt;Peter Finch&amp;lt;/vendor&amp;gt;&lt;br /&gt;    &amp;lt;homepage href="http://www.homepla.net/webstart/simpleblending/" /&amp;gt;&lt;br /&gt;    &amp;lt;description&amp;gt;JOGL Webstart Example 1&amp;lt;/description&amp;gt;&lt;br /&gt;    &amp;lt;offline-allowed/&amp;gt;&lt;br /&gt;  &amp;lt;/information&amp;gt;&lt;br /&gt;  &amp;lt;resources&amp;gt;&lt;br /&gt;    &amp;lt;j2se version="1.4+" /&amp;gt;&lt;br /&gt;    &amp;lt;jar href="jplanet.jar" /&amp;gt;&lt;br /&gt;    &amp;lt;property name="sun.java2d.noddraw" value="true"/&amp;gt;&lt;br /&gt;    &amp;lt;extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp" /&amp;gt;&lt;br /&gt;  &amp;lt;/resources&amp;gt;&lt;br /&gt;  &amp;lt;application-desc main-class="jplanet.JPlanetWindow" /&amp;gt;&lt;br /&gt;&amp;lt;/jnlp&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115294665290701947?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115294665290701947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115294665290701947' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115294665290701947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115294665290701947'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/07/jogl-java-webstart-jnpl.html' title='JOGL Java Webstart (JNPL)'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115277336781218284</id><published>2006-07-13T16:19:00.000+10:00</published><updated>2006-07-14T21:15:14.276+10:00</updated><title type='text'>JOGL Draw Arrays</title><content type='html'>Calling the OpenGL drawing primitives in Java, like glVertex() and glNormal(), quickly becomes a bottleneck for rendering scenes. The function call overhead, although small, when multiplied a million times for each polygon is a problem very quickly, however, this can be overcome using glDrawArrays (commonly known as vertex arrays). Vertices, normals, colours and texture coordinates can be loaded into an IntBuffer, FloatBuffer or a DoubleBuffer (depending on what you want to use) and then sent to the rendering engine using a single glDrawArrays() function call.&lt;br /&gt;&lt;pre class=”code”&gt;&lt;br /&gt;import java.nio.DoubleBuffer ;&lt;br /&gt;..&lt;br /&gt;DoubleBuffer verticesBuffer = BufferUtil.newDoubleBuffer(3 * 3) ;&lt;br /&gt;..&lt;br /&gt;verticesBuffer.put(c0.x) ;&lt;br /&gt;verticesBuffer.put(c0.y) ;&lt;br /&gt;verticesBuffer.put(c0.z) ;&lt;br /&gt;verticesBuffer.put(c1.x) ;&lt;br /&gt;verticesBuffer.put(c1.y) ;&lt;br /&gt;verticesBuffer.put(c1.z) ;&lt;br /&gt;verticesBuffer.put(c2.x) ;&lt;br /&gt;verticesBuffer.put(c2.y) ;&lt;br /&gt;verticesBuffer.put(c2.z) ;&lt;br /&gt;..&lt;br /&gt;gl.glEnableClientState (GL.GL_VERTEX_ARRAY);        &lt;br /&gt;verticesBuffer.rewind();&lt;br /&gt;gl.glVertexPointer(3, GL.GL_DOUBLE, 0, verticesBuffer);        &lt;br /&gt;gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Sadly, there is still a function call overhead loading the values into the DoubleBuffer, however, this is less that the overhead of calling glVertex() multiple times. Make sure you rewind the location in the buffer using verticesBuffer.rewind() or verticesBuffer.position(0) before calling glVertexPointer() otherwise you will load the current location in the buffer into OpenGL instead of the starting location and you’ll end up only seeing a new vertices each call.&lt;br /&gt;&lt;p&gt;I found that loading the values into a local array and the calling the put(double[], int, int) function to load multiple values at once was much slower that calling multiple put(double) functions, even if the array was pre-allocated and reused. I could not find any way to load values into the buffers without doing it thought a function call… so if you know how to do please let me know.&lt;/p&gt;&lt;br /&gt;&lt;pre class=”code”&gt;&lt;br /&gt;// Really slow for some reason.&lt;br /&gt;double array[] = new double[9] ;&lt;br /&gt;array[0] = c0.x ;&lt;br /&gt;array[1] = c0.y ;&lt;br /&gt;..&lt;br /&gt;verticesBuffer.put(array, 0, 9) ;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Rendering tip… remember to set gl.glEnable(GL.GL_NORMALIZE) when using matrixes to translating and scaling groups of vertices, otherwise the vertices normals passed to OpenGL get transformed as well, but they don’t get re-normalized, so you end up of unexpected lighting results.&lt;br /&gt;&lt;p&gt;&lt;a href="http://user.cs.tu-berlin.de/~schabby/VertexArrayTest.java"&gt;Here&lt;/a&gt; is some good example code but make sure you add that rewind calling glColorPointer().&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115277336781218284?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115277336781218284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115277336781218284' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115277336781218284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115277336781218284'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/07/jogl-draw-arrays.html' title='JOGL Draw Arrays'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115213751101656199</id><published>2006-07-06T07:57:00.000+10:00</published><updated>2006-07-06T08:12:37.283+10:00</updated><title type='text'>Using the mouse</title><content type='html'>When using a Java Frame to hold the JOGL GLCanvas, interaction with the frame, using the mouse, can be done in the usual way by using a Listener. The listener event handler class (the class which is to receive the events), must implement the MouseListener, MouseMotionListener interfaces. One of the nice things about &lt;a href="http://www.eclipse.org/"&gt;Eclipse&lt;/a&gt; is that the moment you add these interfaces to the class it will ask you if you want to add the corresponding functions.&lt;br /&gt;&lt;pre class="code"&gt;public class joglpbuffer implements &lt;br /&gt;  GLEventListener, &lt;br /&gt;  MouseListener, &lt;br /&gt;  MouseMotionListener  {&lt;br /&gt;&lt;br /&gt;  public void init(GLAutoDrawable drawable) {&lt;br /&gt;    drawable.addMouseListener(this);&lt;br /&gt;    drawable.addMouseMotionListener(this);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The event functions themselves are self explanatory. They are all passed a MouseEvent argument which can be used to determine the location of the mouse or the button that was just pressed.&lt;br /&gt;&lt;pre class="code"&gt;  public void mouseClicked(MouseEvent e) {}&lt;br /&gt;  public void mouseEntered(MouseEvent e) {}&lt;br /&gt;  public void mouseExited(MouseEvent e) {}&lt;br /&gt;  public void mouseMoved(MouseEvent e) {} &lt;br /&gt;  public void mousePressed(MouseEvent e) {&lt;br /&gt;    prevMouseX = e.getX();&lt;br /&gt;    prevMouseY = e.getY();&lt;br /&gt;    if ((e.getModifiers() &amp; e.BUTTON3_MASK) != 0) {&lt;br /&gt;      mouseRButtonDown = true;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  public void mouseReleased(MouseEvent e) {&lt;br /&gt;    if ((e.getModifiers() &amp; e.BUTTON3_MASK) != 0) {&lt;br /&gt;      mouseRButtonDown = false;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  public void mouseDragged(MouseEvent e) {&lt;br /&gt;    int x = e.getX();&lt;br /&gt;    int y = e.getY();&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115213751101656199?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115213751101656199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115213751101656199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115213751101656199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115213751101656199'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/07/using-mouse.html' title='Using the mouse'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115148991287420959</id><published>2006-06-28T19:53:00.000+10:00</published><updated>2006-06-29T14:20:58.970+10:00</updated><title type='text'>Simple Application</title><content type='html'>&lt;h4&gt;Step 1 - Create a frame&lt;/h4&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4439/3219/1600/teapot.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/4439/3219/200/teapot.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;There are two types of OpenGL "windows" in JOGL, a GLCanvas and a GLJPanel. The GLJPanel is for use with the normal Java2D API while the GLCanvas is a high performace version.  To create an OpenGL window first create a Frame and the simply add a GLCanvas to it. &lt;br /&gt;&lt;pre&gt;Frame frame = new Frame("PBuffers") ;&lt;br /&gt;GLCanvas canvas = new GLCanvas() ;&lt;br /&gt;canvas.addGLEventListener(this);&lt;br /&gt;frame.add(canvas);&lt;br /&gt;frame.setSize(640, 480);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The application is notified of OpenGL events via 4 simple callbacks that are called following the registration of the GLEventListener listener via the canvas.addGLEventListener(this) call. It's easier to use the GLU functions with can be called from the GLU object.&lt;br /&gt;&lt;h4&gt;Step 2 - Initilize the OpenGL context&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;The init() method is called when the windows is first created. The display() function is only called when the display needs to be repainted so the Animator class be used to update the display periodically.&lt;br /&gt;&lt;pre&gt;public void init(GLAutoDrawable drawable) &lt;br /&gt;{&lt;br /&gt;  final GL gl = drawable.getGL();&lt;br /&gt;  gl.setSwapInterval(0);&lt;br /&gt;  animator = new Animator(canvas);&lt;br /&gt;  animator.setRunAsFastAsPossible(true) ;&lt;br /&gt;  animator.start() ;  &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;Step 3 - Add a display callback&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;The display() method is called when the window needs to be updated and is where all the OpenGL drawing should take place. &lt;br /&gt;&lt;pre&gt;public void display(GLAutoDrawable drawable) &lt;br /&gt;{&lt;br /&gt;  GL gl = drawable.getGL() ;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;Step 4 - Add a reshape callback&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;The reshape() method is called when the window size changes. This callback is called once when the application is started.&lt;br /&gt;&lt;pre&gt;public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) &lt;br /&gt;{&lt;br /&gt;  GL gl = drawable.getGL();&lt;br /&gt;  float h = (float) width / (float) height;&lt;br /&gt;  gl.glMatrixMode(GL.GL_PROJECTION);&lt;br /&gt;  gl.glLoadIdentity();&lt;br /&gt;  glu.gluPerspective( 40.0, h, 1.00, 100.0 );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;Step 5 - Add a displayChanged callback&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;The displayChanged() method is called then the display is changed.&lt;br /&gt;&lt;pre&gt;public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) &lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Notes:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;If the GLUT objects appear to be rendered back to front (or inside out) then try gl.glEnable(GL.GL_CW) as GLUT polygons are rendered in clock-wise order.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Setup light sources with all options as LIGHT0 has defaults that the others lights do not appear to have.&lt;br&gt;&lt;br /&gt;&lt;pre&gt;gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, light2pos, 0);&lt;br /&gt;gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, light2amb, 0);&lt;br /&gt;gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, light2diff, 0);&lt;br /&gt;gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, light2spec, 0);&lt;br /&gt;gl.glEnable(GL.GL_LIGHT1);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115148991287420959?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115148991287420959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115148991287420959' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115148991287420959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115148991287420959'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/06/simple-application.html' title='Simple Application'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115104423616248403</id><published>2006-06-23T16:02:00.000+10:00</published><updated>2006-06-23T17:10:50.083+10:00</updated><title type='text'>What happened to my frame rate!</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4439/3219/1600/gears.png"&gt;&lt;img style="float:right; width: 100pt;margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/4439/3219/200/gears.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;Ok, I don't mean to boast, but I do have a pretty good graphics card… it’s a NVidia 6800. My PC is no slouch either, and I’ve got plenty of memory, so when I started up the gears.java demo I was expecting a pretty high frame. However, it just didn’t look right. I added some code to the display() function (which gets called to display each frame) and I was getting 60FPS... Hold the phone!!!!&lt;br /&gt;&lt;pre&gt;if(nFrame++ &gt; 200) {&lt;br /&gt;  if(nLastUpdate != 0) {&lt;br /&gt;    long nTimeMS = System.currentTimeMillis() - nLastUpdate ;&lt;br /&gt;    System.out.println(nFrame + " in " + nTimeMS + "msec (" +&lt;br /&gt;      nFrame * 1000 / nTimeMS + " FPS)") ;&lt;br /&gt;  } &lt;br /&gt;  nFrame = 0 ;&lt;br /&gt;  nLastUpdate = System.currentTimeMillis() ;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;60FPS…um… that is my monitor refresh rate (I’ve got an LCD). Ahhh, now I remember… &lt;a href="http://en.wikipedia.org/wiki/Vertical_blank"&gt;Vertical retrace&lt;/a&gt;! To stop frames from tearing while being display most OpenGL implementations pause and wait for the monitors Vertical Retrace Interrupt before updating the image. Usually, it’s a pain to turn this off in OpenGL but in JOGL it’s easy. If you want to pull the maximum frame rate just set the "swap interval" to 0 in the init() function. &lt;br /&gt;&lt;pre&gt;public void init(GLAutoDrawable drawable) {&lt;br /&gt;  GL gl = drawable.getGL();&lt;br /&gt;  gl.setSwapInterval(0);&lt;br /&gt;  …&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;1100 FPS … That’s better, now that’s what I like to see!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115104423616248403?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115104423616248403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115104423616248403' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115104423616248403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115104423616248403'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/06/what-happened-to-my-frame-rate.html' title='What happened to my frame rate!'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115102896041186881</id><published>2006-06-23T12:03:00.000+10:00</published><updated>2006-06-23T15:54:56.486+10:00</updated><title type='text'>Development Environment</title><content type='html'>I use &lt;a href="http://www.eclipse.org/"&gt;Eclipse&lt;/a&gt; for all my Java development. In fact which all it's difference plugins Eclipse is pretty a pretty good development environment for most things, I also use it for PHP, ASP and C/C++ on Linux. I found the following &lt;a href="http://www.euclideanspace.com/software/language/java/eclipse/index.htm"&gt;website&lt;/a&gt; by Martin John Baker that does a good job of describing the setting up of the Eclipse IDE enviroment for JOGL. Basically, for setting up a simple Java JOGL Application&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download the "jogl.jar" and the platform native libraries like "jogl-natives-macosx-universal.jar".&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create a new Java project.&lt;/li&gt;&lt;li&gt;In "project | Properties | Java Build Path" add the "jogl.jar" library.&lt;/li&gt;&lt;li&gt;Then the tricky bit, add the native libraries. They come is a "jar" from the JOGL website so you may have to extract the DLL's (so's for linux, etc) from the JAR and place them in a new directory. Then just add the path as described in the Martin's web page. i.e. Select the "Native library location" and set it to the location of your DLL's.&lt;br /&gt;&lt;br&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4439/3219/1600/JOGLsetup.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/blogger/4439/3219/320/JOGLsetup.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Add some code. I used the "gears.java" class from the demos that come with JOGL.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115102896041186881?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115102896041186881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115102896041186881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115102896041186881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115102896041186881'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/06/development-environment.html' title='Development Environment'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115097217879251443</id><published>2006-06-22T20:24:00.000+10:00</published><updated>2006-07-23T22:12:38.283+10:00</updated><title type='text'>Links</title><content type='html'>Useful links for developing JOGL application.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.opengl.org/"&gt;OpenGL&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="https://jogl.dev.java.net/"&gt;JOGL homepage&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.euclideanspace.com/software/language/java/eclipse/index.htm"&gt;Setting up eclipse&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://today.java.net/pub/a/today/2003/09/11/jogl2d.html"&gt;Jumping into JOGL&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.gamedev.net/reference/articles/article695.asp"&gt;3D Matrix Math Demystified&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115097217879251443?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115097217879251443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115097217879251443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115097217879251443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115097217879251443'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/06/links.html' title='Links'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-30081901.post-115095854857309117</id><published>2006-06-22T16:37:00.000+10:00</published><updated>2006-06-22T17:00:05.953+10:00</updated><title type='text'>Introduction</title><content type='html'>After years of writing OpenGL applications in C or C++ I have finally decided to try my hand at one of the many Java OpenGL API's. I have been programming in Java for many years, but I never really thought about using it for OpenGL, as I always thought it would be too slow. One of my mates at work was using &lt;a href="http://www.lwjgl.org/"&gt;LWJGL&lt;/a&gt; to do some stuff and I was pretty impressed by what he could do using Java, so I thought it's about time to give it a go.&lt;br /&gt;&lt;br /&gt;I have decided to try &lt;a href="https://jogl.dev.java.net/"&gt;JOGL&lt;/a&gt; for a number of reasons, but mainly because it seems to have better support for OpenGL 2.0 and all those neat OpenGL extensions that make modern 3D graphics look so good and seems to have a bit better Java community support. I could be wring, that's what I'm here to find out. So, I have set up this Blog to record my notes and programs, however, my hope is that you (yes YOU!) may also find this useful or even be able to help me out with suggestions or your experience. Anyway, we'll see how I go...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30081901-115095854857309117?l=joglblogl.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joglblogl.blogspot.com/feeds/115095854857309117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=30081901&amp;postID=115095854857309117' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115095854857309117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/30081901/posts/default/115095854857309117'/><link rel='alternate' type='text/html' href='http://joglblogl.blogspot.com/2006/06/introduction.html' title='Introduction'/><author><name>PC</name><uri>http://www.blogger.com/profile/13919671589185282895</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://www.homepla.net/images/me2006a.jpg'/></author><thr:total>0</thr:total></entry></feed>
