Active Forums => QB64 Discussion => Topic started by: jakeh0916 on February 12, 2021, 12:05:48 am
Title: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: jakeh0916 on February 12, 2021, 12:05:48 am
Hey everyone, I'm trying to figure out _maptriangle and hardware images here. My intention is to use _maptriangle to map some triangles onto a mode 33 image. Then use _putimage to place that image on the screen. The reason I want to do this instead of just using _maptriangle to directly put triangles on the screen is that I want to preserve the screen resolution (which should be 500x500 here) in fullscreen mode. _FULLSCREEN _SQUAREPIXELS has no effect when using _MAPTRIANGLE in 3d mode, as far as I can tell... and I know of no other way to properly scale a small screen to fullscreen without smoothing it and stretching it.
Anyway, the problem with the current method is that it eats up memory like crazy (starts at around 60MB, steadily increases until crash), and I think it's pretty obvious what the issue is: it's copying that image (background&) to a new mode 33 image every single frame. I'm not sure how to deal with this though, since I don't believe you can _FREEIMAGE a mode 33 image (since its handle is negative) and I don't know how to do this projecting in any other way. (I could be wrong about _FREEIMAGE, though, as I did try it once and it didn't give me an error trying to free the mode 33 image. But, even with "freeing" the image every frame before copying a new one, the memory still rose until the program crashed.)
If you have any ideas or see what I'm messing up here... let me know!
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: SMcNeill on February 12, 2021, 12:47:26 am
You need a _DISPLAY before the end of your loop.
Hardware images won’t render, or leave memory, until _DISPLAY is called. Toss one in there after the Putimage and let me know how it performs.
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: jakeh0916 on February 12, 2021, 01:04:36 am
Oops, that's just a typo. I wrote that sample code for demonstration... I've got a display in there in my actual program, and the displaying works great. The PUTIMAGE scales properly with the screen and keeps its resolution, it's just that the copying of a bunch of software -> hardware images seems to leak memory somewhere.
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: jakeh0916 on February 12, 2021, 01:15:28 am
When I run this at a high frame rate, it seems to also leak some memory. As the program sits, the memory used increases steadily... Not sure what's causing this. Anyone know of a way to avoid this but get a hardware image wiped, written & drawn to the screen each frame?
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: SMcNeill on February 12, 2021, 01:42:42 am
What OS? Version of QB64?
In Win 10, with QB64x64, I run the test code and memory usage stays steady at 57.4MB. I'm not seeing a leak from this. Is it OS specific?
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: jakeh0916 on February 12, 2021, 03:08:28 am
I'm running QB64-1.2 on Windows 10, because I had a problem with _MOUSEMOVEMENTX/Y in 1.4.
Could definitely be some legacy bug. Ran the program again (the one from the wiki) and had memory increase from 40.1 MB to 52.2 MB over about ten minutes, and it was a pretty gradual increase throughout. I'd say this is kind of insignificant, but it looks like the same issue is getting magnified on my other program and causing a lot more memory to leak--or something, idk. I'm going to try it in QB 1.4 and see how that handles...
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: jakeh0916 on February 12, 2021, 04:36:48 am
Incredibly, it does seem to be that me running an old version of QB64 was the problem. Who would've guessed. Now if only I can get _MOUSEMOVEMENT working on 1.4!
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: jakeh0916 on February 12, 2021, 04:58:19 am
Oh.. encountered the issue again, actually. I'm going to make a new post with a better example/title for this because I think I've made this one a little convoluted!
Title: Re: Question about _MAPTRIANGLE, hardware images, and image handles... :'(
Post by: FellippeHeitor on February 12, 2021, 06:33:45 am
_MOUSEMOVEMENT has been fixed in upcoming v1.5. You can already start using it though: https://www.qb64.org/portal/development-build/