Difference between revisions of "Shader:setConstant"
From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>") |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | '''Available since:''' Gideros 2015.06.30<br/> | |
− | ''' | + | '''Class:''' [[Shader]]<br/> |
− | ''' | + | |
− | === | + | === Description === |
− | + | Changes the value of a uniform from Lua code. | |
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
− | + | Shader:setConstant(uniformName,dataType,mult,data) | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === Parameters === |
− | '''uniformName''': (string) | + | '''uniformName''': (string) the uniform name to change<br/> |
− | '''dataType''': (int) | + | '''dataType''': (int) the type of data to set (one of the Shader.Cxxx constants)<br/> |
− | '''mult''': (number) | + | '''mult''': (number) number of elements of the given type to set<br/> |
− | '''data''': (varies) | + | '''data''': (varies) and the actual data to set, either as a table or as multiple arguments<br/> |
+ | |||
+ | === Example === | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | -- loop | ||
+ | local timer = 0 | ||
+ | stage:addEventListener(Event.ENTER_FRAME, function(e) | ||
+ | timer += 0.018 | ||
+ | shaderwave:setConstant("time", Shader.CFLOAT, 1, timer) | ||
+ | bitmap:setX(bitmap:getX() + 1) | ||
+ | if bitmap:getX() > 400 then bitmap:setX(-80) end | ||
+ | end) | ||
+ | </syntaxhighlight> | ||
{{Shader}} | {{Shader}} |
Revision as of 23:37, 3 November 2023
Available since: Gideros 2015.06.30
Class: Shader
Description
Changes the value of a uniform from Lua code.
Shader:setConstant(uniformName,dataType,mult,data)
Parameters
uniformName: (string) the uniform name to change
dataType: (int) the type of data to set (one of the Shader.Cxxx constants)
mult: (number) number of elements of the given type to set
data: (varies) and the actual data to set, either as a table or as multiple arguments
Example
-- loop
local timer = 0
stage:addEventListener(Event.ENTER_FRAME, function(e)
timer += 0.018
shaderwave:setConstant("time", Shader.CFLOAT, 1, timer)
bitmap:setX(bitmap:getX() + 1)
if bitmap:getX() > 400 then bitmap:setX(-80) end
end)