video memory and two identical textures

BlitzMax Forums/BlitzMax Programming/video memory and two identical textures

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How does this look?
Type Texture

	Global textures:TMap

	Function Load:TImage( filename:String )
	
		If Not textures Then textures = New TMap
		
		If Not textures.ValueForKey(filename) Then
			' Not found, load it.
			Local img:TImage = LoadImage( filename )
			If Not img Then Throw "Unable to load "+filename
			
			textures.insert( filename, img )
			Print "New texture loaded. "+filename
			
			Return img		
		Else
			' get the texture and return it
			Print "Texture reused. "+filename
			Return TImage(textures.ValueForKey(filename))
		EndIf
	
	
	EndFunction


	' Call this after you have changed the graphics mode to reload all textures
	Function Reload()

		If Not textures Then Return ' Nothing to reload

		Local templist:TMap = New TMap

		Local nodeenum:TNodeEnum=textures.ObjectEnumerator()
		While nodeenum.HasNext()
		Local temp:TNode=TNode(nodeenum.NextObject())
			Print("Reloading texture "+temp.Key().ToString())
			'Print("VAL: "+item(temp.Value()).val)
			templist.insert( temp.Key().ToString(), LoadImage( temp.Key().ToString() ) )
		Wend
		
		textures = templist
	
	EndFunction
	
	
	Function Clear()
		textures.clear()
	EndFunction
	

EndType


Anything I should change/add/remove?