Material System
Cache and manage materials efficiently.
cLib.AddMaterial
Register a material for caching.
cLib.AddMaterial(matID, path, pngParams)Parameters:
| Parameter | Type | Description |
|---|---|---|
matID | string | Unique identifier |
path | string | Path relative to materials/ |
pngParams | string | Optional PNG parameters |
-- Register materials
cLib.AddMaterial("MyAddon.Logo", "myaddon/logo.png", "smooth")
cLib.AddMaterial("MyAddon.Background", "myaddon/bg.png")
cLib.AddMaterial("MyAddon.Icon", "myaddon/icon.png", "smooth mips")cLib.GetMaterial
Retrieve a cached material (client-side only).
local mat = cLib.GetMaterial(matID)Example:
-- Draw material
local logo = cLib.GetMaterial("MyAddon.Logo")
function PANEL:Paint(w, h)
surface.SetDrawColor(255, 255, 255)
surface.SetMaterial(logo)
surface.DrawTexturedRect(10, 10, 64, 64)
endBuilt-in Materials
cLib.GetMaterial("uparrow") -- Arrow up icon
cLib.GetMaterial("downarrow") -- Arrow down iconPNG Parameters
| Parameter | Description |
|---|---|
smooth | Smooth/bilinear filtering |
mips | Generate mipmaps |
noclamp | Don't clamp texture |
alphatest | Alpha testing |
cLib.AddMaterial("icon", "path/icon.png", "smooth mips")