Triangle not being drawn on GLFW window?


Title says it, here’s my code.


Without the shaders I can’t check your code completely, however a quick scan shows you have at least one error as you have the fourth parameter of glVertexAttribPointer as 0, when it should be the stride of your vertices, which in your case is sizeof(GLfloat)*3.

You have also not set any depth testing, triangle face culling nor are you setting the viewport and clearing the frame buffer.

For a look at a simple working example using GLFW and shaders see


Doug, 0 is a valid stride for glVertexAttribPointer. In case of “0” stride GL assumes data is tightly packed. In OP case it will calculate stride from second and third argument - 3 elements, each GL_FLOAT, so GL will use 3*sizeof(float) as stride.


Thanks @mmozeiko - you’re right, my mistake!