# Triangle not being drawn on GLFW window?

**URL:** <https://discourse.glfw.org/t/triangle-not-being-drawn-on-glfw-window/808>\
**Category:** support\
**Created:** [November 22, 2016, 7:12am UTC](https://discourse.glfw.org/t/triangle-not-being-drawn-on-glfw-window/808 "2016-11-22T07:12:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MelonShooter](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@MelonShooter](https://discourse.glfw.org/u/MelonShooter)\
**Post date:** [November 22, 2016, 7:12am UTC](https://discourse.glfw.org/t/triangle-not-being-drawn-on-glfw-window/808/1 "2016-11-22T07:12:18Z")

</div>

Title says it, here’s my code.

[http://pastebin.com/i9VMra0n](http://pastebin.com/i9VMra0n)

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [November 22, 2016, 11:50am UTC](https://discourse.glfw.org/t/triangle-not-being-drawn-on-glfw-window/808/2 "2016-11-22T11:50:27Z")

</div>

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](https://www.opengl.org/sdk/docs/man4/html/glVertexAttribPointer.xhtml) 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](https://github.com/glfw/glfw/blob/master/examples/simple.c)

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [November 22, 2016, 6:44pm UTC](https://discourse.glfw.org/t/triangle-not-being-drawn-on-glfw-window/808/3 "2016-11-22T18:44:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [November 22, 2016, 7:03pm UTC](https://discourse.glfw.org/t/triangle-not-being-drawn-on-glfw-window/808/4 "2016-11-22T19:03:29Z")

</div>

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