drawBuffers method
dynamic
drawBuffers(
- dynamic renderTarget,
- dynamic framebuffer
Implementation
drawBuffers(renderTarget, framebuffer) {
dynamic drawBuffers = defaultDrawbuffers;
var needsUpdate = false;
if (renderTarget != null) {
drawBuffers = currentDrawbuffers.get(framebuffer);
if (drawBuffers == null) {
drawBuffers = [];
currentDrawbuffers.set(framebuffer, drawBuffers);
}
if (renderTarget.isWebGLMultipleRenderTargets) {
var textures = renderTarget.texture;
if (drawBuffers.length != textures.length ||
drawBuffers[0] != gl.COLOR_ATTACHMENT0) {
for (var i = 0, il = textures.length; i < il; i++) {
drawBuffers[i] = gl.COLOR_ATTACHMENT0 + i;
}
drawBuffers.length = textures.length;
needsUpdate = true;
}
} else {
if (drawBuffers.length == 0 || drawBuffers[0] != gl.COLOR_ATTACHMENT0) {
if (drawBuffers.length == 0) {
drawBuffers.add(gl.COLOR_ATTACHMENT0);
} else {
drawBuffers[0] = gl.COLOR_ATTACHMENT0;
}
drawBuffers.length = 1;
needsUpdate = true;
}
}
} else {
if (drawBuffers.length == 0 || drawBuffers[0] != gl.BACK) {
if (drawBuffers.length == 0) {
drawBuffers.add(gl.BACK);
} else {
drawBuffers[0] = gl.BACK;
}
drawBuffers.length = 1;
needsUpdate = true;
}
}
if (needsUpdate) {
if (capabilities.isWebGL2) {
gl.drawBuffers(List<int>.from(drawBuffers));
} else {
extensions
.get('WEBGL_draw_buffers')
.drawBuffersWEBGL(List<int>.from(drawBuffers));
}
}
}