aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun/opengl/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/util')
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/Animator.java15
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp51
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase55
-rw-r--r--src/jogl/classes/com/sun/opengl/util/texture/spi/NetPbmTextureWriter.java24
4 files changed, 88 insertions, 57 deletions
diff --git a/src/jogl/classes/com/sun/opengl/util/Animator.java b/src/jogl/classes/com/sun/opengl/util/Animator.java
index a10717881..1d4b832e8 100755
--- a/src/jogl/classes/com/sun/opengl/util/Animator.java
+++ b/src/jogl/classes/com/sun/opengl/util/Animator.java
@@ -43,6 +43,8 @@ import java.util.*;
import javax.media.opengl.*;
+import com.sun.opengl.impl.Debug;
+
/** <P> An Animator can be attached to one or more {@link
GLAutoDrawable}s to drive their display() methods in a loop. </P>
@@ -53,7 +55,7 @@ import javax.media.opengl.*;
*/
public class Animator {
- protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("Animator");
+ protected static final boolean DEBUG = Debug.debug("Animator");
private volatile ArrayList/*<GLAutoDrawable>*/ drawables = new ArrayList();
private AnimatorImpl impl;
@@ -67,10 +69,13 @@ public class Animator {
/** Creates a new, empty Animator. */
public Animator(ThreadGroup tg) {
- try {
- // Try to use the AWT-capable Animator implementation by default
- impl = (AnimatorImpl) Class.forName("com.sun.opengl.util.awt.AWTAnimatorImpl").newInstance();
- } catch (Exception e) {
+
+ if(GLProfile.isAWTJOGLAvailable()) {
+ try {
+ impl = (AnimatorImpl) Class.forName("com.sun.opengl.util.awt.AWTAnimatorImpl").newInstance();
+ } catch (Exception e) { }
+ }
+ if(null==impl) {
impl = new AnimatorImpl();
}
threadGroup = tg;
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp
index 1f6b89c7e..e7c80678f 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp
+++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp
@@ -640,6 +640,10 @@ public class TextureIO {
}
}
+ write(data, file);
+ }
+
+ public static void write(TextureData data, File file) throws IOException, GLException {
for (Iterator iter = textureWriters.iterator(); iter.hasNext(); ) {
TextureWriter writer = (TextureWriter) iter.next();
if (writer.write(file, data)) {
@@ -647,9 +651,9 @@ public class TextureIO {
}
}
- throw new IOException("No suitable texture writer found");
+ throw new IOException("No suitable texture writer found for "+file.getAbsolutePath());
}
-
+
//----------------------------------------------------------------------
// SPI support
//
@@ -710,15 +714,17 @@ public class TextureIO {
static {
/*
- // ImageIO provider, the fall-back, must be the first one added
- try {
- // Use reflection to avoid compile-time dependencies on AWT-related classes
- TextureProvider provider = (TextureProvider)
- Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureProvider").newInstance();
- addTextureProvider(provider);
- } catch (Exception e) {
- if (DEBUG) {
- e.printStackTrace();
+ if(GLProfile.isAWTJOGLAvailable()) {
+ // ImageIO provider, the fall-back, must be the first one added
+ try {
+ // Use reflection to avoid compile-time dependencies on AWT-related classes
+ TextureProvider provider = (TextureProvider)
+ Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureProvider").newInstance();
+ addTextureProvider(provider);
+ } catch (Exception e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
}
}
*/
@@ -730,14 +736,16 @@ public class TextureIO {
/*
// ImageIO writer, the fall-back, must be the first one added
- try {
- // Use reflection to avoid compile-time dependencies on AWT-related classes
- TextureWriter writer = (TextureWriter)
- Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureWriter").newInstance();
- addTextureWriter(writer);
- } catch (Exception e) {
- if (DEBUG) {
- e.printStackTrace();
+ if(GLProfile.isAWTJOGLAvailable()) {
+ try {
+ // Use reflection to avoid compile-time dependencies on AWT-related classes
+ TextureWriter writer = (TextureWriter)
+ Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureWriter").newInstance();
+ addTextureWriter(writer);
+ } catch (Exception e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
}
}
*/
@@ -746,6 +754,7 @@ public class TextureIO {
addTextureWriter(new DDSTextureWriter());
addTextureWriter(new SGITextureWriter());
addTextureWriter(new TGATextureWriter());
+ addTextureWriter(new NetPbmTextureWriter());
}
// Implementation methods
@@ -772,7 +781,7 @@ public class TextureIO {
}
}
- throw new IOException("No suitable reader for given file");
+ throw new IOException("No suitable reader for given file "+file.getAbsolutePath());
}
private static TextureData newTextureDataImpl(InputStream stream,
@@ -829,7 +838,7 @@ public class TextureIO {
}
}
- throw new IOException("No suitable reader for given URL");
+ throw new IOException("No suitable reader for given URL "+url);
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase
index 2b2f123a0..556d51343 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase
+++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase
@@ -640,6 +640,10 @@ public class TextureIO {
}
}
+ write(data, file);
+ }
+
+ public static void write(TextureData data, File file) throws IOException, GLException {
for (Iterator iter = textureWriters.iterator(); iter.hasNext(); ) {
TextureWriter writer = (TextureWriter) iter.next();
if (writer.write(file, data)) {
@@ -647,7 +651,7 @@ public class TextureIO {
}
}
- throw new IOException("No suitable texture writer found");
+ throw new IOException("No suitable texture writer found for "+file.getAbsolutePath());
}
//----------------------------------------------------------------------
@@ -710,14 +714,16 @@ public class TextureIO {
static {
// ImageIO provider, the fall-back, must be the first one added
- try {
- // Use reflection to avoid compile-time dependencies on AWT-related classes
- TextureProvider provider = (TextureProvider)
- Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureProvider").newInstance();
- addTextureProvider(provider);
- } catch (Exception e) {
- if (DEBUG) {
- e.printStackTrace();
+ if(GLProfile.isAWTJOGLAvailable()) {
+ try {
+ // Use reflection to avoid compile-time dependencies on AWT-related classes
+ TextureProvider provider = (TextureProvider)
+ Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureProvider").newInstance();
+ addTextureProvider(provider);
+ } catch (Exception e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
}
}
@@ -727,18 +733,20 @@ public class TextureIO {
addTextureProvider(new TGATextureProvider());
// ImageIO writer, the fall-back, must be the first one added
- try {
- // Use reflection to avoid compile-time dependencies on AWT-related classes
- TextureWriter writer = (TextureWriter)
- Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureWriter").newInstance();
- addTextureWriter(writer);
- } catch (Exception e) {
- if (DEBUG) {
- e.printStackTrace();
- }
- } catch (Error e) {
- if (DEBUG) {
- e.printStackTrace();
+ if(GLProfile.isAWTJOGLAvailable()) {
+ try {
+ // Use reflection to avoid compile-time dependencies on AWT-related classes
+ TextureWriter writer = (TextureWriter)
+ Class.forName("com.sun.opengl.util.texture.spi.awt.IIOTextureWriter").newInstance();
+ addTextureWriter(writer);
+ } catch (Exception e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
+ } catch (Error e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
}
}
@@ -746,6 +754,7 @@ public class TextureIO {
addTextureWriter(new DDSTextureWriter());
addTextureWriter(new SGITextureWriter());
addTextureWriter(new TGATextureWriter());
+ addTextureWriter(new NetPbmTextureWriter());
}
// Implementation methods
@@ -772,7 +781,7 @@ public class TextureIO {
}
}
- throw new IOException("No suitable reader for given file");
+ throw new IOException("No suitable reader for given file "+file.getAbsolutePath());
}
private static TextureData newTextureDataImpl(InputStream stream,
@@ -829,7 +838,7 @@ public class TextureIO {
}
}
- throw new IOException("No suitable reader for given URL");
+ throw new IOException("No suitable reader for given URL "+url);
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/spi/NetPbmTextureWriter.java b/src/jogl/classes/com/sun/opengl/util/texture/spi/NetPbmTextureWriter.java
index f771e0a3d..18df1dc55 100644
--- a/src/jogl/classes/com/sun/opengl/util/texture/spi/NetPbmTextureWriter.java
+++ b/src/jogl/classes/com/sun/opengl/util/texture/spi/NetPbmTextureWriter.java
@@ -58,7 +58,7 @@ public class NetPbmTextureWriter implements TextureWriter {
/**
* supported magic values are:<br>
* <pre>
- * magic 0 - auto
+ * magic 0 - detect by file suffix (TextureIO compliant)
* magic 6 - PPM binary RGB
* magic 7 - PAM binary RGB or RGBA
* </pre>
@@ -77,13 +77,25 @@ public class NetPbmTextureWriter implements TextureWriter {
public int getMagic() { return magic; }
- public static String getPPMSuffix() { return "ppm"; }
- public static String getPAMSuffix() { return "pam"; }
+ public static final String PPM = "ppm";
+ public static final String PAM = "pam";
- public String getSuffix() { return (magic==6)?getPPMSuffix():getPAMSuffix(); }
+ public String getSuffix() { return (magic==6)?PPM:PAM; }
public boolean write(File file,
TextureData data) throws IOException {
+
+ // file suffix selection
+ if (0==magic) {
+ if (PPM.equals(FileUtil.getFileSuffix(file))) {
+ magic = 6;
+ } else if (PAM.equals(FileUtil.getFileSuffix(file))) {
+ magic = 7;
+ } else {
+ return false;
+ }
+ }
+
int pixelFormat = data.getPixelFormat();
int pixelType = data.getPixelType();
if ((pixelFormat == GL.GL_RGB ||
@@ -93,10 +105,6 @@ public class NetPbmTextureWriter implements TextureWriter {
int comps = ( pixelFormat == GL.GL_RGBA ) ? 4 : 3 ;
- if(0==magic) {
- magic = ( comps == 4 ) ? 7 : 6 ;
- }
-
if(magic==6 && comps==4) {
throw new IOException("NetPbmTextureWriter magic 6 (PPM) doesn't RGBA pixel format, use magic 7 (PAM)");
}