planetis-m / naylib

Yet another raylib Nim wrapper
MIT License
181 stars 10 forks source link

Make texture=, shader= setters work on Weak* types #96

Closed planetis-m closed 1 month ago

planetis-m commented 6 months ago

Somehow tmp are not sinked into the setter and a destructor call is generated in the outer scope.

planetis-m commented 6 months ago

Right that was done on purpose in order to be able to share resources, however this design hits a limit with temporaries. the fix isn't obvious.

planetis-m commented 6 months ago

Nah the fix is obvious you have reset and wasMoved, wasMoved is appropriate here.

planetis-m commented 6 months ago

It actually makes sense for these setters to only accept Weak* counterparts making it explicit that they are unmanaged resources.

planetis-m commented 6 months ago

On the other hand, it's not a weak resource, UnloadMaterial unloads both shader and all the textures... But if part of a Model, then it's not destroyed...

planetis-m commented 6 months ago

I am going full circle here, that's what the repo used in 88cd872 that's a year ago!

planetis-m commented 3 months ago

Also review getShapesTexture and getFontDefault.

planetis-m commented 1 month ago

The solution here is to make a setter with parameter constraints that disallow rvalues.