Quick Texture/Memory Question

Blitz3D Forums/Blitz3D Programming/Quick Texture/Memory Question

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.

AvailVidMem() is your friend. :)

Actually, I've never bothered to check it until now. Here's a quick test of video memory. It shows one texture applied to 1 or 3 cubes. Availvidmem is the same in both cases (set the var 'loadmorecubes' to 0).

; Texture Memory Test
; -------------------

Graphics3D 640,480,16,2
SetBuffer BackBuffer()

camera=CreateCamera()
light=CreateLight()
RotateEntity light,90,0,0

cube=CreateCube()
PositionEntity cube,0,0,5

loadmorecubes=1 ;<-- extra cubes switch, 0=one cube

If loadmorecubes<>0 ;Load the extra cubes
 cube2=CreateCube()
 PositionEntity cube2,3,0,5
 cube3=CreateCube()
 PositionEntity cube3,-3,0,5
EndIf

tex=CreateTexture(256,256) ;Create texture of size 256x256
SetBuffer TextureBuffer(tex) ;Set buffer - texture buffer
ClsColor 255,255,255 ;Clear texture buffer with background white color
Cls
font=LoadFont("arial",24) ; Draw text on texture
SetFont font
Color 0,0,0
Text 0,0,"This texture"
Text 0,40,"was created using" : Color 0,0,255
Text 0,80,"CreateTexture()" : Color 0,0,0
Text 0,120,"and drawn to using" : Color 0,0,255
Text 0,160,"SetBuffer TextureBuffer()"
SetBuffer BackBuffer() ;Set buffer - backbuffer
EntityTexture cube,tex ;Texture cube with texture

If loadmorecubes<>0 ;Texture the extra cubes
 EntityTexture cube2,tex
 EntityTexture cube3,tex
EndIf

While Not KeyDown(1)

 pitch#=0
 yaw#=0
 roll#=0
 If KeyDown(208) Then pitch#=-1 
 If KeyDown(200) Then pitch#=1
 If KeyDown(203) Then yaw#=-1
 If KeyDown(205) Then yaw#=1
 If KeyDown(45) Then roll#=-1
 If KeyDown(44) Then roll#=1
 TurnEntity cube,pitch#,yaw#,roll#

 If loadmorecubes<>0 ;Spin the extra cubes
  TurnEntity cube2,pitch#,yaw#,roll#
  TurnEntity cube3,pitch#,yaw#,roll#
 EndIf

RenderWorld

 totalmem#=Float(TotalVidMem())/1000000 ;get memory in mb's
 availmem#=Float(AvailVidMem())/1000000
 Text 0,0," total="+Totalmem+"mb, avail="+availmem+"mb"

Flip
Wend
End