WebGL : Draw Modes

In WebGL, you have to specify the mode to be used by the drawing API. Modes are defined as constants and you can access it using WebGL context.

1
2
3
4
webGL = this.canvas.getContext('webgl');
webGL.draw(webGL, webGL.TRIANGLES, 10);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In the working example given below you can try changing the mode and see the difference

1
2
<!-- Target canvas -->
<canvas id="expCanvas" width="480" height="480"> </canvas>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
#expCanvas{
/*border: 1px solid #000;*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
/**
* @author diode / https://vipin.link
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Share

Output