StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
4 years ago
|
"use strict"
|
||
|
|
||
|
function doBind(gl, elements, attributes) {
|
||
|
if(elements) {
|
||
|
elements.bind()
|
||
|
} else {
|
||
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null)
|
||
|
}
|
||
|
var nattribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS)|0
|
||
|
if(attributes) {
|
||
|
if(attributes.length > nattribs) {
|
||
|
throw new Error("gl-vao: Too many vertex attributes")
|
||
|
}
|
||
|
for(var i=0; i<attributes.length; ++i) {
|
||
|
var attrib = attributes[i]
|
||
|
if(attrib.buffer) {
|
||
|
var buffer = attrib.buffer
|
||
|
var size = attrib.size || 4
|
||
|
var type = attrib.type || gl.FLOAT
|
||
|
var normalized = !!attrib.normalized
|
||
|
var stride = attrib.stride || 0
|
||
|
var offset = attrib.offset || 0
|
||
|
buffer.bind()
|
||
|
gl.enableVertexAttribArray(i)
|
||
|
gl.vertexAttribPointer(i, size, type, normalized, stride, offset)
|
||
|
} else {
|
||
|
if(typeof attrib === "number") {
|
||
|
gl.vertexAttrib1f(i, attrib)
|
||
|
} else if(attrib.length === 1) {
|
||
|
gl.vertexAttrib1f(i, attrib[0])
|
||
|
} else if(attrib.length === 2) {
|
||
|
gl.vertexAttrib2f(i, attrib[0], attrib[1])
|
||
|
} else if(attrib.length === 3) {
|
||
|
gl.vertexAttrib3f(i, attrib[0], attrib[1], attrib[2])
|
||
|
} else if(attrib.length === 4) {
|
||
|
gl.vertexAttrib4f(i, attrib[0], attrib[1], attrib[2], attrib[3])
|
||
|
} else {
|
||
|
throw new Error("gl-vao: Invalid vertex attribute")
|
||
|
}
|
||
|
gl.disableVertexAttribArray(i)
|
||
|
}
|
||
|
}
|
||
|
for(; i<nattribs; ++i) {
|
||
|
gl.disableVertexAttribArray(i)
|
||
|
}
|
||
|
} else {
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, null)
|
||
|
for(var i=0; i<nattribs; ++i) {
|
||
|
gl.disableVertexAttribArray(i)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = doBind
|