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
print ("TYPE loadimage tTexture count : " + str(_texture.length))
Print( "Get Loaded Images : " + str(GetLoadedImages()) )
print ("times that not re-load same images : " + str(myloadimage_wins))
type tTexture
name as string
id as integer
archivo as string
image as integer
object_type as string
endtype
global _object as tObject[]
global _texture as tTexture[]
global myloadimage_wins as integer
function myloadimage( archivo$ , objet_type_name$)
exist = -1
// check if the texture is already loaded
for n = 0 to _texture.length
if archivo$ = _texture[n].archivo
texture_id = _texture[n].image
myloadimage_wins = myloadimage_wins + 1
exist = n
endif
next n
// load a texture that never was loaded
if exist = -1
tx as tTexture
tx.archivo = archivo$
tx.object_type = objet_type_name$
tx.image = loadimage(archivo$)
texture_id = tx.image
_texture.insert(tx)
endif
endfunction texture_id
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