Also, there is no w component for normals. Normals will always be 3 elements each. The value 4 that you are passing for glNormalPointer is wrong too. That’s the stride, not the number of components. It should be 12. (3 floats * 4 bytes/float)
Using glVertexPointer(3, GL_FLOAT, 4, my_vertices) Is saying that you only have x,y,z (the first parameter is how many components) and as Nutty pointed out, sets the stride to 4. So unless you changed your vertices to not have a w, you should do this.
if you’re going to do matrix transformations yourself, you need the W component in both cases. (im using ogl for this, just reusing my matrix lib since i just started)
i see now what i missinterpreted, thanks for the heads up.
The byte offset between vertices on 4 floats, is 16. The reason you can put 0 in, is because of a tiny little extra feature of that function. If verts are tightly packed, you can put 0 in, and gl will automatically calculate the correct stride.
As I said, I personally prefer to specify it explicity.
I think alot of people get confused on this. They know it works with 0, so they think gl is measuring the byte difference between vert(n).z and vert(n+1).x When it’s not, it’s the difference between vert(n).x and vert(n+1).x
Nutty
P.S. Why do you need to specify the W component if you write your own matrix code?
that was exactly what i was confusing it with. and the wording in the msdn doc’s doesnt quite help (in my view): “The byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array”
the last part could be rewritten to cause less confusion.
anyway, why i need W? and so i can transform the vectors and vertices with the same matrix (and matrix function) and perform perspective correction.
thanks for the help, its all running perfectly now