Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9dfb1a3
Deprecate CursorLoader
mondogo24 May 7, 2026
e78b01e
Drop Desktop.cfg file and change references for General.cfg
mondogo24 May 7, 2026
7b0ff9d
Javadoc improvements in CursorLoader
mondogo24 May 7, 2026
dd3335c
Revert "Drop Desktop.cfg file and change references for General.cfg"
mondogo24 May 7, 2026
ba7e586
Adapted TestCursor for the deprecation of CursorLoader
mondogo24 May 22, 2026
85de977
feature: CursorConverter now support cursor animations
mondogo24 May 27, 2026
23ab1e7
Merge branch 'master' into refactor/deprecate-CursorLoader
mondogo24 May 27, 2026
b9e60e1
doc: update CursorLoader deprecation javadoc
mondogo24 May 27, 2026
ba390ac
Fix cached assets related problems
mondogo24 Jun 1, 2026
40ffe74
Deleted manual null checks in CursorConverter
mondogo24 Jun 1, 2026
ee832ce
Fix misspell mistake: from 'applyed' to 'applied'
mondogo24 Jun 1, 2026
db22e58
Add Flip() to IntBuffer data and swap reduce() with a for loop
mondogo24 Jun 1, 2026
14c41e7
Fix some spelling/grammar issues in javadoc and error messages
mondogo24 Jun 1, 2026
596ea87
Update lincense disclaimer and javadoc in TestCursor
mondogo24 Jun 1, 2026
e002d5d
Added missing extra information in license disclaimer
mondogo24 Jun 1, 2026
f8688be
Add deep clone to Image
mondogo24 Jun 2, 2026
0708ab1
Added custom hot spot and other improvements
mondogo24 Jun 4, 2026
be9f260
Fix javadoc brackets misuse
mondogo24 Jun 11, 2026
71fe4dd
Merge branch 'master' into refactor/deprecate-CursorLoader
riccardobl Oct 30, 2026
b0543e1
Merge branch 'master' into refactor/deprecate-CursorLoader
mondogo24 Nov 1, 2026
b74a950
Improve CursorConverter's reliability and documentation.
mondogo24 Nov 8, 2026
1aebf7b
Merge branch 'master' into refactor/deprecate-CursorLoader
mondogo24 Nov 8, 2026
c75f6da
Fixed invalid yhotspot positions
mondogo24 Nov 11, 2026
82ad7d9
Fixed CursorConverter incompatibility with AndroidMouseInput24
mondogo24 Nov 11, 2026
111851a
Fixed wrong buffer size for Android and documented if hotspots flip
mondogo24 Nov 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void setCursorVisible(boolean visible) {
public void setNativeCursor(JmeCursor cursor) {
if(inputHandler.getView()!=null) {
if(cursor!=null) {
// Translate into Android Bitmap format ARGB888. Assuming input image as RGBA
// Translate into Android Bitmap format ARGB888. Assuming input image as RGBA where each channel is an integer.
int bufferSize = cursor.getHeight()*cursor.getWidth();
int[] outputBitmap=new int[bufferSize];
IntBuffer inputImage = cursor.getImagesData().asReadOnlyBuffer();
Expand Down
29 changes: 24 additions & 5 deletions jme3-core/src/main/java/com/jme3/math/ColorRGBA.java
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,25 @@ public int asIntABGR() {
return toInt(a, b, g, r);
}

/**
* Retrieves the component values of this <code>ColorRGBA</code> as an
* <code>int[]</code> of lenght four in r,g,b,a order.
* Where:
* int[0] = red value in range of 0-255.
* int[1] = green value in range of 0-255.
* int[2] = blue value in range of 0-255.
* int[3] = alpha value in range of 0-255.
*
* @return The integer array representation of this <code>ColorRGBA</code> in r,g,b,a order.
*/
public int[] asIntsRGBA() {
int intR = ((int) (r * 255) & 0xFF);
int intG = ((int) (g * 255) & 0xFF);
int intB = ((int) (b * 255) & 0xFF);
int intA = ((int) (a * 255) & 0xFF);
return new int[] {intR, intG, intB, intA};
}

/**
* Sets the component values of this <code>ColorRGBA</code> with the given
* combined ARGB <code>int</code>.
Expand Down Expand Up @@ -824,10 +843,10 @@ private float fromByte(int channelByte) {
* Helper method to combine four float channels into an int.
*/
private int toInt(float c1, float c2, float c3, float c4) {
int r = ((int) (c1 * 255) & 0xFF);
int g = ((int) (c2 * 255) & 0xFF);
int b = ((int) (c3 * 255) & 0xFF);
int a = ((int) (c4 * 255) & 0xFF);
return (r << 24) | (g << 16) | (b << 8) | a;
int intC1 = ((int) (c1 * 255) & 0xFF);
int intC2 = ((int) (c2 * 255) & 0xFF);
int intC3 = ((int) (c3 * 255) & 0xFF);
int intC4 = ((int) (c4 * 255) & 0xFF);
return (intC1 << 24) | (intC2 << 16) | (intC3 << 8) | intC4;
}
}
72 changes: 47 additions & 25 deletions jme3-core/src/main/java/com/jme3/texture/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ public enum Format {
Reserved2(0),

/**
* half-precision floating-point grayscale/luminance.
*
* Requires {@link Caps#HalfFloatTexture}.
* half-precision floating-point grayscale/luminance.
*
* Requires {@link Caps#HalfFloatTexture}.
*/
Luminance16F(16,true),

/**
* single-precision floating-point grayscale/luminance.
*
* Requires {@link Caps#FloatTexture}.
* Requires {@link Caps#FloatTexture}.
*/
Luminance32F(32,true),

Expand All @@ -101,9 +101,9 @@ public enum Format {
Reserved3(0),

/**
* half-precision floating-point grayscale/luminance and alpha.
*
* Requires {@link Caps#HalfFloatTexture}.
* half-precision floating-point grayscale/luminance and alpha.
*
* Requires {@link Caps#HalfFloatTexture}.
*/
Luminance16FAlpha16F(32,true),

Expand Down Expand Up @@ -255,7 +255,7 @@ public enum Format {
* but will be converted to {@link Format#RGB111110F} when sent
* to the video hardware.
*
* Requires {@link Caps#HalfFloatTexture} and {@link Caps#PackedFloatTexture}.
* Requires {@link Caps#HalfFloatTexture} and {@link Caps#PackedFloatTexture}.
*/
RGB16F_to_RGB111110F(48,true),

Expand All @@ -271,7 +271,7 @@ public enum Format {
* but will be converted to {@link Format#RGB9E5} when sent
* to the video hardware.
*
* Requires {@link Caps#HalfFloatTexture} and {@link Caps#SharedExponentTexture}.
* Requires {@link Caps#HalfFloatTexture} and {@link Caps#SharedExponentTexture}.
*/
RGB16F_to_RGB9E5(48,true),

Expand All @@ -283,32 +283,32 @@ public enum Format {
RGB9E5(32,true),

/**
* half-precision floating point red, green, and blue.
*
* Requires {@link Caps#HalfFloatTexture}.
* half-precision floating point red, green, and blue.
*
* Requires {@link Caps#HalfFloatTexture}.
* May be supported for renderbuffers, but the OpenGL specification does not require it.
*/
RGB16F(48,true),

/**
* half-precision floating point red, green, blue, and alpha.
*
* Requires {@link Caps#HalfFloatTexture}.
* Requires {@link Caps#HalfFloatTexture}.
*/
RGBA16F(64,true),

/**
* single-precision floating point red, green, and blue.
*
* Requires {@link Caps#FloatTexture}.
* single-precision floating point red, green, and blue.
*
* Requires {@link Caps#FloatTexture}.
* May be supported for renderbuffers, but the OpenGL specification does not require it.
*/
RGB32F(96,true),

/**
* single-precision floating point red, green, blue and alpha.
*
* Requires {@link Caps#FloatTexture}.
* single-precision floating point red, green, blue and alpha.
*
* Requires {@link Caps#FloatTexture}.
*/
RGBA32F(128,true),

Expand Down Expand Up @@ -507,21 +507,21 @@ public enum Format {
/**
* half-precision floating point red.
*
* Requires {@link Caps#HalfFloatTexture}.
* Requires {@link Caps#HalfFloatTexture}.
*/
R16F(16,true),

/**
* single-precision floating point red.
*
* Requires {@link Caps#FloatTexture}.
* single-precision floating point red.
*
* Requires {@link Caps#FloatTexture}.
*/
R32F(32,true),

/**
* half-precision floating point red and green.
*
* Requires {@link Caps#HalfFloatTexture}.
* Requires {@link Caps#HalfFloatTexture}.
*/
RG16F(32,true),

Expand Down Expand Up @@ -719,7 +719,8 @@ public long getUniqueId() {
}

/**
* @return A shallow clone of this image. The data is not cloned.
* @return a shallow clone of this image. The data is not cloned.
* @see #deepClone() Deep clone.
*/
@Override
public Image clone(){
Expand All @@ -731,6 +732,27 @@ public Image clone(){
return clone;
}

/**
* @return a deep clone of this image. The data is cloned.
* @see #clone() Shallow clone.
*/
public Image deepClone() {
Image clone = (Image) super.clone();
clone.mipMapSizes = mipMapSizes != null ? mipMapSizes.clone() : null;
clone.data = data != null ? dataDeepClone() : null;
clone.lastTextureState = new LastTextureState();
clone.setUpdateNeeded();
return clone;
}

private ArrayList<ByteBuffer> dataDeepClone() {
ArrayList<ByteBuffer> clone = new ArrayList<ByteBuffer>(data.size());
for (ByteBuffer originalBuffer : data) {
clone.add(BufferUtils.clone(originalBuffer));
}
return clone;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deep-copy path uses BufferUtils.clone(ByteBuffer), which calls rewind() on the supplied buffer and advances it to its limit while copying. Because originalBuffer belongs to the source Image, calling deepClone() therefore changes the source image's buffer position as a side effect (including the cached asset images used by the converter). Please clone a duplicate so the source buffer's position and limit remain untouched.

Suggested change
}
clone.add(BufferUtils.clone(originalBuffer.duplicate()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a problem with the cloned buffer's state: BufferUtils.clone() leaves its returned buffer positioned at its limit. Since Image data is commonly consumed via the buffer's remaining elements, a deepClone() can consequently appear to contain no image data. Please reset the copied buffer for reading before storing it.

Suggested change
}
ByteBuffer clonedBuffer = BufferUtils.clone(originalBuffer.duplicate());
clonedBuffer.flip();
clone.add(clonedBuffer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction: I’m not confident in my previous note about the cloned buffer’s position without verifying the exact BufferUtils.clone() contract, so please disregard that suggestion. The source-buffer side-effect concern in my other comment still stands if the helper rewinds its input; cloning a duplicate protects the source buffer’s state.


/**
* Constructor instantiates a new <code>Image</code> object. All values
* are undefined.
Expand Down
1 change: 0 additions & 1 deletion jme3-core/src/main/resources/com/jme3/asset/Desktop.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
INCLUDE com/jme3/asset/General.cfg

# Desktop-specific loaders
Comment thread
mondogo24 marked this conversation as resolved.
Resolved
LOADER com.jme3.cursors.plugins.CursorLoader : ani, cur, ico
Loading