If I have a buffer with my vertices, normals and texture coordinates, and I use glDrawArrays to draw the VBO to the screen, how can I send attributes per vertex that I placed in an array to the shader program? I'm making a voxel terrain, and every chunk is 1 VBO, this works all great, but I want to send the light value of each block (Just an array filled with int's) to the shader as well, how would I do that?
Edit: After reading some comments, here some clarification: I'm trying to avoid the deprecated glVertexPointer etc, so I'm using Vertex Arrays. Here is the layout of my vertex array:
X, Y, Z, NX, NY, NZ, X, Y, Z, NX, NY, NZ,X, Y, Z, NX, NY, NZ
I'm using this to draw it: (ofcourse with the array buffer bound)
glVertexAttribPointer(0, 3, GL_FLOAT, false, 12, 0); glVertexAttribPointer(1, 3, GL_FLOAT, false, 12, 12); glDrawArrays(GL_TRIANGLES, 0, arraySize / 6);
However I get some weird shapes on my screen. Apart from the light problem, that is essentially the same thing, I don't get why this doesn't just work. When I remove the normals, and use just 1 vertexattribpointer it works fine. Yes, the attributes are bound to in_position and in_normal, and the vertex shader is nothing more than gl_Position = gl_ModelViewProjectionMatrix * vec4(in_position, 1.0);
This is what I get:
(This are 6X6 chunks, so this code is called 6*6 times.)