digitalmars.D.learn - No triangle with OpenGL (DerelictGLFW and DerelictGL3)
- Peter Lewis (9/9) Jun 11 2016 Hi all.
- Joerg Joergonson (7/16) Jun 11 2016 I had similar issues when I tried it and never got it to work
- Mike Parker (20/29) Jun 11 2016 Your problem is this line:
- Peter Lewis (2/8) Jun 11 2016 Thank you very much. You are right, that fixed my issue
Hi all. I am trying to create a basic OpenGL triangle in a GLFW instance. The window works, I can change the background colour and everything but for the life of me I can't get the triangle to show up. Instead of trying to put everything in the post, I have put it on github. (https://github.com/werl/d_glfw_tests) I am currently following a tutorial I found Any help is appreciated, Thanks!
Jun 11 2016
On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote:Hi all. I am trying to create a basic OpenGL triangle in a GLFW instance. The window works, I can change the background colour and everything but for the life of me I can't get the triangle to show up. Instead of trying to put everything in the post, I have put it on github. (https://github.com/werl/d_glfw_tests) I am currently following a tutorial I found Any help is appreciated, Thanks!I had similar issues when I tried it and never got it to work either. Try Adam Druppe's stuff on github. It works and he has some support for images and stuff. It's not perfect but at least it works out of the box compared to alot of the other stuff floating around that mostly is outdated.
Jun 11 2016
On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote:Hi all. I am trying to create a basic OpenGL triangle in a GLFW instance. The window works, I can change the background colour and everything but for the life of me I can't get the triangle to show up. Instead of trying to put everything in the post, I have put it on github. (https://github.com/werl/d_glfw_tests) I am currently following a tutorial I found Any help is appreciated, Thanks!Your problem is this line: glBufferData(GL_ARRAY_BUFFER, verts.sizeof, &verts, GL_STATIC_DRAW); First, the array declarations in the example C code create static arrays. Calling sizeof(array) on a static array in C will give you the combined size of all the elements. For a dynamic array, it will give you the size of a pointer. The same is true in D, but there's a difference in the declaration syntax. float[9] foo; is a static array, but float[] bar; is *always* a dynamic array. foo.size of will give you 36. bar.size of will give you 8 in 32-bit and 16 in 64-bit, because its giving you the size of the length and pointer that make up the array itself, not of the contents. Second, &verts is giving you a pointer to the array itself (i.e. the length and pointer pair) and *not* the contents. D arrays are not C arrays! With the two changes below, your triangle renders fine. glBufferData(GL_ARRAY_BUFFER, verts.length * float.sizeof, verts.ptr, GL_STATIC_DRAW);
Jun 11 2016
On Sunday, 12 June 2016 at 03:46:31 UTC, Mike Parker wrote:On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote:Thank you very much. You are right, that fixed my issue[...]Your problem is this line: glBufferData(GL_ARRAY_BUFFER, verts.sizeof, &verts, GL_STATIC_DRAW); [...]
Jun 11 2016