From 776d1e3158a92140f3103d6bfbfe0b6e632d2666 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Tue, 3 Apr 2007 04:03:35 +0000 Subject: Added TextureIO.setTexRectEnabled() and isTexRectEnabled() based on discussions with Chris Campbell of the Java 2D team, and changed Texture implementation to respect it git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1190 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../com/sun/opengl/util/texture/Texture.java | 4 ++- .../com/sun/opengl/util/texture/TextureIO.java | 35 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src/classes/com/sun/opengl/util') diff --git a/src/classes/com/sun/opengl/util/texture/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java index 167b4e073..9ceff7cd8 100755 --- a/src/classes/com/sun/opengl/util/texture/Texture.java +++ b/src/classes/com/sun/opengl/util/texture/Texture.java @@ -892,6 +892,8 @@ public class Texture { } private static boolean haveTexRect(GL gl) { - return (!disableTexRect && gl.isExtensionAvailable("GL_ARB_texture_rectangle")); + return (!disableTexRect && + TextureIO.isTexRectEnabled() && + gl.isExtensionAvailable("GL_ARB_texture_rectangle")); } } diff --git a/src/classes/com/sun/opengl/util/texture/TextureIO.java b/src/classes/com/sun/opengl/util/texture/TextureIO.java index e537f4276..f1ac85ebd 100755 --- a/src/classes/com/sun/opengl/util/texture/TextureIO.java +++ b/src/classes/com/sun/opengl/util/texture/TextureIO.java @@ -140,6 +140,12 @@ public class TextureIO { private static final boolean DEBUG = Debug.debug("TextureIO"); + // For manually disabling the use of the texture rectangle + // extensions so you know the texture target is GL_TEXTURE_2D; this + // is useful for shader writers (thanks to Chris Campbell for this + // observation) + private static boolean texRectEnabled = true; + //---------------------------------------------------------------------- // methods that *do not* require a current context // These methods assume RGB or RGBA textures. @@ -692,6 +698,35 @@ public class TextureIO { textureWriters.add(0, writer); } + //--------------------------------------------------------------------------- + // Global disabling of texture rectangle extension + // + + /** Toggles the use of the GL_ARB_texture_rectangle extension by the + TextureIO classes. By default, on hardware supporting this + extension, the TextureIO classes may use the + GL_ARB_texture_rectangle extension for non-power-of-two + textures. (If the hardware supports the + GL_ARB_texture_non_power_of_two extension, that one is + preferred.) In some situations, for example when writing + shaders, it is advantageous to force the texture target to + always be GL_TEXTURE_2D in order to have one version of the + shader, even at the expense of texture memory in the case where + NPOT textures are not supported. This method allows the use of + the GL_ARB_texture_rectangle extension to be turned off globally + for this purpose. The default is that the use of the extension + is enabled. */ + public static void setTexRectEnabled(boolean enabled) { + texRectEnabled = enabled; + } + + /** Indicates whether the GL_ARB_texture_rectangle extension is + allowed to be used for non-power-of-two textures; see {@link + #setTexRectEnabled setTexRectEnabled}. */ + public static boolean isTexRectEnabled() { + return texRectEnabled; + } + //---------------------------------------------------------------------- // Internals only below this point // -- cgit v1.2.3