aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-31 03:11:55 +0100
committerSven Gothel <[email protected]>2019-12-31 03:11:55 +0100
commit71773168d8ea67c03e9712c172c2f078099f6bbc (patch)
treed05d98e255fbc6a9411c32616059ad396820feca /src/jogl/classes
parente2223107cc54e08031bd9505ce8a9ccc72673be0 (diff)
Reuse Gluegen's Bitfield.Util for 'PowerOf2' computation
See gluegen commit 178c7b9d40e06a04790542241912ca21d2c7b92f
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java36
1 files changed, 6 insertions, 30 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
index bdaa2d792..5868e1b52 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
@@ -41,6 +41,7 @@ import java.nio.*;
import com.jogamp.opengl.*;
import com.jogamp.opengl.glu.*;
+import com.jogamp.common.util.Bitfield;
import com.jogamp.nativewindow.NativeWindowFactory;
import jogamp.opengl.*;
@@ -538,7 +539,7 @@ public class Texture {
data.setHaveGL12(gl.isExtensionAvailable(GLExtensions.VERSION_1_2));
// Indicates whether both width and height are power of two
- final boolean isPOT = isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight);
+ final boolean isPOT = Bitfield.Util.isPowerOf2(imgWidth) && Bitfield.Util.isPowerOf2(imgHeight);
// Note that automatic mipmap generation doesn't work for
// GL_ARB_texture_rectangle
@@ -553,8 +554,8 @@ public class Texture {
// two. It also doesn't really matter exactly what the texture
// width and height are because the texture coords are always
// between 0.0 and 1.0.
- imgWidth = nextPowerOfTwo(imgWidth);
- imgHeight = nextPowerOfTwo(imgHeight);
+ imgWidth = Bitfield.Util.roundToPowerOf2(imgWidth);
+ imgHeight = Bitfield.Util.roundToPowerOf2(imgHeight);
texWidth = imgWidth;
texHeight = imgHeight;
texTarget = GL.GL_TEXTURE_2D;
@@ -628,8 +629,8 @@ public class Texture {
if (data.getBorder() != 0) {
throw new RuntimeException("Scaling up a non-power-of-two texture which has a border won't work");
}
- texWidth = nextPowerOfTwo(imgWidth);
- texHeight = nextPowerOfTwo(imgHeight);
+ texWidth = Bitfield.Util.roundToPowerOf2(imgWidth);
+ texHeight = Bitfield.Util.roundToPowerOf2(imgHeight);
texTarget = GL.GL_TEXTURE_2D;
}
texParamTarget = texTarget;
@@ -968,31 +969,6 @@ public class Texture {
// Internals only below this point
//
- /**
- * Returns true if the given value is a power of two.
- *
- * @return true if the given value is a power of two, false otherwise
- */
- private static boolean isPowerOfTwo(final int val) {
- return ((val & (val - 1)) == 0);
- }
-
- /**
- * Returns the nearest power of two that is larger than the given value.
- * If the given value is already a power of two, this method will simply
- * return that value.
- *
- * @param val the value
- * @return the next power of two
- */
- private static int nextPowerOfTwo(final int val) {
- int ret = 1;
- while (ret < val) {
- ret <<= 1;
- }
- return ret;
- }
-
private void updateTexCoords() {
if ( GL2.GL_TEXTURE_RECTANGLE_ARB == imageTarget ) {
if (mustFlipVertically) {