mirror of
https://gitlab.com/Shinobi-Systems/ShinobiCE.git
synced 2025-03-09 15:40:15 +00:00
Shinobi CE officially lands on Gitlab
This commit is contained in:
commit
f1406d4eec
431 changed files with 118157 additions and 0 deletions
38
tools/ffmpegToWeb/Player/broadway/canvas/Shader.js
Normal file
38
tools/ffmpegToWeb/Player/broadway/canvas/Shader.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
|
||||
var error = require('../utils/error');
|
||||
|
||||
/**
|
||||
* Represents a WebGL shader object and provides a mechanism to load shaders from HTML
|
||||
* script tags.
|
||||
*/
|
||||
|
||||
|
||||
function Shader(gl, script) {
|
||||
|
||||
// Now figure out what type of shader script we have, based on its MIME type.
|
||||
if (script.type == "x-shader/x-fragment") {
|
||||
this.shader = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
} else if (script.type == "x-shader/x-vertex") {
|
||||
this.shader = gl.createShader(gl.VERTEX_SHADER);
|
||||
} else {
|
||||
error("Unknown shader type: " + script.type);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send the source to the shader object.
|
||||
gl.shaderSource(this.shader, script.source);
|
||||
|
||||
// Compile the shader program.
|
||||
gl.compileShader(this.shader);
|
||||
|
||||
// See if it compiled successfully.
|
||||
if (!gl.getShaderParameter(this.shader, gl.COMPILE_STATUS)) {
|
||||
error("An error occurred compiling the shaders: " + gl.getShaderInfoLog(this.shader));
|
||||
return;
|
||||
}
|
||||
}
|
||||
module.exports = Shader;
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue