From d25261f80e380d87e48db01a3c888a7ca843797b Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Wed, 3 Sep 2008 01:57:20 +0000 Subject: Added TextureIO.newTexture wrapping an OpenGL texture ID from an external library git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1770 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../com/sun/opengl/util/texture/Texture.java | 17 ++++++++++ .../util/texture/TextureIO.java.javame_cdc_fp | 39 ++++++++++++++++++++++ .../sun/opengl/util/texture/TextureIO.java.javase | 39 ++++++++++++++++++++++ 3 files changed, 95 insertions(+) (limited to 'src/classes/com') diff --git a/src/classes/com/sun/opengl/util/texture/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java index aed480fe0..4e8c206bc 100755 --- a/src/classes/com/sun/opengl/util/texture/Texture.java +++ b/src/classes/com/sun/opengl/util/texture/Texture.java @@ -189,6 +189,23 @@ public class Texture { this.target = target; } + // Package-private constructor for creating a texture object which wraps + // an existing texture ID from another package + Texture(int textureID, + int target, + int texWidth, + int texHeight, + int imgWidth, + int imgHeight, + boolean mustFlipVertically) { + this.texID = textureID; + this.target = target; + this.mustFlipVertically = mustFlipVertically; + this.texWidth = texWidth; + this.texHeight = texHeight; + setImageSize(imgWidth, imgHeight, target); + } + /** * Enables this texture's target (e.g., GL_TEXTURE_2D) in the * current GL context's state. This method is a shorthand equivalent diff --git a/src/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp b/src/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp index f39f1e4c0..fe4724310 100755 --- a/src/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp +++ b/src/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp @@ -489,6 +489,45 @@ public class TextureIO { return new Texture(target); } + /** + * Wraps an OpenGL texture ID from an external library and allows + * some of the base methods from the Texture class, such as + * binding and querying of texture coordinates, to be used with + * it. Attempts to update such textures' contents will yield + * undefined results. + * + * @param textureID the OpenGL texture object to wrap + * @param target the OpenGL texture target, eg GL.GL_TEXTURE_2D, + * GL2.GL_TEXTURE_RECTANGLE + * @param texWidth the width of the texture in pixels + * @param texHeight the height of the texture in pixels + * @param imgWidth the width of the image within the texture in + * pixels (if the content is a sub-rectangle in the upper + * left corner); otherwise, pass in texWidth + * @param imgHeight the height of the image within the texture in + * pixels (if the content is a sub-rectangle in the upper + * left corner); otherwise, pass in texHeight + * @param mustFlipVertically indicates whether the texture + * coordinates must be flipped vertically + * in order to properly display the + * texture + */ + public static Texture newTexture(int textureID, + int target, + int texWidth, + int texHeight, + int imgWidth, + int imgHeight, + boolean mustFlipVertically) { + return new Texture(textureID, + target, + texWidth, + texHeight, + imgWidth, + imgHeight, + mustFlipVertically); + } + /** * Writes the given texture to a file. The type of the file is * inferred from its suffix. An OpenGL context must be current in diff --git a/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase b/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase index ebb59fa6f..2cb2d2c9f 100755 --- a/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase +++ b/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase @@ -489,6 +489,45 @@ public class TextureIO { return new Texture(target); } + /** + * Wraps an OpenGL texture ID from an external library and allows + * some of the base methods from the Texture class, such as + * binding and querying of texture coordinates, to be used with + * it. Attempts to update such textures' contents will yield + * undefined results. + * + * @param textureID the OpenGL texture object to wrap + * @param target the OpenGL texture target, eg GL.GL_TEXTURE_2D, + * GL2.GL_TEXTURE_RECTANGLE + * @param texWidth the width of the texture in pixels + * @param texHeight the height of the texture in pixels + * @param imgWidth the width of the image within the texture in + * pixels (if the content is a sub-rectangle in the upper + * left corner); otherwise, pass in texWidth + * @param imgHeight the height of the image within the texture in + * pixels (if the content is a sub-rectangle in the upper + * left corner); otherwise, pass in texHeight + * @param mustFlipVertically indicates whether the texture + * coordinates must be flipped vertically + * in order to properly display the + * texture + */ + public static Texture newTexture(int textureID, + int target, + int texWidth, + int texHeight, + int imgWidth, + int imgHeight, + boolean mustFlipVertically) { + return new Texture(textureID, + target, + texWidth, + texHeight, + imgWidth, + imgHeight, + mustFlipVertically); + } + /** * Writes the given texture to a file. The type of the file is * inferred from its suffix. An OpenGL context must be current in -- cgit v1.2.3