i am writing a opengl based voxel engine voxel engine using java and lwjgl. i have followed
this tutorial and tried to update it's rendering method to modern opengl so i can use shaders. when i turned glVertexPointer into glVertexAttribPointer it displayed all the vertices correctly but when i did it for glTexCoordPointer the color stopped displaying.
here are the two rendering methods of the chunks (from the updated one and the old one)
public void Render() { //updated render method
GL30.glBindVertexArray(VAOHandle);
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL11.glDrawArrays(GL11.GL_QUADS, 0, CHUNK_SIZE * CHUNK_SIZE
* CHUNK_SIZE * 24);
GL20.glDisableVertexAttribArray(1);
GL20.glDisableVertexAttribArray(0);
GL30.glBindVertexArray(0);
}
public void Render() { //old render method
GL11.glPushMatrix();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOVertexHandle);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0L);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOColorHandle);
GL11.glColorPointer(3, GL11.GL_FLOAT, 0, 0L);
GL11.glDrawArrays(GL11.GL_QUADS, 0, CHUNK_SIZE * CHUNK_SIZE
* CHUNK_SIZE * 24);
GL11.glPopMatrix();
}
and here is the part where the date is loaded to the VAO/VBOs (the data is the same in both cases so i don't think i need to add it, but if needed i will):
// updated method
VAOHandle = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vaoID);
VBOColorHandle = GL15.glGenBuffers();
VBOVertexHandle = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOVertexHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexPositionData,
GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOColorHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorData, GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(1, 3, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL30.glBindVertexArray(0);
// old method
VBOColorHandle = GL15.glGenBuffers();
VBOVertexHandle = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOVertexHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexPositionData,
GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOColorHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorData,
GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
if anyone can figure out why the vertices are rendered but no color is applied i would be greatful, thanks in advance