diff options
author | Kenneth Russel <[email protected]> | 2005-09-09 09:05:33 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-09-09 09:05:33 +0000 |
commit | 8130f512b1c140372d85b58303cb10eeeb914435 (patch) | |
tree | bfbd98822a81eb61c7cf87c3b9990321e9ec7ecc /src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java | |
parent | ba4ea2f846e55283efbc19d4dc7a62a1f116e4b1 (diff) |
Initial integration of JOGL with the Java2D OpenGL pipeline in the Sun JDK.
GLJPanel has a new rendering path which captures the Java2D back buffer via
GLDrawableFactory.createExternalGLDrawable()/createExternalGLContext() and
creates a new context on it for performing JOGL rendering. The new path is
enabled by default in Mustang build 51 and later when the Java2D/OpenGL
pipeline is turned on via -Dsun.java2d.opengl=true, and yields huge speedups
relative to the previous pbuffer-based GLJPanel implementation. GLJPanel in
the new configuration is nearly as fast as the GLCanvas, and still provides
100% correct Swing integration. No public API changes were required to JOGL
in order to implement this integration with one exception in
GLJPanel.isOGLPipelineEnabled(): see below.
Issues still remain, such as the desire to run all (not just some) OpenGL
work on the Java2D-internal Queue Flusher Thread to maintain single-threaded
behavior of the library. Currently GLCanvas's OpenGL work is run on the EDT
while GLJPanel's and GLPbuffer's OpenGL work is run on the QFT. Significant
restructuring to the GLCanvas will be required to achieve this goal. There is
some lag of mouse events with demos which are more expensive to render which
needs to be investigated. It will not be possible to implement calling of
display() on other non-pbuffer GLAutoDrawables from within the
GLEventListener's display() callback in this model. There are other issues as
well.
GLJPanel falls back to using a pbuffer internally when the Java2D back
buffer's pixel format is not suitable for rendering the JOGL demos (for
example, the InfiniteShadowVolumes demo, which requires stencil bits).
Added GLJPanel.isOGLPipelineEnabled() which applications can use to decide
whether to clear the color buffer or leave prior Java2D rendering results in
place for non-opaque GLJPanels. The JGears demo has been modified to query
that flag to maintain the gradient behind it while rendering the gears
directly into the Java2D back buffer.
GLCanvas uses the pixel format specified by Java2D if one is already set. It
turns out that when the Java2D OpenGL pipeline is enabled, one is always set
by default even though no Java2D rendering is performed into it, because the
AWT clears the background of Canvases by default in certain situations. This
can be disabled (only globally, unfortunately) by specifying
-Dsun.awt.noerasebackground=true.
Fixed issues with HDR and HWShadowmapsSimple demos where they needed to pay
attention to the x and y coordinates passed down in the reshape callback in
order to set up the correct OpenGL viewport. Fixed minor shutdown-related
issues with demos using gleem's ManipManager.
Tested (on NVidia hardware only so far) on Windows and X11 platforms with
Mustang build 51.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JSR-231@125 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java')
-rw-r--r-- | src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java index ca2a8aa..23029bd 100644 --- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java +++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java @@ -95,6 +95,7 @@ public class HWShadowmapsSimple extends Demo { public void shutdownDemo() { ManipManager.getManipManager().unregisterWindow(drawable); + drawable.removeGLEventListener(this); super.shutdownDemo(); } @@ -168,6 +169,8 @@ public class HWShadowmapsSimple extends Demo { private Mat4f spotlightTransform = new Mat4f(); private Mat4f spotlightInverseTransform = new Mat4f(); private Mat4f objectTransform = new Mat4f(); + private int viewportX; + private int viewportY; public void init(GLAutoDrawable drawable) { // Use debug pipeline @@ -348,13 +351,16 @@ public class HWShadowmapsSimple extends Demo { switch (displayMode) { case RENDER_SCENE_FROM_CAMERA_VIEW: render_scene_from_camera_view(gl, glu, drawable, params); break; case RENDER_SCENE_FROM_CAMERA_VIEW_SHADOWED: render_scene_from_camera_view_shadowed(gl, glu, drawable, params); break; - case RENDER_SCENE_FROM_LIGHT_VIEW: render_scene_from_light_view(gl, glu, drawable); break; + case RENDER_SCENE_FROM_LIGHT_VIEW: render_scene_from_light_view(gl, glu, drawable, viewportX, viewportY); break; default: throw new RuntimeException("Illegal display mode " + displayMode); } } // Unused routines - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + viewportX = x; + viewportY = y; + } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} private void checkExtension(GL gl, String extensionName) { @@ -428,7 +434,7 @@ public class HWShadowmapsSimple extends Demo { ((Tweak) tweaks.get(POLYGON_OFFSET_BIAS)).val); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); - render_scene_from_light_view(gl, glu, drawable); + render_scene_from_light_view(gl, glu, drawable, 0, 0); gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); @@ -654,7 +660,7 @@ public class HWShadowmapsSimple extends Demo { gl.glActiveTexture(GL.GL_TEXTURE0); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); - gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + gl.glViewport(viewportX, viewportY, drawable.getWidth(), drawable.getHeight()); applyTransform(gl, cameraPerspective); gl.glMatrixMode(GL.GL_MODELVIEW); render_scene(gl, cameraTransform, drawable, params); @@ -723,7 +729,7 @@ public class HWShadowmapsSimple extends Demo { gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); - gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + gl.glViewport(viewportX, viewportY, drawable.getWidth(), drawable.getHeight()); applyTransform(gl, cameraPerspective); gl.glMatrixMode(GL.GL_MODELVIEW); render_scene(gl, cameraTransform, drawable, params); @@ -739,15 +745,15 @@ public class HWShadowmapsSimple extends Demo { render_light_frustum(gl); } - private void largest_square_power_of_two_viewport(GL gl, GLAutoDrawable drawable) { + private void largest_square_power_of_two_viewport(GL gl, GLAutoDrawable drawable, int viewportX, int viewportY) { float min = Math.min(drawable.getWidth(), drawable.getHeight()); float log2min = (float) Math.log(min) / (float) Math.log(2.0); float pow2 = (float) Math.floor(log2min); int size = 1 << (int) pow2; - gl.glViewport(0, 0, size, size); + gl.glViewport(viewportX, viewportY, size, size); } - private void render_scene_from_light_view(GL gl, GLU glu, GLAutoDrawable drawable) { + private void render_scene_from_light_view(GL gl, GLU glu, GLAutoDrawable drawable, int viewportX, int viewportY) { // place light gl.glPushMatrix(); gl.glLoadIdentity(); @@ -781,7 +787,7 @@ public class HWShadowmapsSimple extends Demo { glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); gl.glMatrixMode(GL.GL_MODELVIEW); if (displayMode == RENDER_SCENE_FROM_LIGHT_VIEW) - largest_square_power_of_two_viewport(gl, drawable); + largest_square_power_of_two_viewport(gl, drawable, viewportX, viewportY); render_scene(gl, spotlightTransform, null, null); gl.glActiveTexture(GL.GL_TEXTURE1); |