-
Notifications
You must be signed in to change notification settings - Fork 88
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
Shader.set_uniform_texture() texture borrow lifetime is too restrictive #213
Comments
I'm not sure how to solve this in an easy way. This will probably require finding a good solution to allow Shader/Sprite/etc. to accept |
One idea I have is allowing ownership of the texture by Shader. Maybe have a method for temporarily borrowing it mutably if it needs to be modified. Moving the Shader shouldn't cause problems, because the texture is at a fixed location on the heap, thanks to SfBox. |
Are there any updates on this? I'm incurring in the same problem. I can help with the implementation if a design is agreed upon. |
We could potentially have an unsafe method that accepts a raw pointer to a Texture and offloads the responsibility of ensuring soundness to the user, until we come up with a better solution. If anyone has good ideas on safe solutions though, I'm happy to review them! |
I think that as a temporary solution it can be ok, as long as we can document well how to use it safely. Meanwhile I'm also thinking about safe solutions, but it's not easy to find one while keeping the same structure as SFML :( |
From what I understand of the concepts of Rust you either have:
I would like to help on the subject but I am really a noob in the world of bindings and I will need help myself to make the subject move forward... |
This comment was marked as resolved.
This comment was marked as resolved.
Thank you so much for having shared your solution! |
Could someone perhaps provide an example of how this would look in practice? I'm currently struggling to implement the proposed solution. How can uniform textures in the shader even be set at all while it is borrowed by RenderStates (required to apply shader using draw_with_render_states)? Many thanks in advance to any future legend that might help me out here. |
Borrowing the texture for its entire lifetime renders this method unusable:
borrow might be used here, when 'shader' is dropped and runs the 'Drop' code for type 'sfml::graphics::Shader'
The text was updated successfully, but these errors were encountered: