Skip to content
Advertisement

webgl trying to draw a triangle

I have been trying to draw a triangle but it is not showing up on the canvas

here is my draw function code:

JavaScript

here is the whole work:

JavaScript
JavaScript

Advertisement

Answer

There are some issues:

The properties gl.viewportWidth and gl.viewportHeight are never set:

JavaScript

In the array of vertex coordinates is a , instead of a .

JavaScript

And there is a typo , you wrote vertextPositionAttribute instead of vertexPositionAttribute, when you get the attribute index:

JavaScript

But in general your code works:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement