Hi, i try to make a Voxel Engine.
I have a VAO that have a VBO. In this are the vertex and the normals of the Cubes.
vaoId = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vaoId);
ByteBuffer verticesBuffer = BufferUtils.createByteBuffer(numberOfVerices * 6);
verticesBuffer.put(verticesAndNormals, 0, numberOfVerices);
verticesBuffer.flip();
vboId = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_DYNAMIC_DRAW);
GL20.glVertexAttribPointer(0, 3, GL11.GL_BYTE, false, 6, 0); // vertex
GL20.glVertexAttribPointer(1, 3, GL11.GL_BYTE, false, 6, 3); // normals
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL30.glBindVertexArray(0);
I can render the cubes like this:
GL30.glBindVertexArray(vaoId);
GL20.glEnableVertexAttribArray(0);
GL11.glDrawArrays(GL11.GL_QUADS, 0, vertexCount);
GL20.glDisableVertexAttribArray(0);
GL30.glBindVertexArray(0);
But how can I say OpenGL that, the second VBO includes the normals?
And is this the right way to render my Cubes? Or is there a better?