Published
Edited
Jun 26, 2020
Insert cell
Insert cell
canvas = html`<canvas width=640 height=480>`
Insert cell
Insert cell
picogl = require('picogl@0.17.3/build/picogl.min.js')
Insert cell
Insert cell
app = picogl.createApp(canvas)
.clearColor(0, 0, 0, 1);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
programMRT = app.createProgram(vertexShader, fragShaderMRT)
Insert cell
programBlend = app.createProgram(vertexShader, fragShaderBlend)
Insert cell
Insert cell
quadPositions = app.createVertexBuffer(picogl.FLOAT, 2, new Float32Array([
-1.0, 1.0,
-1.0, -1.0,
1.0, -1.0,
-1.0, 1.0,
1.0, -1.0,
1.0, 1.0
]))
Insert cell
triangPositions = app.createVertexBuffer(picogl.FLOAT, 2, new Float32Array([
-0.5, -0.5,
0.5, -0.5,
0.0, 0.5
]))
Insert cell
Insert cell
triangleArray = app.createVertexArray().vertexAttributeBuffer(0, triangPositions)
Insert cell
quadArray = app.createVertexArray().vertexAttributeBuffer(0,quadPositions)
Insert cell
Insert cell
frameBuffer = {
var colorTarget1 = app.createTexture2D(app.width, app.height);
var colorTarget2 = app.createTexture2D(app.width, app.height);
return app.createFramebuffer()
.colorTarget(0, colorTarget1)
.colorTarget(1, colorTarget2);
}
Insert cell
Insert cell
drawCallMRT = app.createDrawCall(programMRT, triangleArray)
Insert cell
drawCallBlend = app.createDrawCall(programBlend, quadArray)
.texture("texture1", frameBuffer.colorAttachments[0])
.texture("texture2", frameBuffer.colorAttachments[1])
Insert cell
Insert cell
drawMRT = {
app.drawFramebuffer(frameBuffer).clear();
drawCallMRT.draw();
}
Insert cell
Insert cell
drawBlend = {
app.defaultDrawFramebuffer().clear();
drawCallBlend.draw();
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more