diff options
author | Kenneth Russel <[email protected]> | 2008-12-30 16:17:12 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-12-30 16:17:12 +0000 |
commit | a140be936d8111bcee0d9b2cdc5979c681d3d03a (patch) | |
tree | 3d851a6f6ace09cc32f90ca4abcd2ab1b518a1d2 /src | |
parent | 003684ca21121ca147ff00d1b2c3145a1fcf7e06 (diff) |
Moved GL2- and AWT-specific utility classes into the AWT package
because the expectation is that the AWT implementation will only be
used on the desktop, where the GL2 profile is always available, and
renamed the classes to their JOGL 1.0 naming convention. Updated demos.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1830 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rwxr-xr-x | src/classes/com/sun/opengl/util/awt/Overlay.java (renamed from src/classes/com/sun/opengl/util/awt/gl2/GL2Overlay.java) | 12 | ||||
-rwxr-xr-x | src/classes/com/sun/opengl/util/awt/Screenshot.java (renamed from src/classes/com/sun/opengl/util/awt/gl2/GL2Screenshot.java) | 7 | ||||
-rwxr-xr-x | src/classes/com/sun/opengl/util/awt/TextRenderer.java (renamed from src/classes/com/sun/opengl/util/awt/gl2/GL2TextRenderer.java) | 65 | ||||
-rwxr-xr-x | src/classes/com/sun/opengl/util/awt/TextureRenderer.java (renamed from src/classes/com/sun/opengl/util/awt/gl2/GL2TextureRenderer.java) | 19 |
4 files changed, 47 insertions, 56 deletions
diff --git a/src/classes/com/sun/opengl/util/awt/gl2/GL2Overlay.java b/src/classes/com/sun/opengl/util/awt/Overlay.java index 1302f62ea..5a54a7161 100755 --- a/src/classes/com/sun/opengl/util/awt/gl2/GL2Overlay.java +++ b/src/classes/com/sun/opengl/util/awt/Overlay.java @@ -37,28 +37,26 @@ * and developed by Kenneth Bradley Russell and Christopher John Kline. */ -package com.sun.opengl.util.awt.gl2; +package com.sun.opengl.util.awt; import java.awt.Graphics2D; import javax.media.opengl.*; import com.sun.opengl.util.texture.*; -import com.sun.opengl.util.awt.*; - /** Provides a Java 2D overlay on top of an arbitrary GLDrawable, making it easier to do things like draw text and images on top of an OpenGL scene while still maintaining reasonably good efficiency. */ -public class GL2Overlay { +public class Overlay { private GLDrawable drawable; - private GL2TextureRenderer renderer; + private TextureRenderer renderer; private boolean contentsLost; /** Creates a new Java 2D overlay on top of the specified GLDrawable. */ - public GL2Overlay(GLDrawable drawable) { + public Overlay(GLDrawable drawable) { this.drawable = drawable; } @@ -201,7 +199,7 @@ public class GL2Overlay { private void validateRenderer() { if (renderer == null) { - renderer = new GL2TextureRenderer(drawable.getWidth(), + renderer = new TextureRenderer(drawable.getWidth(), drawable.getHeight(), true); contentsLost = true; diff --git a/src/classes/com/sun/opengl/util/awt/gl2/GL2Screenshot.java b/src/classes/com/sun/opengl/util/awt/Screenshot.java index e72a7b106..6c6bc7a26 100755 --- a/src/classes/com/sun/opengl/util/awt/gl2/GL2Screenshot.java +++ b/src/classes/com/sun/opengl/util/awt/Screenshot.java @@ -34,7 +34,7 @@ * facility. */ -package com.sun.opengl.util.awt.gl2; +package com.sun.opengl.util.awt; import java.awt.image.*; import java.io.*; @@ -48,12 +48,11 @@ import javax.media.opengl.glu.gl2.*; import com.sun.opengl.impl.io.*; import com.sun.opengl.util.io.*; -import com.sun.opengl.util.awt.*; /** Utilities for taking screenshots of OpenGL applications. */ -public class GL2Screenshot { - private GL2Screenshot() {} +public class Screenshot { + private Screenshot() {} /** * Takes a fast screenshot of the current OpenGL drawable to a Targa diff --git a/src/classes/com/sun/opengl/util/awt/gl2/GL2TextRenderer.java b/src/classes/com/sun/opengl/util/awt/TextRenderer.java index 0ec232eca..525e0824f 100755 --- a/src/classes/com/sun/opengl/util/awt/gl2/GL2TextRenderer.java +++ b/src/classes/com/sun/opengl/util/awt/TextRenderer.java @@ -36,7 +36,7 @@ * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ -package com.sun.opengl.util.awt.gl2; +package com.sun.opengl.util.awt; import com.sun.opengl.impl.*; import com.sun.opengl.impl.packrect.*; @@ -44,9 +44,6 @@ import com.sun.opengl.util.*; import com.sun.opengl.util.io.*; import com.sun.opengl.util.texture.*; import com.sun.opengl.util.texture.awt.*; -import com.sun.opengl.util.gl2.*; -import com.sun.opengl.util.awt.*; -import com.sun.opengl.util.awt.gl2.*; import java.awt.AlphaComposite; import java.awt.Color; @@ -119,7 +116,7 @@ import javax.media.opengl.util.*; pack both glyphs and full Strings' rendering results (which are variable size) onto a larger OpenGL texture. The internal backing store is maintained using a {@link - com.sun.opengl.util.awt.gl2.GL2TextureRenderer TextureRenderer}. A least + com.sun.opengl.util.awt.TextureRenderer TextureRenderer}. A least recently used (LRU) algorithm is used to discard previously rendered strings; the specific algorithm is undefined, but is currently implemented by flushing unused Strings' rendering @@ -130,7 +127,7 @@ import javax.media.opengl.util.*; @author John Burkey @author Kenneth Russell */ -public class GL2TextRenderer { +public class TextRenderer { private static final boolean DEBUG = Debug.debug("TextRenderer"); // These are occasionally useful for more in-depth debugging @@ -166,7 +163,7 @@ public class GL2TextRenderer { private RectanglePacker packer; private boolean haveMaxSize; private RenderDelegate renderDelegate; - private GL2TextureRenderer cachedBackingStore; + private TextureRenderer cachedBackingStore; private Graphics2D cachedGraphics; private FontRenderContext cachedFontRenderContext; private Map /*<String,Rect>*/ stringLocations = new HashMap /*<String,Rect>*/(); @@ -216,7 +213,7 @@ public class GL2TextRenderer { @param font the font to render with */ - public GL2TextRenderer(Font font) { + public TextRenderer(Font font) { this(font, false, false, null, false); } @@ -230,7 +227,7 @@ public class GL2TextRenderer { @param font the font to render with @param mipmap whether to attempt use of automatic mipmap generation */ - public GL2TextRenderer(Font font, boolean mipmap) { + public TextRenderer(Font font, boolean mipmap) { this(font, false, false, null, mipmap); } @@ -247,7 +244,7 @@ public class GL2TextRenderer { @param useFractionalMetrics whether to use fractional font metrics at the Java 2D level */ - public GL2TextRenderer(Font font, boolean antialiased, + public TextRenderer(Font font, boolean antialiased, boolean useFractionalMetrics) { this(font, antialiased, useFractionalMetrics, null, false); } @@ -266,7 +263,7 @@ public class GL2TextRenderer { @param renderDelegate the render delegate to use to draw the text's bitmap, or null to use the default one */ - public GL2TextRenderer(Font font, boolean antialiased, + public TextRenderer(Font font, boolean antialiased, boolean useFractionalMetrics, RenderDelegate renderDelegate) { this(font, antialiased, useFractionalMetrics, renderDelegate, false); } @@ -288,7 +285,7 @@ public class GL2TextRenderer { text's bitmap, or null to use the default one @param mipmap whether to attempt use of automatic mipmap generation */ - public GL2TextRenderer(Font font, boolean antialiased, + public TextRenderer(Font font, boolean antialiased, boolean useFractionalMetrics, RenderDelegate renderDelegate, boolean mipmap) { this.font = font; @@ -609,8 +606,8 @@ public class GL2TextRenderer { (int) Math.ceil(src.getHeight()) + 2 * boundary); } - private GL2TextureRenderer getBackingStore() { - GL2TextureRenderer renderer = (GL2TextureRenderer) packer.getBackingStore(); + private TextureRenderer getBackingStore() { + TextureRenderer renderer = (TextureRenderer) packer.getBackingStore(); if (renderer != cachedBackingStore) { // Backing store changed since last time; discard any cached Graphics2D @@ -627,7 +624,7 @@ public class GL2TextRenderer { } private Graphics2D getGraphics2D() { - GL2TextureRenderer renderer = getBackingStore(); + TextureRenderer renderer = getBackingStore(); if (cachedGraphics == null) { cachedGraphics = renderer.createGraphics(); @@ -880,7 +877,7 @@ public class GL2TextRenderer { } // OK, now draw the portion of the backing store to the screen - GL2TextureRenderer renderer = getBackingStore(); + TextureRenderer renderer = getBackingStore(); // NOTE that the rectangles managed by the packer have their // origin at the upper-left but the TextureRenderer's origin is @@ -1146,12 +1143,12 @@ public class GL2TextRenderer { // whether we're likely to need to support a full RGBA backing // store (i.e., non-default Paint, foreground color, etc.), but // for now, let's just be more efficient - GL2TextureRenderer renderer; + TextureRenderer renderer; if (renderDelegate.intensityOnly()) { - renderer = GL2TextureRenderer.createAlphaOnlyRenderer(w, h, mipmap); + renderer = TextureRenderer.createAlphaOnlyRenderer(w, h, mipmap); } else { - renderer = new GL2TextureRenderer(w, h, true, mipmap); + renderer = new TextureRenderer(w, h, true, mipmap); } renderer.setSmoothing(smoothing); @@ -1164,7 +1161,7 @@ public class GL2TextRenderer { } public void deleteBackingStore(Object backingStore) { - ((GL2TextureRenderer) backingStore).dispose(); + ((TextureRenderer) backingStore).dispose(); } public boolean preExpand(Rect cause, int attemptNumber) { @@ -1247,20 +1244,20 @@ public class GL2TextRenderer { } if (isOrthoMode) { - ((GL2TextureRenderer) oldBackingStore).endOrthoRendering(); + ((TextureRenderer) oldBackingStore).endOrthoRendering(); } else { - ((GL2TextureRenderer) oldBackingStore).end3DRendering(); + ((TextureRenderer) oldBackingStore).end3DRendering(); } } - GL2TextureRenderer newRenderer = (GL2TextureRenderer) newBackingStore; + TextureRenderer newRenderer = (TextureRenderer) newBackingStore; g = newRenderer.createGraphics(); } public void move(Object oldBackingStore, Rect oldLocation, Object newBackingStore, Rect newLocation) { - GL2TextureRenderer oldRenderer = (GL2TextureRenderer) oldBackingStore; - GL2TextureRenderer newRenderer = (GL2TextureRenderer) newBackingStore; + TextureRenderer oldRenderer = (TextureRenderer) oldBackingStore; + TextureRenderer newRenderer = (TextureRenderer) newBackingStore; if (oldRenderer == newRenderer) { // Movement on the same backing store -- easy case @@ -1282,17 +1279,17 @@ public class GL2TextRenderer { g.dispose(); // Sync the whole surface - GL2TextureRenderer newRenderer = (GL2TextureRenderer) newBackingStore; + TextureRenderer newRenderer = (TextureRenderer) newBackingStore; newRenderer.markDirty(0, 0, newRenderer.getWidth(), newRenderer.getHeight()); // Re-enter the begin / end pair if necessary if (inBeginEndPair) { if (isOrthoMode) { - ((GL2TextureRenderer) newBackingStore).beginOrthoRendering(beginRenderingWidth, + ((TextureRenderer) newBackingStore).beginOrthoRendering(beginRenderingWidth, beginRenderingHeight, beginRenderingDepthTestDisabled); } else { - ((GL2TextureRenderer) newBackingStore).begin3DRendering(); + ((TextureRenderer) newBackingStore).begin3DRendering(); } // Push client attrib bits used by the pipelined quad renderer @@ -1301,10 +1298,10 @@ public class GL2TextRenderer { if (haveCachedColor) { if (cachedColor == null) { - ((GL2TextureRenderer) newBackingStore).setColor(cachedR, + ((TextureRenderer) newBackingStore).setColor(cachedR, cachedG, cachedB, cachedA); } else { - ((GL2TextureRenderer) newBackingStore).setColor(cachedColor); + ((TextureRenderer) newBackingStore).setColor(cachedColor); } } } else { @@ -1450,7 +1447,7 @@ public class GL2TextRenderer { mPipelinedQuadRenderer = new Pipelined_QuadRenderer(); } - GL2TextureRenderer renderer = getBackingStore(); + TextureRenderer renderer = getBackingStore(); // Handles case where NPOT texture is used for backing store TextureCoords wholeImageTexCoords = renderer.getTexture().getImageTexCoords(); float xScale = wholeImageTexCoords.right(); @@ -1770,7 +1767,7 @@ public class GL2TextRenderer { if (mOutstandingGlyphsVerticesPipeline > 0) { GL2 gl = GLUgl2.getCurrentGL2(); - GL2TextureRenderer renderer = getBackingStore(); + TextureRenderer renderer = getBackingStore(); Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? mVertCoords.rewind(); @@ -1813,7 +1810,7 @@ public class GL2TextRenderer { private void drawIMMEDIATE() { if (mOutstandingGlyphsVerticesPipeline > 0) { - GL2TextureRenderer renderer = getBackingStore(); + TextureRenderer renderer = getBackingStore(); Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? GL2 gl = GLUgl2.getCurrentGL2(); @@ -1869,7 +1866,7 @@ public class GL2TextRenderer { return; } - GL2TextureRenderer rend = getBackingStore(); + TextureRenderer rend = getBackingStore(); final int w = rend.getWidth(); final int h = rend.getHeight(); rend.beginOrthoRendering(w, h); diff --git a/src/classes/com/sun/opengl/util/awt/gl2/GL2TextureRenderer.java b/src/classes/com/sun/opengl/util/awt/TextureRenderer.java index 649344b31..9650d759a 100755 --- a/src/classes/com/sun/opengl/util/awt/gl2/GL2TextureRenderer.java +++ b/src/classes/com/sun/opengl/util/awt/TextureRenderer.java @@ -37,7 +37,7 @@ * and developed by Kenneth Bradley Russell and Christopher John Kline. */ -package com.sun.opengl.util.awt.gl2; +package com.sun.opengl.util.awt; import java.awt.Color; import java.awt.Dimension; @@ -52,9 +52,6 @@ import javax.media.opengl.glu.gl2.*; import com.sun.opengl.util.texture.*; import com.sun.opengl.util.texture.spi.*; import com.sun.opengl.util.texture.awt.*; -import com.sun.opengl.util.gl2.*; -import com.sun.opengl.util.awt.*; -import com.sun.opengl.util.awt.gl2.*; /** Provides the ability to render into an OpenGL {@link com.sun.opengl.util.texture.Texture Texture} using the Java 2D @@ -63,7 +60,7 @@ import com.sun.opengl.util.awt.gl2.*; that image to an OpenGL texture on demand. The resulting OpenGL texture can then be mapped on to a polygon for display. */ -public class GL2TextureRenderer { +public class TextureRenderer { // For now, we supply only a BufferedImage back-end for this // renderer. In theory we could use the Java 2D/JOGL bridge to fully // accelerate the rendering paths, but there are restrictions on @@ -112,7 +109,7 @@ public class GL2TextureRenderer { @param height the height of the texture to render into @param alpha whether to allocate an alpha channel for the texture */ - public GL2TextureRenderer(int width, int height, boolean alpha) { + public TextureRenderer(int width, int height, boolean alpha) { this(width, height, alpha, false); } @@ -127,13 +124,13 @@ public class GL2TextureRenderer { @param alpha whether to allocate an alpha channel for the texture @param mipmap whether to attempt use of automatic mipmap generation */ - public GL2TextureRenderer(int width, int height, boolean alpha, boolean mipmap) { + public TextureRenderer(int width, int height, boolean alpha, boolean mipmap) { this(width, height, alpha, false, mipmap); } // Internal constructor to avoid confusion since alpha only makes // sense when intensity is not set - private GL2TextureRenderer(int width, int height, boolean alpha, boolean intensity, boolean mipmap) { + private TextureRenderer(int width, int height, boolean alpha, boolean intensity, boolean mipmap) { this.alpha = alpha; this.intensity = intensity; this.mipmap = mipmap; @@ -144,7 +141,7 @@ public class GL2TextureRenderer { which acts only as an alpha channel. No mipmap support is requested. Internally, this associates a GL_INTENSITY OpenGL texture with the backing store. */ - public static GL2TextureRenderer createAlphaOnlyRenderer(int width, int height) { + public static TextureRenderer createAlphaOnlyRenderer(int width, int height) { return createAlphaOnlyRenderer(width, height, false); } @@ -154,8 +151,8 @@ public class GL2TextureRenderer { better smoothing when rendering the TextureRenderer's contents at a distance. Internally, this associates a GL_INTENSITY OpenGL texture with the backing store. */ - public static GL2TextureRenderer createAlphaOnlyRenderer(int width, int height, boolean mipmap) { - return new GL2TextureRenderer(width, height, false, true, mipmap); + public static TextureRenderer createAlphaOnlyRenderer(int width, int height, boolean mipmap) { + return new TextureRenderer(width, height, false, true, mipmap); } /** Returns the width of the backing store of this renderer. |