SetShader

This function sets the material shader. If the shader is not NULL, this function will increment the shader reference count. If the previously set shader is not NULL, this function will decrement the previously set shader's reference count.

Syntax

Parameters

Example

window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
directionallight = DirectionalLight:Create()
directionallight:SetRotation(45,35,0)

--Create a material
local material = Material:Create()

--Load and apply a texture
local texture = Texture:Load("Materials/Grass/grass01.tex")
material:SetTexture(texture)
texture:Release()

--Load and apply a shader
local shader = Shader:Load("Shaders/Drawing/blitcolor.shader")
material:SetShader(shader)
shader:Release()

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

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end
Time:Update()
world:Update()
world:Render()
context:Sync()
end