TextureName$ ( texture )
Parameters
| texture - texture handle |
Description
|
Returns the file name a texture was loaded from. For a texture that came from disk - LoadTexture, LoadAnimTexture, or a texture inside a loaded model - you get the file's name including its path, which can be fairly long. For a texture made in code with CreateTexture there is no file, so you get an empty string, and that empty string is itself a handy test for "was this loaded or generated?". Its natural home is model inspection: after digging a texture out of a loaded mesh with GetSurfaceBrush and GetBrushTexture, TextureName tells you which image file it actually is - useful for debugging art problems, or for building tools that list a model's dependencies. See also: LoadTexture, CreateTexture, GetBrushTexture, TextureWidth, TextureHeight. |
Example
; TextureName Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; One texture loaded from disk, one created in code disk_tex=LoadTexture("media/b3dlogo.jpg") code_tex=CreateTexture(128,128) SetBuffer TextureBuffer(code_tex) ClsColor 200,120,40 Cls SetBuffer BackBuffer() cube=CreateCube() PositionEntity cube,0,1,0 EntityTexture cube,disk_tex current=disk_tex While Not KeyDown(1) ; Space swaps the cube between the two textures If KeyHit(57) If current=disk_tex Then current=code_tex Else current=disk_tex EntityTexture cube,current EndIf ; TextureName returns the file a texture was loaded from name$=TextureName$(current) If name$="" Then name$="(empty - this texture was made with CreateTexture)" If Len(name$)>52 Then name$="..."+Right$(name$,49) TurnEntity cube,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,"Space: swap texture Arrows: camera Esc: exit" Text 0,20,"TextureName$(current) = "+name$ Flip Wend End
Index