DarkAngel wrote:
It would be best to re-align (un-align?) the data before packing into a VBO. Anything that puts data into a VBO would need an "Aligned Vec4 to Unaligned Vec3/4" conversion function.
I'm not sure alignment is an issue in VBO. I'm quite sure however that the way vector data is handled is one since the offset/stride used in egRenderer.cpp do not take structure size into account but instead make the (unsafe) assumption that the compiler will gently pack the data the way the it is declared and it does not even bother checking the size of Vec3 and make the (even more unsafe) assumption that it will be that of three floats. So anyone with knoweldge of the internals should be able to solve this using a couple of sizeof().
Now of course it would be possible to convert the data when sending it to (or redinig it from) the GPU but it would probably end up wasting a lot of cycles with no obvious advantage.
edit : I may have fixed it at last. I'll do some more tests and keep you informed.
In egRenderer.cpp somewhere around line 1630 modify the code to look like that (no addition/deletion, just some parameter changes)
Code:
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3f), (char *)0 + vertCount * sizeof(Vec3f) );
glVertexAttribPointer( 2, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3f), (char *)0 + vertCount * sizeof(Vec3f) * 2 );
glVertexAttribPointer( 3, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3f), (char *)0 + vertCount * sizeof(Vec3f) * 3 );
glVertexAttribPointer( 4, 4, GL_FLOAT, GL_FALSE,
sizeof( VertexDataStatic ), (char *)0 + vertCount * sizeof(Vec3f) * 4 + 8 );
glVertexAttribPointer( 5, 4, GL_FLOAT, GL_FALSE,
sizeof( VertexDataStatic ), (char *)0 + vertCount * sizeof(Vec3f) * 4 + 24 );
glVertexAttribPointer( 6, 2, GL_FLOAT, GL_FALSE,
sizeof( VertexDataStatic ), (char *)0 + vertCount * sizeof(Vec3f) * 4 );
glVertexAttribPointer( 7, 2, GL_FLOAT, GL_FALSE,
sizeof( VertexDataStatic ), (char *)0 + vertCount * sizeof(Vec3f) * 4 + 40 );
At least it now runs fine with a Vec3f having four float fields. I'll see if alignment break things.
edit 2 : alignment is not a concern apparently but regardless particule rendering is broken and I have troubles figuring out how to fix that (looks like glUniform does not take a stride argument
) any hints?