Follow the given steps:
ch_RenderingModes.html
in the HTML5 browser of your preference. This example follows the same structure as discussed in the previous section. initBuffer
function. renderingMode
variable defined at the top of the WebGL JS code (scroll up if you want to see where it is defined). drawScene
function. trapezoidIndexBuffer
with the following instruction:gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, trapezoidIndexBuffer);
you have a switch statement where there is a code that executes, depending on the value of the renderingMode
variable:
case 'TRIANGLES': { ... } case 'LINES': { ... } case'POINTS': { ... }
trapezoidIndexBuffer
) by using the bufferData
function. Finally, you call the drawElements
function.
Mode |
Example |
Description |
---|---|---|
|
|
When you use the
|
|
|
The For instance |
|
|
When we use the In this example, we will only render vertices number 1, number 2, and number 3 with |
|
|
|
|
|
It is similar to The |
|
|
If we have (0,1,2) , (1,2,3), and (2,3,4). |
|
|
In our example, will create the triangles: (0,1,2) and (0,3,4). |
ch_RenderingModes.html
) so that when you select the option TRIANGLES
, you render the trapezoid instead of two triangles. LINES
. LINE_LOOP
mode, draw only the boundary of the trapezoid.18.118.227.69