-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
GLRenderer.modifyTexture on GLES fix #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLRenderer.modifyTexture on GLES fix #1235
Conversation
Resync fork
Update fork
Fork update
|
Looks satisfactory to me, but I'd like to hear from other who know more. |
|
Mhhh, we can't do that. I think the method should only throw an exception if the formats do not match, and then let the developer handle conversions depending on the situation. |
|
Agreed. I was going to say the same thing. We don't know what the application is doing with this image. They might be updating the buffer, for example. Only the application knows so only the application can determine when/if it is safe to convert. |
|
Also, I could swear we already image conversion implemented somewhere... and directly on Image is not a good place for it. It should be external and take one Image and produce another. |
|
I agree also, thinking about it I realized that it can be risky to change the image this way as it could be used by other textures for example. There's an exception on this, in the case of niftygui at least using xmls you don't have code control to convert the image before it's added to the atlas, in fact worst still, nifty has the hardcoded
So if we just throw an exception if formats don't match every nifty android user will receive it and no app using batched nifty will work on android at all. Instead I would output a warning log or something similar instead. Do you agree? I'll check the JmeBatchRenderBackend just in case I could create a new image with the appropiate format in loadImage or addImageToAtlas methods (which in the end will call GLRenderer.modifyTexture). Fixing this for nifty but allowing the developers to do what they want with the images. Also, @pspeed42 I didn't find any image conversion method, do you remember where it is? I'll look for it and if not found I'll move mine from Image class to other place or maybe keep the new convert method but return a new image keeping the current as it is now 🤔 EDIT: For the case of nifty batch, it's safe to add the gles check and conversion just in because And for the case of any other texSubImage call, we leave the developers make what they want |
|
Which loadImage()? For the general loadImage(), you also wouldn't want to autoconvert because apps might be expecting a particular format. Or is this in the JME-nifty adapter? (Which is where any nifty-specific changes should be.) |
|
And as for existing conversions, I may have been thinking about the ImageCodec stuff that was written for ImageRaster. I thought there was a utility method to use it to copy one image format to another but I can't find it in 5 seconds of glancing around. |
Yes, I was talking about the loadImage in JmeBatchRenderBackend class in jme3-nifty package |
I didn't find any conversion method and I spent much more time looking around... :( |
|
You should be able to use ImageRaster for that |
…r.modifyTexture. Added a warning instead for the potential failing cases Fixing the issue in JmeBatchRenderBackend.loadImage transforming it to RGBA8 if required
|
I finally reverted the previous change, implemented the conversion using ImageRaster directly in JmeBatchRenderBackend when needed and added a warning to the modifyTexture methods |
riccardobl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, nothing obviously wrong. I would wait for someone else who knows nifty to approve. But for me it's OK.
As I commented in forum thread https://hub.jmonkeyengine.org/t/niftygui-some-controls-have-bad-rendering-in-android-having-batch-enabled/42641 all calls to GLRenderer.modifyTexture having different formats of source and destination texture done in GLES context fails with a GL_INVALID_EXCEPTION because glTexSubImage2D on GLES doesn't support it.
This PR adds a method in Image class to convert among formats, currently just rgb8 to rgba8 and back which I think are the most common cases for this and modifies GLRenderer.modifyTexture to call it if required