Multiple Programs and Regions
Scissor Test
A scissor rectangle limits which framebuffer pixels can be changed while it is enabled.
Program
The scissor test is a simple rectangular mask. It is useful for UI panes, partial clears, and region-limited rendering.
scissor_test.html
Visuals: generated teaching cards from captured state
- state written by this keyframe
1<canvas id="stage" width="360" height="210"></canvas>
2<script>
3 gl.enable(gl.SCISSOR_TEST);
4 gl.scissor(48, 36, 264, 138);
5 gl.clearColor(0.08, 0.72, 0.64, 1.0);
6 gl.clear(gl.COLOR_BUFFER_BIT);
7 gl.disable(gl.SCISSOR_TEST);
8</script>Enable scissor testing
kf: 1event 0kind: lifecycleEnable scissor testing.
3gl.enable→ enabled(gl.SCISSOR_TEST);
The test applies to clear and draw commands while enabled. State after this keyframedisabled → enabledscissor testDefine the rectangular pixel box
kf: 2event 1kind: lifecycleDefine the rectangular pixel box.
4gl.scissor→ 264 x 138(48, 36, 264, 138);
Scissor coordinates are pixel-space drawing-buffer coordinates. State after this keyframeunset → 264 x 138scissor boxChoose the clipped clear color
kf: 3event 2kind: lifecycleChoose the clipped clear color.
5gl.clearColor→ teal(0.08, 0.72, 0.64, 1.0);
clearColor stores state for the next clear call. State after this keyframedark blue → tealclear colorClear only inside the scissor box
kf: 4event 3kind: lifecycleClear only inside the scissor box.
6gl.clear→ clipped teal rectangle(gl.COLOR_BUFFER_BIT);
With SCISSOR_TEST enabled, clear updates only pixels inside the box. State after this keyframedark blue → clipped teal rectanglepixelsDisable scissor testing for later work
kf: 5event 4kind: lifecycleDisable scissor testing for later work.
7gl.disable→ disabled(gl.SCISSOR_TEST);
Disabling state affects later commands, not pixels already written. State after this keyframeenabled → disabledscissor test
scissor test
The scissor test rejects fragments and clear writes outside a rectangular pixel box.
partial clear
A partial clear updates only a selected framebuffer region.