diff options
Diffstat (limited to 'src')
8 files changed, 194 insertions, 175 deletions
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java b/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java index 81124b060..7899a2395 100755 --- a/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java @@ -49,6 +49,7 @@ import com.sun.opengl.util.*; * * @author Chris Campbell * @author Kenneth Russell + * @author Sven Gothel */ public class TextureData { @@ -71,13 +72,10 @@ public class TextureData { protected int alignment; // 1, 2, or 4 bytes protected int estimatedMemorySize; - // specialization of this class might need GL dependent post initialization - protected Object glPostInitSync = new Object(); - protected volatile boolean glPostInitDone = false; - // These booleans are a concession to the AWTTextureData subclass protected boolean haveEXTABGR; protected boolean haveGL12; + protected GLProfile glProfile; /** * Constructs a new TextureData object with the specified parameters @@ -87,6 +85,8 @@ public class TextureData { * memory-mapped files that might otherwise require a garbage * collection to reclaim and close. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param internalFormat the OpenGL internal format for the * resulting texture; must be specified, may * not be 0 @@ -117,7 +117,8 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(int internalFormat, + public TextureData(GLProfile glp, + int internalFormat, int width, int height, int border, @@ -132,6 +133,7 @@ public class TextureData { throw new IllegalArgumentException("Can not generate mipmaps for compressed textures"); } + this.glProfile = glp; this.width = width; this.height = height; this.border = border; @@ -155,6 +157,8 @@ public class TextureData { * complete; for example, closing of memory-mapped files that might * otherwise require a garbage collection to reclaim and close. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param internalFormat the OpenGL internal format for the * resulting texture; must be specified, may * not be 0 @@ -184,7 +188,8 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(int internalFormat, + public TextureData(GLProfile glp, + int internalFormat, int width, int height, int border, @@ -194,6 +199,7 @@ public class TextureData { boolean mustFlipVertically, Buffer[] mipmapData, Flusher flusher) throws IllegalArgumentException { + this.glProfile = glp; this.width = width; this.height = height; this.border = border; @@ -211,7 +217,7 @@ public class TextureData { } /** Used only by subclasses */ - protected TextureData() { } + protected TextureData(GLProfile glp) { this.glProfile = glp; } /** Returns the width in pixels of the texture data. */ public int getWidth() { return width; } @@ -219,61 +225,50 @@ public class TextureData { public int getHeight() { return height; } /** Returns the border in pixels of the texture data. */ public int getBorder() { - glPostInitInt(); return border; } /** Returns the intended OpenGL pixel format of the texture data. */ public int getPixelFormat() { - glPostInitInt(); return pixelFormat; } /** Returns the intended OpenGL pixel type of the texture data. */ public int getPixelType() { - glPostInitInt(); return pixelType; } /** Returns the intended OpenGL internal format of the texture data. */ public int getInternalFormat() { - glPostInitInt(); return internalFormat; } /** Returns whether mipmaps should be generated for the texture data. */ public boolean getMipmap() { - glPostInitInt(); return mipmap; } /** Indicates whether the texture data is in compressed form. */ public boolean isDataCompressed() { - glPostInitInt(); return dataIsCompressed; } /** Indicates whether the texture coordinates must be flipped vertically for proper display. */ public boolean getMustFlipVertically() { - glPostInitInt(); return mustFlipVertically; } /** Returns the texture data, or null if it is specified as a set of mipmaps. */ public Buffer getBuffer() { - glPostInitInt(); return buffer; } /** Returns all mipmap levels for the texture data, or null if it is specified as a single image. */ public Buffer[] getMipmapData() { - glPostInitInt(); return mipmapData; } /** Returns the required byte alignment for the texture data. */ public int getAlignment() { - glPostInitInt(); return alignment; } /** Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures. */ public int getRowLength() { - glPostInitInt(); return rowLength; } @@ -321,6 +316,9 @@ public class TextureData { this.haveGL12 = haveGL12; } + /** Returns the GLProfile this texture data is intended and created for. */ + public GLProfile getGLProfile() { return glProfile; } + /** Returns an estimate of the amount of memory in bytes this TextureData will consume once uploaded to the graphics card. It should only be treated as an estimate; most applications should @@ -333,7 +331,6 @@ public class TextureData { /** Flushes resources associated with this TextureData by calling Flusher.flush(). */ public void flush() { - glPostInitInt(); if (flusher != null) { flusher.flush(); flusher = null; @@ -364,19 +361,6 @@ public class TextureData { // Internals only below this point // - protected void glPostInit() { } - - protected final void glPostInitInt() { - if(glPostInitDone) return; - synchronized(glPostInitSync) { - if(!glPostInitDone) { - glPostInit(); - glPostInitDone = true; - } - glPostInitSync.notifyAll(); - } - } - protected static int estimatedMemorySize(Buffer buffer) { if (buffer == null) { return 0; 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 e7c80678f..5c64806fc 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 @@ -155,6 +155,8 @@ public class TextureIO { /** * Creates a TextureData from the given file. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param file the file from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture either by autogenerating them or @@ -171,18 +173,20 @@ public class TextureIO { * registered texture providers could read the file * @throws IOException if an error occurred while reading the file */ - public static TextureData newTextureData(File file, + public static TextureData newTextureData(GLProfile glp, File file, boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { fileSuffix = FileUtil.getFileSuffix(file); } - return newTextureDataImpl(file, 0, 0, mipmap, fileSuffix); + return newTextureDataImpl(glp, file, 0, 0, mipmap, fileSuffix); } /** * Creates a TextureData from the given stream. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param stream the stream from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture either by autogenerating them or @@ -199,15 +203,17 @@ public class TextureIO { * registered texture providers could read the stream * @throws IOException if an error occurred while reading the stream */ - public static TextureData newTextureData(InputStream stream, + public static TextureData newTextureData(GLProfile glp, InputStream stream, boolean mipmap, String fileSuffix) throws IOException { - return newTextureDataImpl(stream, 0, 0, mipmap, fileSuffix); + return newTextureDataImpl(glp, stream, 0, 0, mipmap, fileSuffix); } /** * Creates a TextureData from the given URL. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param url the URL from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture either by autogenerating them or @@ -224,13 +230,13 @@ public class TextureIO { * registered texture providers could read the URL * @throws IOException if an error occurred while reading the URL */ - public static TextureData newTextureData(URL url, + public static TextureData newTextureData(GLProfile glp, URL url, boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { fileSuffix = FileUtil.getFileSuffix(url.getPath()); } - return newTextureDataImpl(url, 0, 0, mipmap, fileSuffix); + return newTextureDataImpl(glp, url, 0, 0, mipmap, fileSuffix); } //---------------------------------------------------------------------- @@ -248,6 +254,8 @@ public class TextureIO { * variant of this method which does not take these arguments. Does * no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param file the file from which to read the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -270,7 +278,7 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the file */ - public static TextureData newTextureData(File file, + public static TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -283,7 +291,7 @@ public class TextureIO { fileSuffix = FileUtil.getFileSuffix(file); } - return newTextureDataImpl(file, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureDataImpl(glp, file, internalFormat, pixelFormat, mipmap, fileSuffix); } /** @@ -294,6 +302,8 @@ public class TextureIO { * variant of this method which does not take these arguments. Does * no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param stream the stream from which to read the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -316,7 +326,7 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the stream */ - public static TextureData newTextureData(InputStream stream, + public static TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -325,7 +335,7 @@ public class TextureIO { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); } - return newTextureDataImpl(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureDataImpl(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } /** @@ -336,6 +346,8 @@ public class TextureIO { * variant of this method which does not take these arguments. Does * no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param url the URL from which to read the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -358,7 +370,7 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the URL */ - public static TextureData newTextureData(URL url, + public static TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, @@ -371,7 +383,7 @@ public class TextureIO { fileSuffix = FileUtil.getFileSuffix(url.getPath()); } - return newTextureDataImpl(url, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureDataImpl(glp, url, internalFormat, pixelFormat, mipmap, fileSuffix); } //---------------------------------------------------------------------- @@ -410,7 +422,8 @@ public class TextureIO { * OpenGL error occurred */ public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException { - TextureData data = newTextureData(file, mipmap, FileUtil.getFileSuffix(file)); + GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + TextureData data = newTextureData(glp, file, mipmap, FileUtil.getFileSuffix(file)); Texture texture = newTexture(data); data.flush(); return texture; @@ -437,7 +450,8 @@ public class TextureIO { * OpenGL error occurred */ public static Texture newTexture(InputStream stream, boolean mipmap, String fileSuffix) throws IOException, GLException { - TextureData data = newTextureData(stream, mipmap, fileSuffix); + GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + TextureData data = newTextureData(glp, stream, mipmap, fileSuffix); Texture texture = newTexture(data); data.flush(); return texture; @@ -467,7 +481,8 @@ public class TextureIO { if (fileSuffix == null) { fileSuffix = FileUtil.getFileSuffix(url.getPath()); } - TextureData data = newTextureData(url, mipmap, fileSuffix); + GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + TextureData data = newTextureData(glp, url, mipmap, fileSuffix); Texture texture = newTexture(data); data.flush(); return texture; @@ -580,7 +595,7 @@ public class TextureIO { int size = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_COMPRESSED_IMAGE_SIZE); ByteBuffer res = ByteBuffer.wrap(new byte[size]); gl.glGetCompressedTexImage(GL.GL_TEXTURE_2D, 0, res); - data = new TextureData(internalFormat, width, height, border, internalFormat, GL.GL_UNSIGNED_BYTE, + data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, internalFormat, GL.GL_UNSIGNED_BYTE, false, true, true, res, null); } else { int bytesPerPixel = 0; @@ -631,7 +646,7 @@ public class TextureIO { gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, packSkipPixels); gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, packSwapBytes); - data = new TextureData(internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, + data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, false, false, false, res, null); if (DEBUG) { @@ -758,7 +773,7 @@ public class TextureIO { } // Implementation methods - private static TextureData newTextureDataImpl(File file, + private static TextureData newTextureDataImpl(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -771,7 +786,7 @@ public class TextureIO { for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(file, + TextureData data = provider.newTextureData(glp, file, internalFormat, pixelFormat, mipmap, @@ -784,7 +799,7 @@ public class TextureIO { throw new IOException("No suitable reader for given file "+file.getAbsolutePath()); } - private static TextureData newTextureDataImpl(InputStream stream, + private static TextureData newTextureDataImpl(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -802,7 +817,7 @@ public class TextureIO { for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(stream, + TextureData data = provider.newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, @@ -815,7 +830,7 @@ public class TextureIO { throw new IOException("No suitable reader for given stream"); } - private static TextureData newTextureDataImpl(URL url, + private static TextureData newTextureDataImpl(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, @@ -828,7 +843,7 @@ public class TextureIO { for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(url, + TextureData data = provider.newTextureData(glp, url, internalFormat, pixelFormat, mipmap, @@ -844,7 +859,7 @@ public class TextureIO { //---------------------------------------------------------------------- // DDS provider -- supports files only for now static class DDSTextureProvider implements TextureProvider { - public TextureData newTextureData(File file, + public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -852,13 +867,13 @@ public class TextureIO { if (DDS.equals(fileSuffix) || DDS.equals(FileUtil.getFileSuffix(file))) { DDSImage image = DDSImage.read(file); - return newTextureData(image, internalFormat, pixelFormat, mipmap); + return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } return null; } - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -866,26 +881,26 @@ public class TextureIO { if (DDS.equals(fileSuffix) || DDSImage.isDDSImage(stream)) { DDSImage image = DDSImage.read(stream); - return newTextureData(image, internalFormat, pixelFormat, mipmap); + return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } return null; } - public TextureData newTextureData(URL url, + public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix) throws IOException { InputStream stream = new BufferedInputStream(url.openStream()); try { - return newTextureData(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { stream.close(); } } - private TextureData newTextureData(final DDSImage image, + private TextureData newTextureData(GLProfile glp, final DDSImage image, int internalFormat, int pixelFormat, boolean mipmap) { @@ -937,7 +952,7 @@ public class TextureIO { for (int i = 0; i < image.getNumMipMaps(); i++) { mipmapData[i] = image.getMipMap(i).getData(); } - data = new TextureData(internalFormat, + data = new TextureData(glp, internalFormat, info.getWidth(), info.getHeight(), 0, @@ -951,7 +966,7 @@ public class TextureIO { // Fix this up for the end user because we can't generate // mipmaps for compressed textures mipmap = false; - data = new TextureData(internalFormat, + data = new TextureData(glp, internalFormat, info.getWidth(), info.getHeight(), 0, @@ -970,7 +985,7 @@ public class TextureIO { //---------------------------------------------------------------------- // Base class for SGI RGB and TGA image providers static abstract class StreamBasedTextureProvider implements TextureProvider { - public TextureData newTextureData(File file, + public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -980,7 +995,7 @@ public class TextureIO { // The SGIImage and TGAImage implementations use InputStreams // anyway so there isn't much point in having a separate code // path for files - return newTextureData(inStream, + return newTextureData(glp, inStream, internalFormat, pixelFormat, mipmap, @@ -990,14 +1005,14 @@ public class TextureIO { } } - public TextureData newTextureData(URL url, + public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix) throws IOException { InputStream stream = new BufferedInputStream(url.openStream()); try { - return newTextureData(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { stream.close(); } @@ -1007,7 +1022,7 @@ public class TextureIO { //---------------------------------------------------------------------- // SGI RGB image provider static class SGITextureProvider extends StreamBasedTextureProvider { - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -1022,7 +1037,7 @@ public class TextureIO { if (internalFormat == 0) { internalFormat = image.getFormat(); } - return new TextureData(internalFormat, + return new TextureData(glp, internalFormat, image.getWidth(), image.getHeight(), 0, @@ -1042,7 +1057,7 @@ public class TextureIO { //---------------------------------------------------------------------- // TGA (Targa) image provider static class TGATextureProvider extends StreamBasedTextureProvider { - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -1060,7 +1075,7 @@ public class TextureIO { internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; } } - return new TextureData(internalFormat, + return new TextureData(glp, internalFormat, image.getWidth(), image.getHeight(), 0, 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 556d51343..034a850bd 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 @@ -155,6 +155,8 @@ public class TextureIO { /** * Creates a TextureData from the given file. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param file the file from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture either by autogenerating them or @@ -171,18 +173,20 @@ public class TextureIO { * registered texture providers could read the file * @throws IOException if an error occurred while reading the file */ - public static TextureData newTextureData(File file, + public static TextureData newTextureData(GLProfile glp, File file, boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { fileSuffix = FileUtil.getFileSuffix(file); } - return newTextureDataImpl(file, 0, 0, mipmap, fileSuffix); + return newTextureDataImpl(glp, file, 0, 0, mipmap, fileSuffix); } /** * Creates a TextureData from the given stream. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param stream the stream from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture either by autogenerating them or @@ -199,15 +203,17 @@ public class TextureIO { * registered texture providers could read the stream * @throws IOException if an error occurred while reading the stream */ - public static TextureData newTextureData(InputStream stream, + public static TextureData newTextureData(GLProfile glp, InputStream stream, boolean mipmap, String fileSuffix) throws IOException { - return newTextureDataImpl(stream, 0, 0, mipmap, fileSuffix); + return newTextureDataImpl(glp, stream, 0, 0, mipmap, fileSuffix); } /** * Creates a TextureData from the given URL. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param url the URL from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture either by autogenerating them or @@ -224,13 +230,13 @@ public class TextureIO { * registered texture providers could read the URL * @throws IOException if an error occurred while reading the URL */ - public static TextureData newTextureData(URL url, + public static TextureData newTextureData(GLProfile glp, URL url, boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { fileSuffix = FileUtil.getFileSuffix(url.getPath()); } - return newTextureDataImpl(url, 0, 0, mipmap, fileSuffix); + return newTextureDataImpl(glp, url, 0, 0, mipmap, fileSuffix); } //---------------------------------------------------------------------- @@ -248,6 +254,8 @@ public class TextureIO { * variant of this method which does not take these arguments. Does * no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param file the file from which to read the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -270,7 +278,7 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the file */ - public static TextureData newTextureData(File file, + public static TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -283,7 +291,7 @@ public class TextureIO { fileSuffix = FileUtil.getFileSuffix(file); } - return newTextureDataImpl(file, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureDataImpl(glp, file, internalFormat, pixelFormat, mipmap, fileSuffix); } /** @@ -294,6 +302,8 @@ public class TextureIO { * variant of this method which does not take these arguments. Does * no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param stream the stream from which to read the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -316,7 +326,7 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the stream */ - public static TextureData newTextureData(InputStream stream, + public static TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -325,7 +335,7 @@ public class TextureIO { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); } - return newTextureDataImpl(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureDataImpl(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } /** @@ -336,6 +346,8 @@ public class TextureIO { * variant of this method which does not take these arguments. Does * no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param url the URL from which to read the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -358,7 +370,7 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the URL */ - public static TextureData newTextureData(URL url, + public static TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, @@ -371,7 +383,7 @@ public class TextureIO { fileSuffix = FileUtil.getFileSuffix(url.getPath()); } - return newTextureDataImpl(url, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureDataImpl(glp, url, internalFormat, pixelFormat, mipmap, fileSuffix); } //---------------------------------------------------------------------- @@ -410,7 +422,8 @@ public class TextureIO { * OpenGL error occurred */ public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException { - TextureData data = newTextureData(file, mipmap, FileUtil.getFileSuffix(file)); + GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + TextureData data = newTextureData(glp, file, mipmap, FileUtil.getFileSuffix(file)); Texture texture = newTexture(data); data.flush(); return texture; @@ -437,7 +450,8 @@ public class TextureIO { * OpenGL error occurred */ public static Texture newTexture(InputStream stream, boolean mipmap, String fileSuffix) throws IOException, GLException { - TextureData data = newTextureData(stream, mipmap, fileSuffix); + GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + TextureData data = newTextureData(glp, stream, mipmap, fileSuffix); Texture texture = newTexture(data); data.flush(); return texture; @@ -467,7 +481,8 @@ public class TextureIO { if (fileSuffix == null) { fileSuffix = FileUtil.getFileSuffix(url.getPath()); } - TextureData data = newTextureData(url, mipmap, fileSuffix); + GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + TextureData data = newTextureData(glp, url, mipmap, fileSuffix); Texture texture = newTexture(data); data.flush(); return texture; @@ -580,7 +595,7 @@ public class TextureIO { int size = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_COMPRESSED_IMAGE_SIZE); ByteBuffer res = ByteBuffer.allocate(size); gl.glGetCompressedTexImage(GL.GL_TEXTURE_2D, 0, res); - data = new TextureData(internalFormat, width, height, border, internalFormat, GL.GL_UNSIGNED_BYTE, + data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, internalFormat, GL.GL_UNSIGNED_BYTE, false, true, true, res, null); } else { int bytesPerPixel = 0; @@ -631,7 +646,7 @@ public class TextureIO { gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, packSkipPixels); gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, packSwapBytes); - data = new TextureData(internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, + data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, false, false, false, res, null); if (DEBUG) { @@ -758,7 +773,7 @@ public class TextureIO { } // Implementation methods - private static TextureData newTextureDataImpl(File file, + private static TextureData newTextureDataImpl(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -771,7 +786,7 @@ public class TextureIO { for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(file, + TextureData data = provider.newTextureData(glp, file, internalFormat, pixelFormat, mipmap, @@ -784,7 +799,7 @@ public class TextureIO { throw new IOException("No suitable reader for given file "+file.getAbsolutePath()); } - private static TextureData newTextureDataImpl(InputStream stream, + private static TextureData newTextureDataImpl(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -802,7 +817,7 @@ public class TextureIO { for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(stream, + TextureData data = provider.newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, @@ -815,7 +830,7 @@ public class TextureIO { throw new IOException("No suitable reader for given stream"); } - private static TextureData newTextureDataImpl(URL url, + private static TextureData newTextureDataImpl(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, @@ -828,7 +843,7 @@ public class TextureIO { for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(url, + TextureData data = provider.newTextureData(glp, url, internalFormat, pixelFormat, mipmap, @@ -844,7 +859,7 @@ public class TextureIO { //---------------------------------------------------------------------- // DDS provider -- supports files only for now static class DDSTextureProvider implements TextureProvider { - public TextureData newTextureData(File file, + public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -852,13 +867,13 @@ public class TextureIO { if (DDS.equals(fileSuffix) || DDS.equals(FileUtil.getFileSuffix(file))) { DDSImage image = DDSImage.read(file); - return newTextureData(image, internalFormat, pixelFormat, mipmap); + return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } return null; } - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -868,26 +883,26 @@ public class TextureIO { byte[] data = StreamUtil.readAll2Array(stream); ByteBuffer buf = ByteBuffer.wrap(data); DDSImage image = DDSImage.read(buf); - return newTextureData(image, internalFormat, pixelFormat, mipmap); + return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } return null; } - public TextureData newTextureData(URL url, + public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix) throws IOException { InputStream stream = new BufferedInputStream(url.openStream()); try { - return newTextureData(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { stream.close(); } } - private TextureData newTextureData(final DDSImage image, + private TextureData newTextureData(GLProfile glp, final DDSImage image, int internalFormat, int pixelFormat, boolean mipmap) { @@ -939,7 +954,7 @@ public class TextureIO { for (int i = 0; i < image.getNumMipMaps(); i++) { mipmapData[i] = image.getMipMap(i).getData(); } - data = new TextureData(internalFormat, + data = new TextureData(glp, internalFormat, info.getWidth(), info.getHeight(), 0, @@ -953,7 +968,7 @@ public class TextureIO { // Fix this up for the end user because we can't generate // mipmaps for compressed textures mipmap = false; - data = new TextureData(internalFormat, + data = new TextureData(glp, internalFormat, info.getWidth(), info.getHeight(), 0, @@ -972,7 +987,7 @@ public class TextureIO { //---------------------------------------------------------------------- // Base class for SGI RGB and TGA image providers static abstract class StreamBasedTextureProvider implements TextureProvider { - public TextureData newTextureData(File file, + public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -982,7 +997,7 @@ public class TextureIO { // The SGIImage and TGAImage implementations use InputStreams // anyway so there isn't much point in having a separate code // path for files - return newTextureData(inStream, + return newTextureData(glp, inStream, internalFormat, pixelFormat, mipmap, @@ -992,14 +1007,14 @@ public class TextureIO { } } - public TextureData newTextureData(URL url, + public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix) throws IOException { InputStream stream = new BufferedInputStream(url.openStream()); try { - return newTextureData(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { stream.close(); } @@ -1009,7 +1024,7 @@ public class TextureIO { //---------------------------------------------------------------------- // SGI RGB image provider static class SGITextureProvider extends StreamBasedTextureProvider { - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -1024,7 +1039,7 @@ public class TextureIO { if (internalFormat == 0) { internalFormat = image.getFormat(); } - return new TextureData(internalFormat, + return new TextureData(glp, internalFormat, image.getWidth(), image.getHeight(), 0, @@ -1044,7 +1059,7 @@ public class TextureIO { //---------------------------------------------------------------------- // TGA (Targa) image provider static class TGATextureProvider extends StreamBasedTextureProvider { - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -1062,7 +1077,7 @@ public class TextureIO { internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; } } - return new TextureData(internalFormat, + return new TextureData(glp, internalFormat, image.getWidth(), image.getHeight(), 0, diff --git a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java index e949883ed..f98feb8e9 100755 --- a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java @@ -56,9 +56,6 @@ public class AWTTextureData extends TextureData { private boolean expectingEXTABGR; private boolean expectingGL12; - private int scanlineStride; - private BufferedImage glDependingImage; // indicator wheather GL depening initialization has been passed - private static final ColorModel rgbaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] {8, 8, 8, 8}, true, true, @@ -80,6 +77,8 @@ public class AWTTextureData extends TextureData { * TextureData, that modification will be visible in the resulting * Texture. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param internalFormat the OpenGL internal format for the * resulting texture; may be 0, in which case * it is inferred from the image's type @@ -92,24 +91,31 @@ public class AWTTextureData extends TextureData { * texture * @param image the image containing the texture data */ - public AWTTextureData(int internalFormat, + public AWTTextureData(GLProfile glp, + int internalFormat, int pixelFormat, boolean mipmap, BufferedImage image) { - super(); + super(glp); if (internalFormat == 0) { this.internalFormat = image.getColorModel().hasAlpha() ? GL.GL_RGBA : GL.GL_RGB; } else { this.internalFormat = internalFormat; } - createFromImagePre(image); - + createFromImage(glp, image); this.mipmap = mipmap; + if (buffer != null) { + estimatedMemorySize = estimatedMemorySize(buffer); + } else { + // In the lazy custom conversion case we don't yet have a buffer + if (imageForLazyCustomConversion != null) { + estimatedMemorySize = estimatedMemorySize(wrapImageDataBuffer(imageForLazyCustomConversion)); + } + } } /** Returns the intended OpenGL pixel format of the texture data. */ public int getPixelFormat() { - glPostInitInt(); if (imageForLazyCustomConversion != null) { if (!((expectingEXTABGR && haveEXTABGR) || (expectingGL12 && haveGL12))) { @@ -120,7 +126,6 @@ public class AWTTextureData extends TextureData { } /** Returns the intended OpenGL pixel type of the texture data. */ public int getPixelType() { - glPostInitInt(); if (imageForLazyCustomConversion != null) { if (!((expectingEXTABGR && haveEXTABGR) || (expectingGL12 && haveGL12))) { @@ -132,7 +137,6 @@ public class AWTTextureData extends TextureData { /** Returns the texture data, or null if it is specified as a set of mipmaps. */ public Buffer getBuffer() { - glPostInitInt(); if (imageForLazyCustomConversion != null) { if (!((expectingEXTABGR && haveEXTABGR) || (expectingGL12 && haveGL12))) { @@ -145,13 +149,15 @@ public class AWTTextureData extends TextureData { return buffer; } - private void createFromImagePre(BufferedImage image) { + private void createFromImage(GLProfile glp, BufferedImage image) { pixelType = 0; // Determine from image mustFlipVertically = true; width = image.getWidth(); height = image.getHeight(); + int scanlineStride; + SampleModel sm = image.getRaster().getSampleModel(); if (sm instanceof SinglePixelPackedSampleModel) { scanlineStride = @@ -167,36 +173,23 @@ public class AWTTextureData extends TextureData { setupLazyCustomConversion(image); return; } - glDependingImage = image; // earmark for post init - } - - protected void glPostInit() { - if(null == glDependingImage) return; - - GLContext current = GLContext.getCurrent(); - if(null == current) return; - - BufferedImage image = glDependingImage; - glDependingImage = null; - - GLProfile glp = current.getGL().getGLProfile(); width = image.getWidth(); height = image.getHeight(); - if (glp.isGL2()) { + if (glp.isGL2GL3()) { switch (image.getType()) { case BufferedImage.TYPE_INT_RGB: - pixelFormat = GL2.GL_BGRA; - pixelType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; + pixelFormat = GL2GL3.GL_BGRA; + pixelType = GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV; rowLength = scanlineStride; alignment = 4; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_INT_ARGB_PRE: - pixelFormat = GL2.GL_BGRA; - pixelType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; + pixelFormat = GL2GL3.GL_BGRA; + pixelType = GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV; rowLength = scanlineStride; alignment = 4; expectingGL12 = true; @@ -204,7 +197,7 @@ public class AWTTextureData extends TextureData { break; case BufferedImage.TYPE_INT_BGR: pixelFormat = GL.GL_RGBA; - pixelType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; + pixelType = GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV; rowLength = scanlineStride; alignment = 4; expectingGL12 = true; @@ -215,7 +208,7 @@ public class AWTTextureData extends TextureData { // we can pass the image data directly to OpenGL only if // we have an integral number of pixels in each scanline if ((scanlineStride % 3) == 0) { - pixelFormat = GL2.GL_BGR; + pixelFormat = GL2GL3.GL_BGR; pixelType = GL.GL_UNSIGNED_BYTE; rowLength = scanlineStride / 3; alignment = 1; @@ -235,7 +228,7 @@ public class AWTTextureData extends TextureData { // buggy at least on some NVidia drivers and doesn't perform // the necessary byte swapping (FIXME: needs more // investigation) - if ((scanlineStride % 4) == 0 && false) { + if ((scanlineStride % 4) == 0 && glp.isGL2() && false) { pixelFormat = GL2.GL_ABGR_EXT; pixelType = GL.GL_UNSIGNED_BYTE; rowLength = scanlineStride / 4; @@ -261,8 +254,8 @@ public class AWTTextureData extends TextureData { setupLazyCustomConversion(image); break; case BufferedImage.TYPE_USHORT_555_RGB: - pixelFormat = GL2.GL_BGRA; - pixelType = GL2.GL_UNSIGNED_SHORT_1_5_5_5_REV; + pixelFormat = GL2GL3.GL_BGRA; + pixelType = GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV; rowLength = scanlineStride; alignment = 2; expectingGL12 = true; @@ -377,15 +370,6 @@ public class AWTTextureData extends TextureData { } createNIOBufferFromImage(image); - - if (buffer != null) { - estimatedMemorySize = estimatedMemorySize(buffer); - } else { - // In the lazy custom conversion case we don't yet have a buffer - if (imageForLazyCustomConversion != null) { - estimatedMemorySize = estimatedMemorySize(wrapImageDataBuffer(imageForLazyCustomConversion)); - } - } } private void setupLazyCustomConversion(BufferedImage image) { @@ -409,7 +393,7 @@ public class AWTTextureData extends TextureData { if (pixelType == 0) pixelType = GL.GL_FLOAT; } else if (data instanceof DataBufferInt) { // FIXME: should we support signed ints? - if (pixelType == 0) pixelType = GL2.GL_UNSIGNED_INT; + if (pixelType == 0) pixelType = GL2GL3.GL_UNSIGNED_INT; } else if (data instanceof DataBufferShort) { if (pixelType == 0) pixelType = GL.GL_SHORT; } else if (data instanceof DataBufferUShort) { diff --git a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureIO.java b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureIO.java index 490d150cc..182810174 100644 --- a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureIO.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureIO.java @@ -48,15 +48,20 @@ public class AWTTextureIO extends TextureIO { /** * Creates a TextureData from the given BufferedImage. Does no * OpenGL work. + * We assume a desktop GLProfile GL2GL3, otherwise use the other factory. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param image the BufferedImage containing the texture data * @param mipmap whether mipmaps should be produced for this * texture by autogenerating them * @return the texture data from the image + * + * @see #newTextureData(GLProfile, BufferedImage, boolean) */ - public static TextureData newTextureData(BufferedImage image, + public static TextureData newTextureData(GLProfile glp, BufferedImage image, boolean mipmap) { - return newTextureDataImpl(image, 0, 0, mipmap); + return newTextureDataImpl(glp, image, 0, 0, mipmap); } /** @@ -67,6 +72,8 @@ public class AWTTextureIO extends TextureIO { * the variant of this method which does not take these * arguments. Does no OpenGL work. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param image the BufferedImage containing the texture data * @param internalFormat the OpenGL internal format of the texture * which will eventually result from the TextureData @@ -82,7 +89,7 @@ public class AWTTextureIO extends TextureIO { * @throws IllegalArgumentException if either internalFormat or * pixelFormat was 0 */ - public static TextureData newTextureData(BufferedImage image, + public static TextureData newTextureData(GLProfile glp, BufferedImage image, int internalFormat, int pixelFormat, boolean mipmap) throws IllegalArgumentException { @@ -90,30 +97,33 @@ public class AWTTextureIO extends TextureIO { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); } - return newTextureDataImpl(image, internalFormat, pixelFormat, mipmap); + return newTextureDataImpl(glp, image, internalFormat, pixelFormat, mipmap); } /** * Creates an OpenGL texture object from the specified BufferedImage * using the current OpenGL context. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param image the BufferedImage from which to read the texture data * @param mipmap whether mipmaps should be produced for this * texture by autogenerating them * @throws GLException if no OpenGL context is current or if an * OpenGL error occurred */ - public static Texture newTexture(BufferedImage image, boolean mipmap) throws GLException { - TextureData data = newTextureData(image, mipmap); + public static Texture newTexture(GLProfile glp, BufferedImage image, boolean mipmap) throws GLException { + TextureData data = newTextureData(glp, image, mipmap); Texture texture = newTexture(data); data.flush(); return texture; } - private static TextureData newTextureDataImpl(BufferedImage image, + private static TextureData newTextureDataImpl(GLProfile glp, + BufferedImage image, int internalFormat, int pixelFormat, boolean mipmap) { - return new AWTTextureData(internalFormat, pixelFormat, mipmap, image); + return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, image); } } diff --git a/src/jogl/classes/com/sun/opengl/util/texture/spi/TextureProvider.java b/src/jogl/classes/com/sun/opengl/util/texture/spi/TextureProvider.java index baa087289..afc6a998e 100755 --- a/src/jogl/classes/com/sun/opengl/util/texture/spi/TextureProvider.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/spi/TextureProvider.java @@ -41,6 +41,7 @@ package com.sun.opengl.util.texture.spi; import java.io.*; import java.net.*; +import javax.media.opengl.GLProfile; import com.sun.opengl.util.texture.*; @@ -58,6 +59,8 @@ public interface TextureProvider { * do any OpenGL-related work. The resulting TextureData can be * converted into an OpenGL texture in a later step. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param file the file from which to read the texture data * * @param internalFormat the OpenGL internal format to be used for @@ -83,7 +86,7 @@ public interface TextureProvider { * * @throws IOException if an error occurred while reading the file */ - public TextureData newTextureData(File file, + public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -95,6 +98,8 @@ public interface TextureProvider { * not do any OpenGL-related work. The resulting TextureData can be * converted into an OpenGL texture in a later step. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param stream the stream from which to read the texture data * * @param internalFormat the OpenGL internal format to be used for @@ -120,7 +125,7 @@ public interface TextureProvider { * * @throws IOException if an error occurred while reading the stream */ - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -132,6 +137,8 @@ public interface TextureProvider { * do any OpenGL-related work. The resulting TextureData can be * converted into an OpenGL texture in a later step. * + * @param glp the OpenGL Profile this texture data should be + * created for. * @param url the URL from which to read the texture data * * @param internalFormat the OpenGL internal format to be used for @@ -157,7 +164,7 @@ public interface TextureProvider { * * @throws IOException if an error occurred while reading the URL */ - public TextureData newTextureData(URL url, + public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, diff --git a/src/jogl/classes/com/sun/opengl/util/texture/spi/awt/IIOTextureProvider.java b/src/jogl/classes/com/sun/opengl/util/texture/spi/awt/IIOTextureProvider.java index 0244db285..f025ba591 100644 --- a/src/jogl/classes/com/sun/opengl/util/texture/spi/awt/IIOTextureProvider.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/spi/awt/IIOTextureProvider.java @@ -44,6 +44,7 @@ import java.awt.image.*; import java.io.*; import java.net.*; import javax.imageio.*; +import javax.media.opengl.GLProfile; import com.sun.opengl.impl.Debug; import com.sun.opengl.util.texture.*; @@ -53,7 +54,7 @@ import com.sun.opengl.util.texture.spi.*; public class IIOTextureProvider implements TextureProvider { private static final boolean DEBUG = Debug.debug("TextureIO"); - public TextureData newTextureData(File file, + public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, @@ -66,10 +67,10 @@ public class IIOTextureProvider implements TextureProvider { System.out.println("TextureIO.newTextureData(): BufferedImage type for " + file + " = " + img.getType()); } - return new AWTTextureData(internalFormat, pixelFormat, mipmap, img); + return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, img); } - public TextureData newTextureData(InputStream stream, + public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, @@ -82,17 +83,17 @@ public class IIOTextureProvider implements TextureProvider { System.out.println("TextureIO.newTextureData(): BufferedImage type for stream = " + img.getType()); } - return new AWTTextureData(internalFormat, pixelFormat, mipmap, img); + return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, img); } - public TextureData newTextureData(URL url, + public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix) throws IOException { InputStream stream = url.openStream(); try { - return newTextureData(stream, internalFormat, pixelFormat, mipmap, fileSuffix); + return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { stream.close(); } diff --git a/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java b/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java index 3157388e9..9772d1a99 100755 --- a/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java +++ b/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java @@ -34,6 +34,8 @@ package com.jogamp.opengl.test.junit.texture.awt; import com.jogamp.opengl.test.junit.texture.util.gl2.TextureGL2ListenerDraw1; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2; @@ -92,12 +94,13 @@ public class Texture1 { @Test public void test1() { - GLCanvas glCanvas = new GLCanvas(); + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3)); + GLCanvas glCanvas = new GLCanvas(caps); frame.add(glCanvas); frame.setSize(512, 512); // create texture - TextureData textureData = AWTTextureIO.newTextureData(textureImage, false); + TextureData textureData = AWTTextureIO.newTextureData(caps.getGLProfile(), textureImage, false); glCanvas.addGLEventListener(new TextureGL2ListenerDraw1(textureData)); Animator animator = new Animator(glCanvas); |