; RenderTextureMemoryKB Example ; ----------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,2,-12 light=CreateLight() RotateEntity light,45,45,0 ; Space spawns crates with unique 256x256 textures; C frees them all again Dim crates(19),skins(19) count=0 While Not KeyDown(1) ; Each press creates a NEW texture, so tracked texture memory grows If KeyHit(57) And count<20 Then skins(count)=CreateTexture(256,256) SetBuffer TextureBuffer(skins(count)) ClsColor Rand(60,255),Rand(60,255),Rand(60,255) Cls SetBuffer BackBuffer() crates(count)=CreateCube() EntityTexture crates(count),skins(count) PositionEntity crates(count),Rnd(-6,6),Rnd(-2,2),Rnd(0,8) count=count+1 EndIf ; C frees every crate and its texture, releasing the memory If KeyHit(46) Then For n=0 To count-1 FreeEntity crates(n) FreeTexture skins(n) Next count=0 EndIf ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld ; RenderTextureMemoryKB tracks targets, shadows, cached textures and uploads Text 0,0,"Space: spawn textured crate C: free all Arrows: camera Esc: exit" Text 0,20,"Unique textures: "+count+" RenderTextureMemoryKB() = "+RenderTextureMemoryKB()+" KiB" Flip Wend End