SetTexture

This function sets the material texture. If the texture is not NULL, this function will increment the texture reference count. If the previously set texture is not NULL, this function will decrement the previously set texture'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