ShaderCompile

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 21:28, 30 September 2014 by Vis apiuser (talk) (Created page with "==shaderCompile== <div class="command-min-version-info">Available since: <span class="command-min-version">v4.0</span></div> <div class="command-doc">Compile shader</div> L...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

shaderCompile

Available since: v4.0
Compile shader

Lua Syntax:

shaderCompile(vsh, fsh)

Arguments

vsh

"string" - vertex shader

fsh

"string" - fragment shader

Flags

Return Values

None.

Examples

Example 1: minimal shader

shader = {_temporary_=0, num = shaderCompile([[#ifdef GL_ES 
precision lowp float; 
precision lowp int; 
#endif 
varying vec2 texcoord; 
uniform mat4 mvp_mat; 
attribute vec2 position; 
attribute vec2 uv; 
uniform int pass; 
void main () 
{ 
  gl_Position = mvp_mat * vec4(position.x,position.y,0.0,1.0); 
  texcoord = uv; 
}]],[[#ifdef GL_ES 
precision highp float; 
precision lowp  int; 
#endif 

uniform sampler2D composite;
uniform int pass;
varying vec2 texcoord;
  
void main() {
  gl_FragColor = texture2D(composite, texcoord.st);
}
]])}
shaderSetOptions("active",shader.num)