SetMaterial

This function sets an entity's material.

Syntax

Parameters

Remarks

This function will increment the reference count of the new material and decrement the reference count of the old material (if they exist).

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
local light = DirectionalLight:Create()

--Create a material
local material = Material:Create()
material:SetColor(1,0,0)

--Create a model and apply the material to it
local model = Model:Sphere()
model:SetPosition(0,0,2)
model:SetMaterial(material)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()
context:Sync()
end