Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / MyLoadimage(file$) optimized way to load images for the game without repets or leaks

Author
Message
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 20th Oct 2020 23:44
Hello, this is a way to load images in a more optimized way.

The function was created because I had an image overload in memory in my game, which generated crashes and data overload, making the game slow.

the function serves to:
Prevents the same image from being uploaded twice
It allows to have better control over the loaded images

the idea was from BlinkOk, I just put music on it.



texture = myloadimage( filename$ , "object_name_for_internal_use")



use this to check









I am not very lucid to express myself, but I think it is very useful to not have leaks, or overload that affects performance.
Cheers
Santiago
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 21st Oct 2020 15:17
add MYDeleteimage() function



function mydeleteimage(image_id)

for n = _texture.length to 0 step -1
if image_id = _texture[n].image

deleteimage(_texture[n].image)
_texture.remove(n)
endif
next

endfunction
JonEnstrom
4
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 21st Oct 2020 17:30
It seems like the only problem this would solve is with poor code structure? Why would you be trying to load an image that you already loaded before?

It is useful to not have leaks but you should be addressing the root cause of the issue instead of using a band-aid like this to get around it.
gosukiwi
AGK Tool Maker
4
Years of Service
User Offline
Joined: 24th May 2020
Location: Argentina
Posted: 22nd Oct 2020 03:08 Edited at: 22nd Oct 2020 03:13
There's nothing wrong with idempotence.

Login to post a reply

Server time is: 2024-11-21 23:12:21
Your offset time is: 2024-11-21 23:12:21