|
match_text$ - text to look for in the texture filename texture_flags (optional) - texture flags to add, as per LoadTexture; 0 (default): 1: colour 2: alpha 4: masked - areas coloured 0,0,0 are not drawn 8: mipmapped 16: clamp u - no horizontal tiling 32: clamp v - no vertical tiling 64: spherical environment map 128: cubic environment map 256: store texture in vram (no effect on the modern renderer) 512: force high colour textures (no effect on the modern renderer) |
|
Adds a texture filter, so that textures whose filename contains match_text$ pick up extra flags automatically. This is how you set texture flags for art you never load by hand - the textures that arrive with a mesh. LoadMesh has nowhere to pass flags, so instead you name your art with a convention and let a filter do the work: TextureFilter "_mask",4 turns every texture whose name contains "_mask" into a masked texture, wherever the mesh loader finds it. Matching is a plain case-insensitive substring test against the whole filename, so "_mask" matches "gfx/fence_mask.png", and "tree" matches "trees.bmp" as well as "oaktree.png". Filters do not replace one another: every filter that matches contributes, and its flags are added on top of the flags the load already asked for. An empty match_text$ matches everything. One filter is installed for you at startup: TextureFilter "",1+8 which is why loaded textures come out colour + mipmapped without you asking. Since that catch-all filter stays in the list, adding your own filters can only ever add flags, never take them away - to start from nothing, call ClearTextureFilters first, and remember you then lose the default mipmapping too. Filters are consulted at load time only. They affect LoadTexture, LoadAnimTexture, LoadBrush and textures pulled in by the mesh loaders; they do nothing to a texture already in memory, and nothing to CreateTexture. See also: ClearTextureFilters, LoadTexture, LoadAnimTexture, LoadMesh, LoadBrush. |
; TextureFilter Example
; ---------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
light=CreateLight()
RotateEntity light,45,45,0
; Load the chrome texture normally - no filter is active yet
plain_tex=LoadTexture("media/Chorme-2.BMP")
; Add a texture filter: from now on, any texture whose filename contains
; "Chorme" is loaded with flags 1+64 (color + spherical environment map)
TextureFilter "Chorme",1+64
; The same file again - this time the filter adds the sphere-map flag
env_tex=LoadTexture("media/Chorme-2.BMP")
; Two spheres side by side to compare the two loads
plain_ball=CreateSphere(24)
PositionEntity plain_ball,-1.5,0,5
EntityTexture plain_ball,plain_tex
env_ball=CreateSphere(24)
PositionEntity env_ball,1.5,0,5
EntityTexture env_ball,env_tex
While Not KeyDown(1)
TurnEntity plain_ball,0,1,0
TurnEntity env_ball,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,"Arrows: camera Esc: exit"
Text 0,20,"Left: loaded BEFORE the filter - plain texture"
Text 0,40,"Right: loaded AFTER TextureFilter Chorme,1+64 - sphere-mapped chrome"
Flip
Wend
End