Re: Converting (casting?) a dynamic array to a fixed array?

2015-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 May 2015 at 02:47:24 UTC, WhatMeWorry wrote: glBufferData(GL_ARRAY_BUFFER, verts.sizeof, &verts, GL_STATIC_DRAW); Try (GL_ARRAY_BUFFER, verts.length, verts.ptr, GL_STATIC_DRAW) or maybe: (GL_ARRAY_BUFFER, verts.length * verts[0].sizeof, verts.ptr, GL_STATIC_DRAW) I'm

Re: Converting (casting?) a dynamic array to a fixed array?

2015-05-03 Thread rsw0x via Digitalmars-d-learn
On Monday, 4 May 2015 at 02:47:24 UTC, WhatMeWorry wrote: This following code works fine. A triangle is displayed. GLfloat[6] verts = [ 0.0, 1.0, -1.0, -1.0, 1.0, -1.0 ]; glGenBuffers(1, &vbo); glBindBuffer(GL_

Re: Converting (casting?) a dynamic array to a fixed array?

2015-05-04 Thread WhatMeWorry via Digitalmars-d-learn
Many thanks. Just to recap, I got the code working with: glBufferData(GL_ARRAY_BUFFER, (verts.sizeof * verts.length), verts.ptr, GL_STATIC_DRAW); sizeof on a slice doesn't do what you think it does, it returns the size of the actual slice object I believe. I have to admit that I didn't und

Re: Converting (casting?) a dynamic array to a fixed array?

2015-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 05/04/2015 08:36 AM, WhatMeWorry wrote: > But just for arguments sake, wouldn't it have > been better to define in dynamic array properties a .sizeofref and a > .sizeof (which behaves like the static array.sizeof)? It would not work because 1) .sizeof means the size of the variable that a pi