; GetBrushTexture Example ; ----------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; Two textures: one from disk, one made in code logo_tex=LoadTexture("media/b3dlogo.jpg") code_tex=CreateTexture(64,64) SetBuffer TextureBuffer(code_tex) ClsColor 80,160,255 Cls SetBuffer BackBuffer() ; A brush drives the look of this pickup crate brush=CreateBrush() BrushTexture brush,logo_tex crate=CreateCube() PositionEntity crate,0,1,0 PaintEntity crate,brush While Not KeyDown(1) ; 1 / 2 retexture the brush, then repaint the crate with it If KeyHit(2) BrushTexture brush,logo_tex PaintEntity crate,brush EndIf If KeyHit(3) BrushTexture brush,code_tex PaintEntity crate,brush EndIf ; Ask the brush which texture sits in slot 0 got=GetBrushTexture(brush,0) name$=TextureName$(got) If name$="" Then name$="(unnamed - created in code)" If Len(name$)>48 Then name$="..."+Right$(name$,45) ; The returned handle is a copy - free it or copies pile up FreeTexture got TurnEntity crate,0,1,0 ; 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 Text 0,0,"1/2: swap brush texture Arrows: camera Esc: exit" Text 0,20,"GetBrushTexture(brush,0) is "+name$ Flip Wend End