diff options
author | Sven Göthel <[email protected]> | 2024-01-31 11:58:08 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-01-31 11:58:08 +0100 |
commit | 8d03e7e0b79cf5bd70fa45f524abb236787303ad (patch) | |
tree | 08f60d8873779c13128f2e53681959d5373b9012 | |
parent | 5cf0d370dbc2b1f59102522d40f4875f7d77b1f7 (diff) |
Add Vec2f.set(Vec2i) and Vec2f(Vec2i); Add Texture.set(..) allowing a pending setup/update of texture and image dimensions
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Vec2f.java | 10 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java | 20 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/jogl/classes/com/jogamp/math/Vec2f.java b/src/jogl/classes/com/jogamp/math/Vec2f.java index 547f63a05..94a2ffc62 100644 --- a/src/jogl/classes/com/jogamp/math/Vec2f.java +++ b/src/jogl/classes/com/jogamp/math/Vec2f.java @@ -48,6 +48,10 @@ public final class Vec2f { set(o); } + public Vec2f(final Vec2i o) { + set(o); + } + /** Creating new Vec2f using Vec3f, dropping z. */ public Vec2f(final Vec3f o) { set(o); @@ -71,6 +75,12 @@ public final class Vec2f { this.y = o.y; } + /** this = o (int -> float), returns this. */ + public void set(final Vec2i o) { + this.x = o.x(); + this.y = o.y(); + } + /** this = o while dropping z, returns this. */ public void set(final Vec3f o) { this.x = o.x(); 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 1c2d5f510..7c1f4584e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -285,6 +285,26 @@ public class Texture { throw new GLException("External texture ID invalid: texID "+textureID); } } + /** + * Pending setup or update of texture and image dimensions + * @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 + */ + public void set(final int texWidth, final int texHeight, + final int imgWidth, final int imgHeight) { + this.texWidth = texWidth; + this.texHeight = texHeight; + this.aspectRatio = (float) imgWidth / (float) imgHeight; + this.imgWidth = imgWidth; + this.imgHeight = imgHeight; + this.updateTexCoords(); + } /** * Enables this texture's target (e.g., GL_TEXTURE_2D) in the |