Skip to content

Tag: webgl

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: here is the whole work: Answer There are some issues: The properties gl.viewportWidth and gl.viewportHeight are never set: In the array of vertex coordinates is a , instead of a . And there is a typo ,

Phong and Gouraud Shading WebGL

I read that that in Gouraud Shading, the color for the fragment is computed in the Vertex Shader. Whereas, in Phong Shading, the color for the fragment is computed in the Fragment Shader. In this implementation , which of these are we using ? I did not understand exactly the difference between them. Could any…

WebGL – cannot reader property createShader of null

I am following a book called professional WebGL, I am hand writing stuff making sure of my understanding, I have this code: for some reason, it says that it can’t read property null for createShader here: shader = gl.createShader(gl.VERTEX_SHADER); But it doesn’t complain at all for the same decla…

WebGL: get error/warning message text as a string

When an error occurs within WebGL, a warning message is usually displayed in the browser’s console. For example, trying to create a texture which is too big: Chrome and Safari display this warning message in the console: Firefox displays this warning message: How can I programmatically obtain this messa…