ShaderBlock:getShaderCode

Before a ShaderBlock can be used in a Shader, the Shader has to have the block's variables defined in its source code. This can be a tedious process, so you can call this function to return a GLSL string that contains this definition. Roughly, it will look something like this:

uniform <label> {
  <type> <name>[<count>];
};
code = ShaderBlock:getShaderCode(label)

Arguments

NameTypeDescription
labelstringThe label of the block in the shader code. This will be used to identify it when using Shader:sendBlock.

Returns

NameTypeDescription
codestringThe code that can be prepended to a Shader.

Example

lovr.graphics.newShader(
  block:getShaderCode() .. [[
  // The rest of the shader here
  ]]
)

See also