videocontext
Version:
A WebGL & HTML5 graph based video composition library
102 lines (74 loc) • 3.83 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: ProcessingNodes/effectnode.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: ProcessingNodes/effectnode.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>//Matthew Shotton, R&D User Experience,© BBC 2015
import ProcessingNode from "./processingnode";
import { createElementTexutre } from "../utils.js";
class EffectNode extends ProcessingNode{
/**
* Initialise an instance of an EffectNode. You should not instantiate this directly, but use VideoContest.createEffectNode().
*/
constructor(gl, renderGraph, definition){
let placeholderTexture = createElementTexutre(gl);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]));
super(gl, renderGraph, definition, definition.inputs, true);
this._placeholderTexture = placeholderTexture;
this._displayName = "EffectNode";
}
_render(){
let gl = this._gl;
gl.bindFramebuffer(gl.FRAMEBUFFER, this._framebuffer);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._texture,0);
gl.clearColor(0, 0, 0, 0); // green;
gl.clear(gl.COLOR_BUFFER_BIT);
super._render();
let inputs = this._renderGraph.getInputsForNode(this);
let textureOffset = 0;
for (var i = 0; i < this._inputTextureUnitMapping.length; i++) {
let inputTexture = this._placeholderTexture;
let textureUnit = this._inputTextureUnitMapping[i].textureUnit;
let textureName = this._inputTextureUnitMapping[i].name;
if (i < inputs.length && inputs[i] !== undefined){
inputTexture = inputs[i]._texture;
}
gl.activeTexture(textureUnit);
let textureLocation = gl.getUniformLocation(this._program, textureName);
gl.uniform1i(textureLocation, this._parameterTextureCount + textureOffset);
textureOffset += 1;
gl.bindTexture(gl.TEXTURE_2D, inputTexture);
}
gl.drawArrays(gl.TRIANGLES, 0, 6);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
}
export default EffectNode;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-VideoContext.html">VideoContext</a></li></ul><h3>Classes</h3><ul><li><a href="CanvasNode.html">CanvasNode</a></li><li><a href="CompositingNode.html">CompositingNode</a></li><li><a href="DestinationNode.html">DestinationNode</a></li><li><a href="EffectNode.html">EffectNode</a></li><li><a href="GraphNode.html">GraphNode</a></li><li><a href="ImageNode.html">ImageNode</a></li><li><a href="module-VideoContext.html">VideoContext</a></li><li><a href="ProcessingNode.html">ProcessingNode</a></li><li><a href="RenderGraph.html">RenderGraph</a></li><li><a href="SourceNode.html">SourceNode</a></li><li><a href="TransitionNode.html">TransitionNode</a></li><li><a href="VideoNode.html">VideoNode</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>