Closed Ali-RS closed 1 year ago
I wonder if needGeneratedMips should be set to true in the second constructor. I would kind of expect that if i only pass the wanted mip sizes they would be generated.
If i follow the code in GLRenderer correctly, mipsWhereGenerated is needed to set to true if the miplevels are generated on the gpu, (they can be trusted to be correct) if not, it makes some checks.
Following that, it should actually set mipsWereGenerated to false in the first constructor(Since they are passed manually), but needGeneratedMips to true in the second one (Since we actually want mips to be generated)
Looked a bit deeper into this
The first constructor which takes ArrayList<ByteBuffer> data
seems to be used for texture array and the second constructor which takes ByteBuffer data
is for regular images.
if we pass an int[] mipMapSizes
it means we have generated mips. All mips data must be packed inside the ByteBuffer data
.
This is how mips are generated and stored for an image:
GLRenderer uses TextureUtil to upload a texture to GPU, there if an image has mips packed inside it it will be extracted and uploaded to GPU:
If we do not pass int[] mipMapSizes
it means there is no mips packed inside image data.
I wonder if needGeneratedMips should be set to true in the second constructor. I would kind of expect that if i only pass the wanted mip sizes they would be generated.
So this is not true.
These two constructors on
Image
class behave differently!https://github.com/jMonkeyEngine/jmonkeyengine/blob/f92a73f91ce1a2852645cd1bb5a4c6b597faf7af/jme3-core/src/main/java/com/jme3/texture/Image.java#L749-L762
https://github.com/jMonkeyEngine/jmonkeyengine/blob/f92a73f91ce1a2852645cd1bb5a4c6b597faf7af/jme3-core/src/main/java/com/jme3/texture/Image.java#L805-L816
Look at
needGeneratedMips
andmipsWereGenerated
flags, ifmipMapSizes
is null the first one won't modify the flags but the second one will do (I belive it is wrongly setting mipsWereGenerated = true)Forum post: https://hub.jmonkeyengine.org/t/issue-in-image-class-bug/46297