From 834c8290de028cdfd16d3da11d1f6a4566ffb8c1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 3 Apr 2012 18:24:46 +0200 Subject: Texture: Ignore enable/disable for GL_TEXTURE_EXTERNAL_OES; TextureCoords: Add convenience coord transfer method to buffer. --- .../com/jogamp/opengl/util/texture/Texture.java | 23 ++++++++++++--- .../jogamp/opengl/util/texture/TextureCoords.java | 34 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 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 511b857af..01c8db09d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -207,15 +207,23 @@ public class Texture {
      gl.glEnable(texture.getTarget());
      
- * + * + *

+ * Call is ignored if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}. + *

+ *

* See the performance tips above for hints * on how to maximize performance when using many Texture objects. + *

+ * @param gl the current GL object * * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ public void enable(GL gl) throws GLException { - gl.glEnable(target); + if(GLES2.GL_TEXTURE_EXTERNAL_OES != target) { + gl.glEnable(target); + } } /** @@ -226,15 +234,22 @@ public class Texture { gl.glDisable(texture.getTarget()); * + *

+ * Call is ignored if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}. + *

+ *

* See the performance tips above for hints * on how to maximize performance when using many Texture objects. - * @param gl TODO + *

+ * @param gl the current GL object * * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ public void disable(GL gl) throws GLException { - gl.glDisable(target); + if(GLES2.GL_TEXTURE_EXTERNAL_OES != target) { + gl.glDisable(target); + } } /** diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java index 8d8b3679d..61f5d116c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java @@ -36,6 +36,8 @@ package com.jogamp.opengl.util.texture; +import java.nio.FloatBuffer; + /** Specifies texture coordinates for a rectangular area of a texture. Note that some textures are inherently flipped vertically from OpenGL's standard coordinate system. This class takes care of @@ -61,6 +63,38 @@ public class TextureCoords { this.top = top; } + /** Transfers {s * ss, t * ts} from this object into the given float[8+d_off] in the following order: + *
+     *   left,  bottom
+     *   right, bottom
+     *   left,  top
+     *   right  top
+     * 
+ */ + public float[] getST_LB_RB_LT_RT(float[] d, int d_off, float ss, float ts) { + d[0+d_off] = left *ss; d[1+d_off] = bottom*ts; + d[2+d_off] = right *ss; d[3+d_off] = bottom*ts; + d[4+d_off] = left *ss; d[5+d_off] = top *ts; + d[6+d_off] = right *ss; d[7+d_off] = top *ts; + return d; + } + + /** Transfers {s * ss, t * ts} from this object into the given FloatBuffer in the following order: + *
+     *   left,  bottom
+     *   right, bottom
+     *   left,  top
+     *   right  top
+     * 
+ */ + public FloatBuffer getST_LB_RB_LT_RT(FloatBuffer d, float ss, float ts) { + d.put( left *ss); d.put( bottom*ts); + d.put( right *ss); d.put( bottom*ts); + d.put( left *ss); d.put( top *ts); + d.put( right *ss); d.put( top *ts); + return d; + } + /** Returns the leftmost (x) texture coordinate of this rectangle. */ public float left() { return left; } -- cgit v1.2.3