Triangle not being drawn on GLFW window?


#1

Title says it, here’s my code.

http://pastebin.com/i9VMra0n


#2

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 https://github.com/glfw/glfw/blob/master/examples/simple.c


#3

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.


#4

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