Re: is there a way to draw a part of a image inside a function?
Posted: Sat Mar 10, 2018 12:17 pm
Okay, so assuming this is what we're talking about: https://msdn.microsoft.com/en-us/library/ff433986.aspx (i.e. XNA)
And that links to this Rectangle page: https://msdn.microsoft.com/en-us/librar ... angle.aspx
With these internals: https://msdn.microsoft.com/en-us/librar ... mbers.aspx
Looks quite a bit like a Quad here (although i somewhat fail to see how the x,y and left,top fields aren't the same), although the constructor page doesn't detail it being wasteful to call it inside the loop... https://msdn.microsoft.com/en-us/librar ... angle.aspx
... that said, reading more into it, it looks like it's just an axis-aligned bounding box implementation (and a horrible one at that, only allowing integer coordinates, according to stackoverflow anyway).
Sadly, i can't tell whether creation would be amortized behind the scenes by XNA itself, having object pools, or something else; point is, if you're using the same objects over more than just one frame, do only create one of them, and re-use them. Memory should still be a concern in this age, otherwise, with some exaggeration, you'll create the next google chrome that may eat up 10s of gigabytes of RAM, if it can. (And löve has a garbage collector, so garbage can and will pile up fast if you're generating it at such a pace)
(not exaggerating, its RAM usage can go up to 24GB on my PC)
And that links to this Rectangle page: https://msdn.microsoft.com/en-us/librar ... angle.aspx
With these internals: https://msdn.microsoft.com/en-us/librar ... mbers.aspx
Looks quite a bit like a Quad here (although i somewhat fail to see how the x,y and left,top fields aren't the same), although the constructor page doesn't detail it being wasteful to call it inside the loop... https://msdn.microsoft.com/en-us/librar ... angle.aspx
... that said, reading more into it, it looks like it's just an axis-aligned bounding box implementation (and a horrible one at that, only allowing integer coordinates, according to stackoverflow anyway).
Sadly, i can't tell whether creation would be amortized behind the scenes by XNA itself, having object pools, or something else; point is, if you're using the same objects over more than just one frame, do only create one of them, and re-use them. Memory should still be a concern in this age, otherwise, with some exaggeration, you'll create the next google chrome that may eat up 10s of gigabytes of RAM, if it can. (And löve has a garbage collector, so garbage can and will pile up fast if you're generating it at such a pace)
(not exaggerating, its RAM usage can go up to 24GB on my PC)