Open jon-mil-92 opened 1 year ago
Is this necessary though? Iirc, drawing things in a GUI draw allows you to just draw directly to the back buffer, meaning that drawing at (0,0) will always be the top left corner.
Is this necessary though? Iirc, drawing things in a GUI draw allows you to just draw directly to the back buffer, meaning that drawing at (0,0) will always be the top left corner.
that's not the purpose of this function. like the op said, "a hud following an object in the room". it shall render on ui layer (above everything else), but on the coordinates in the room of any object. so he needs a translation between ui and room coordinates. i have also a set of these in place (both directions, world_to_ui and ui_to_world). things like that also help if you want to launch a particle effect on some ui element, as the particle_system is always in world coordinates but your ui is on the ui layer.
See Input's source for a different approach. I would also recommend a GUI -> room function as well as this is occasionally useful.
I have implemented a function that takes in the coordinates of a point in the room, along with the camera index for the current camera, and it returns the GUI layer coordinates in an array. I found this useful for making hud elements follow an object in the room when it enters the camera view.