Comparing version 0.5.0 to 0.5.1
@@ -0,1 +1,7 @@ | ||
### 0.5.1 (2021-03-26) | ||
*New:* | ||
- Added usage of the `OES_vertex_array_object` extension for improved drawing performance. | ||
### 0.5.0 (2021-03-04) | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "kampos", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Tiny and fast effects compositor on WebGL", | ||
@@ -5,0 +5,0 @@ "registry": "https://registry.npmjs.org/", |
@@ -205,3 +205,3 @@ export default { | ||
function draw (gl, media, data, dimensions) { | ||
const {program, source, attributes, uniforms, textures} = data; | ||
const {program, source, attributes, uniforms, textures, extensions, vao} = data; | ||
@@ -219,4 +219,9 @@ if ( media && source && source.texture ) { | ||
// set attribute buffers with data | ||
_enableVertexAttributes(gl, attributes); | ||
if ( vao ) { | ||
extensions.vao.bindVertexArrayOES(vao); | ||
} | ||
else { | ||
// set attribute buffers with data | ||
_enableVertexAttributes(gl, attributes); | ||
} | ||
@@ -259,3 +264,3 @@ // set uniforms with data | ||
function destroy (gl, data) { | ||
const {program, vertexShader, fragmentShader, source, attributes} = data; | ||
const {program, vertexShader, fragmentShader, source, attributes, extensions, vao} = data; | ||
@@ -265,2 +270,5 @@ // delete buffers | ||
if ( vao ) | ||
extensions.vao.deleteVertexArrayOES(vao); | ||
// delete texture | ||
@@ -301,5 +309,20 @@ if ( source && source.texture ) | ||
let vaoExt, vao; | ||
try { | ||
vaoExt = gl.getExtension('OES_vertex_array_object'); | ||
vao = vaoExt.createVertexArrayOES(); | ||
vaoExt.bindVertexArrayOES(vao); | ||
} | ||
catch (e) { | ||
// ignore | ||
} | ||
// setup the vertex data | ||
const attributes = _initVertexAttributes(gl, program, data.attributes); | ||
if ( vao ) { | ||
_enableVertexAttributes(gl, attributes); | ||
vaoExt.bindVertexArrayOES(null); | ||
} | ||
// setup uniforms | ||
@@ -309,2 +332,5 @@ const uniforms = _initUniforms(gl, program, data.uniforms); | ||
return { | ||
extensions: { | ||
vao: vaoExt | ||
}, | ||
program, | ||
@@ -316,3 +342,4 @@ vertexShader, | ||
uniforms, | ||
textures: data.textures | ||
textures: data.textures, | ||
vao | ||
}; | ||
@@ -607,2 +634,3 @@ } | ||
* @property {WebGLProgram} program | ||
* @property {{vao: OES_vertex_array_object?}} extensions | ||
* @property {WebGLShader} vertexShader | ||
@@ -612,2 +640,3 @@ * @property {WebGLShader} fragmentShader | ||
* @property {kamposAttribute[]} attributes | ||
* @property {WebGLVertexArrayObjectOES} [vao] | ||
* | ||
@@ -614,0 +643,0 @@ * @typedef {Object} kamposTarget |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
15518670
19469