I looked with AvailVidMem() how much memory my video card has left after loading, and unloading, but it seems to always forget to unload something (because I always loose 3 mb video memory, for each time I unload, and load something). This is my code:
Load_Mainmenu.bb:
;Goto start
.load_mainmenu
;Display loadingscreen
ShowLoadingScreen("Data\images\loadscr_main.bmp",showcoords)
;Create camera
camera=CreateCamera()
PositionEntity camera,0,0,0
RotateEntity camera,0,0,0
;Set ambient light
AmbientLight 15,15,15
;Load scene
If FileType("Data\world\mainmenu.x")=0 Then
RuntimeError "Couldn't locate mainmenu.x"
EndIf
scene=LoadMesh("Data\world\mainmenu.x")
PositionEntity scene,0,0,0
RotateEntity scene,0,0,0
;Load mousepointer
LoadMousePointer("Data\images\mouse\menu.bmp","Data\images\mouse\1pic.bmp",255,0,255)
;Load menues
; Validating
If FileType("Data\images\menues\menutop_main.bmp")=0 Then
RuntimeError "Couldn't locate menutop_main.bmp"
EndIf
If FileType("Data\images\menues\menutop_load.bmp")=0 Then
RuntimeError "Couldn't locate menutop_load.bmp"
EndIf
If FileType("Data\images\menues\menu_new.bmp")=0 Then
RuntimeError "Couldn't locate menu_new.bmp"
EndIf
If FileType("Data\images\menues\menu_save.bmp")=0 Then
RuntimeError "Couldn't locate menu_save.bmp"
EndIf
If FileType("Data\images\menues\menu_load.bmp")=0 Then
RuntimeError "Couldn't locate menu_load.bmp"
EndIf
If FileType("Data\images\menues\menu_multi.bmp")=0 Then
RuntimeError "Couldn't locate menu_multi.bmp"
EndIf
If FileType("Data\images\menues\menu_quit.bmp")=0 Then
RuntimeError "Couldn't locate menu_quit.bmp"
EndIf
If FileType("Data\images\menues\loadmenu_gamenames.bmp")=0 Then
RuntimeError "Couldn't locate loadmenu_gamenames.bmp"
EndIf
If FileType("Data\images\menues\menufoot.bmp")=0 Then
RuntimeError "Couldn't locate menufoot.bmp"
EndIf
; Loading
menutop_main=LoadImage("Data\images\menues\menutop_main.bmp")
menutop_load=LoadImage("Data\images\menues\menutop_load.bmp")
menu_new=LoadAnimImage("Data\images\menues\menu_new.bmp",201,20,0,2)
menu_save=LoadAnimImage("Data\images\menues\menu_save.bmp",201,20,0,2)
menu_load=LoadAnimImage("Data\images\menues\menu_load.bmp",201,20,0,2)
menu_quit=LoadAnimImage("Data\images\menues\menu_quit.bmp",201,20,0,2)
menu_multi=LoadAnimImage("Data\images\menues\menu_multi.bmp",201,20,0,2)
loadmenu_gamenames=LoadImage("Data\images\menues\loadmenu_gamenames.bmp")
menufoot=LoadImage("Data\images\menues\menufoot.bmp")
; Masking
MaskImage(menutop_main,255,0,255)
MaskImage(menutop_load,255,0,255)
MaskImage(menu_new,255,0,255)
MaskImage(menu_load,255,0,255)
MaskImage(menu_save,255,0,255)
MaskImage(loadmenu_gamenames,255,0,255)
MaskImage(menu_multi,255,0,255)
MaskImage(menu_quit,255,0,255)
MaskImage(menufoot,255,0,255)
; Menu positions
mainmenux=588
mainmenuy=434
newgamemenux=0
newgamemenuy=0
loadgamemenux=86
loadgamemenuy=225
loadgametextx=187
loadgametexty=230
onlinemenux=0
onlinemenuy=0
;Variables
menux=mainmenux
menuy=mainmenuy
menumode=1
camerawander_main_first=0
;Load fonts
font_gamenames=LoadFont("Alfredo's Dance",20)
font_standard=LoadFont("Arial",16)
;Create lights
Dim light(3000)
light(1)=CreateLight(3)
PositionEntity light(1),-106.893,49.8281,14.2249
RotateEntity light(1),24.1333,-98.297,0
LightRange light(1),400
;Create Dims
Dim save_gamenames$(6)
Dim save_health%(6)
Dim save_checkpoint%(6)
;Hide loadingscreen
Cls
CameraViewport camera,0,0,resx-camleft,resy-camtop
;Main loop
Include "Loop_Mainmenu.bb"
;Unload
.unload_mainmenu
Include "Unload_Mainmenu.bb"
;City Level
.load_city
Include "Load_City.bb"
And this code for unloading ("Unload_Mainmenu.bb"):
;Images
FreeImage menutop_main
FreeImage menutop_load
FreeImage menu_new
FreeImage menu_save
FreeImage menu_load
FreeImage menu_quit
FreeImage menu_multi
FreeImage loadmenu_gamenames
FreeImage menufoot
;World
FreeEntity scene
;Cameraes
FreeEntity camera
;Lights
FreeEntity light(0)
;Fonts
FreeFont font_gamenames
FreeFont font_standard
If leveltoload$="City" Then
Goto load_city
EndIf
Anyone see where the memory loss is?
Load_Mainmenu.bb:
;Goto start
.load_mainmenu
;Display loadingscreen
ShowLoadingScreen("Data\images\loadscr_main.bmp",showcoords)
;Create camera
camera=CreateCamera()
PositionEntity camera,0,0,0
RotateEntity camera,0,0,0
;Set ambient light
AmbientLight 15,15,15
;Load scene
If FileType("Data\world\mainmenu.x")=0 Then
RuntimeError "Couldn't locate mainmenu.x"
EndIf
scene=LoadMesh("Data\world\mainmenu.x")
PositionEntity scene,0,0,0
RotateEntity scene,0,0,0
;Load mousepointer
LoadMousePointer("Data\images\mouse\menu.bmp","Data\images\mouse\1pic.bmp",255,0,255)
;Load menues
; Validating
If FileType("Data\images\menues\menutop_main.bmp")=0 Then
RuntimeError "Couldn't locate menutop_main.bmp"
EndIf
If FileType("Data\images\menues\menutop_load.bmp")=0 Then
RuntimeError "Couldn't locate menutop_load.bmp"
EndIf
If FileType("Data\images\menues\menu_new.bmp")=0 Then
RuntimeError "Couldn't locate menu_new.bmp"
EndIf
If FileType("Data\images\menues\menu_save.bmp")=0 Then
RuntimeError "Couldn't locate menu_save.bmp"
EndIf
If FileType("Data\images\menues\menu_load.bmp")=0 Then
RuntimeError "Couldn't locate menu_load.bmp"
EndIf
If FileType("Data\images\menues\menu_multi.bmp")=0 Then
RuntimeError "Couldn't locate menu_multi.bmp"
EndIf
If FileType("Data\images\menues\menu_quit.bmp")=0 Then
RuntimeError "Couldn't locate menu_quit.bmp"
EndIf
If FileType("Data\images\menues\loadmenu_gamenames.bmp")=0 Then
RuntimeError "Couldn't locate loadmenu_gamenames.bmp"
EndIf
If FileType("Data\images\menues\menufoot.bmp")=0 Then
RuntimeError "Couldn't locate menufoot.bmp"
EndIf
; Loading
menutop_main=LoadImage("Data\images\menues\menutop_main.bmp")
menutop_load=LoadImage("Data\images\menues\menutop_load.bmp")
menu_new=LoadAnimImage("Data\images\menues\menu_new.bmp",201,20,0,2)
menu_save=LoadAnimImage("Data\images\menues\menu_save.bmp",201,20,0,2)
menu_load=LoadAnimImage("Data\images\menues\menu_load.bmp",201,20,0,2)
menu_quit=LoadAnimImage("Data\images\menues\menu_quit.bmp",201,20,0,2)
menu_multi=LoadAnimImage("Data\images\menues\menu_multi.bmp",201,20,0,2)
loadmenu_gamenames=LoadImage("Data\images\menues\loadmenu_gamenames.bmp")
menufoot=LoadImage("Data\images\menues\menufoot.bmp")
; Masking
MaskImage(menutop_main,255,0,255)
MaskImage(menutop_load,255,0,255)
MaskImage(menu_new,255,0,255)
MaskImage(menu_load,255,0,255)
MaskImage(menu_save,255,0,255)
MaskImage(loadmenu_gamenames,255,0,255)
MaskImage(menu_multi,255,0,255)
MaskImage(menu_quit,255,0,255)
MaskImage(menufoot,255,0,255)
; Menu positions
mainmenux=588
mainmenuy=434
newgamemenux=0
newgamemenuy=0
loadgamemenux=86
loadgamemenuy=225
loadgametextx=187
loadgametexty=230
onlinemenux=0
onlinemenuy=0
;Variables
menux=mainmenux
menuy=mainmenuy
menumode=1
camerawander_main_first=0
;Load fonts
font_gamenames=LoadFont("Alfredo's Dance",20)
font_standard=LoadFont("Arial",16)
;Create lights
Dim light(3000)
light(1)=CreateLight(3)
PositionEntity light(1),-106.893,49.8281,14.2249
RotateEntity light(1),24.1333,-98.297,0
LightRange light(1),400
;Create Dims
Dim save_gamenames$(6)
Dim save_health%(6)
Dim save_checkpoint%(6)
;Hide loadingscreen
Cls
CameraViewport camera,0,0,resx-camleft,resy-camtop
;Main loop
Include "Loop_Mainmenu.bb"
;Unload
.unload_mainmenu
Include "Unload_Mainmenu.bb"
;City Level
.load_city
Include "Load_City.bb"
And this code for unloading ("Unload_Mainmenu.bb"):
;Images
FreeImage menutop_main
FreeImage menutop_load
FreeImage menu_new
FreeImage menu_save
FreeImage menu_load
FreeImage menu_quit
FreeImage menu_multi
FreeImage loadmenu_gamenames
FreeImage menufoot
;World
FreeEntity scene
;Cameraes
FreeEntity camera
;Lights
FreeEntity light(0)
;Fonts
FreeFont font_gamenames
FreeFont font_standard
If leveltoload$="City" Then
Goto load_city
EndIf
Anyone see where the memory loss is?