Am 21.04.2012 23:49, schrieb Stephen Jones:
On Saturday, 21 April 2012 at 11:02:51 UTC, David wrote:
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);//is this
right casting a void pointer for 0 offset?


I do it like this: cast(void*)OFFSET; e.g.
cast(void*)12;

Thankyou David. Just to complete the code for those who follow: it works
if you change the above as follows:

glBufferData(GL_ARRAY_BUFFER, v.length * GL_FLOAT.sizeof, &v,
GL_STATIC_DRAW);

to:

glBufferData(GL_ARRAY_BUFFER, v.length * GL_FLOAT.sizeof, &v[0],
GL_STATIC_DRAW);


The null value in:

glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);

can be replaced with cast(void*)0 as David suggests, but the code runs
either way.

I don't quite understand the sizeof comment as writeln(GL_FLOAT.sizeof)
gives me 4 which is what I expect.

Although this is not the place for it, I would just like to plug Pelles
C ide:

http://my.opera.com/run3/blog/2012/02/09/d-programming-in-pelles-c

Simple to set up.
null is cast(void*)0, but sometimes you need differen offsets, that's why I showed you the cast(void*)-way.

GL_FLOAT is an alias to float, it's just a personal thing, that I like to use the type (not an alias) of the array directly (to make things clearer)

PS: &v[0] works, but you should use v.ptr, it is exactly what you want and it's the D-way.

Reply via email to