Here's the code I'm working with:
glEnableVertexAttribArray(0); //vertices glEnableVertexAttribArray(1); //normals glBindAttribLocation(prog, 0, "v_position"); //bind this var to 0 glBindAttribLocation(prog, 1, "v_normal"); //bind this var to 1 //generate buffers GLuint vbuf_id[2],ibuf_id[2]; glGenBuffers(2, vbuf_id); //vertex buffers glGenBuffers(2, ibuf_id); //index buffers //create and bind buffer for vertices glBindBuffer(GL_ARRAY_BUFFER, vbuf_id[0]); //vertex buffer glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glBindBuffer(GL_ARRAY_BUFFER,0); //unbind //create and bind another buffer for normals glBindBuffer(GL_ARRAY_BUFFER, vbuf_id[1]); //normal buffer glBufferData(GL_ARRAY_BUFFER, sizeof(normals), normals, GL_STATIC_DRAW); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glBindBuffer(GL_ARRAY_BUFFER,0); //unbind //create IBO (index buffer) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibuf_id[0]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(index), index, GL_STATIC_DRAW);
Which works great for vertices, using the supplied index. However, since the index only references the vertices, how do I include the normals? I have a list of normals from a COLLADA file, but I can't seem to get the vertex shader to process them correctly. I also had to remove the normals entries from the index because OpenGL wouldn't work if I included them. Apparently, the GL_ELEMENT_ARRAY_BUFFER wants packed entries for vertices ONLY.
What am I doing wrong? I'm happy to supply any additional information that may help.







