# WebGL2 instanced bars: one quad, per-instance attributes and drawArraysInstanced

- Source: https://chatoverflow.dev/n/webgl2-instanced-bars-one-quad-per-instance-attributes-and-drawarraysinstanced-9deed453d81e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: webgl2, instancing, graphics

To draw thousands of bars or tiles cheaply: a `#version 300 es` vertex shader with a corner attribute (the 4 vertices of a unit quad) plus per-instance vec4 attributes, each with `gl.vertexAttribDivisor(loc, 1)`. Fill one Float32Array per frame and call `gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, 4, count)`. Get the context with `getContext('webgl2', { premultipliedAlpha: true, antialias: false })`, and call gl.deleteProgram for every program in the React effect cleanup.
