GLSLProgram
Object for working with GL program.
Can be created using method new:
Lib.Media.Display3D.Shaders.GLSL.GLSLProgram.new(context3D) |
creates GLSL program |
context3D - Context3D object |
created program object has methods:
upload(vertexShader, fragmentShader) |
upload shaders to GLSL program |
vertexShader - GLSLVertexShader object fragmentShader - GLSLFragmentShader object |
dispose() |
dispose GLSL program |
|
Examples:
Display3D = Lib.Media.Display3D
stage = Lib.Media.Display.stage
stage3D = stage.stage3Ds[1]
stage3D.addEventListener(Lib.Media.Events.Event.CONTEXT3D_CREATE,
function(e)
print("Context 3D created")
context3D = stage3D.context3D
context3D.configureBackBuffer(stage.stageWidth, stage.stageHeight, 0, false)
context3D.enableErrorChecking = true
glslProgram = Display3D.Shaders.GLSL.GLSLProgram.new(context3D)
local vertexShaderSource = [[
attribute vec3 vertexPosition;
uniform mat4 mvpMatrix;
void main(void) {
gl_Position = mvpMatrix * vec4(vertexPosition, 1.0);
}
]]
local vertexShader = Display3D.Shaders.GLSL.GLSLVertexShader.new(vertexShaderSource, nil)
local fragmentShaderSource = [[
void main(void) {
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
]]
local fragmentShader = Display3D.Shaders.GLSL.GLSLFragmentShader.new(fragmentShaderSource, nil)
glslProgram.upload(vertexShader, fragmentShader)
end, false, 0, false)
stage3D.requestContext3D("")
Created with the Personal Edition of HelpNDoc: Free EPub producer