Well, this is embarrasing, when we’ve finally got it rendering, it’s rendering too much!. Well sorta.
This picture is of a chunk size of 4. I’ve removed the left and right sides to make it more visible. Inside you see a weird almost cubish object. Where does it come from? I don’t know.
But what I do know is, it appears in 1, 2, 4, 8 and maybe more chunk size, in 16 I cannot find it. And, as I approtch it I drop from 999 to 4 fps.
help please!?
Some code!
Chunk.java
private void rebuildVBO() {
FloatBuffer vCoords = BufferUtils.createFloatBuffer(size * size * size * (3 * 4 * 6));
FloatBuffer cCoords = BufferUtils.createFloatBuffer(size * size * size * (4 * 4 * 6));
for(int x = 0; x < size; x++) {
for(int y = 0; y < size; y++) {
for(int z = 0; z < size; z++) {
vCoords.put(Shape.createCubeVerticies(x, y, z, 1f));
cCoords.put(Shape.getCubeColors());
}
}
}
vCoords.flip();
cCoords.flip();
glBindBuffer(GL_ARRAY_BUFFER, vId);
glBufferData(GL_ARRAY_BUFFER, vCoords, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, cId);
glBufferData(GL_ARRAY_BUFFER, cCoords, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Shape.java
public static float[] createCubeVerticies(float x, float y, float z, float size) {
size = size / 2;
return new float[] {x + size, y + size, z - size, // Top Right Of The Quad (Top)
x - size, y + size, z - size, // Top Left Of The Quad (Top)
x - size, y + size, z + size, // Bottom Left Of The Quad (Top)
x + size, y + size, z + size, // Bottom Right Of The Quad (Top)
x + size, y - size, z + size, // Top Right Of The Quad (Bottom)
x - size, y - size, z + size, // Top Left Of The Quad (Bottom)
x - size, y - size, z - size, // Bottom Left Of The Quad (Bottom)
x + size, y - size, z - size, // Bottom Right Of The Quad (Bottom)
x + size, y + size, z + size, // Top Right Of The Quad (Front)
x - size, y + size, z + size, // Top Left Of The Quad (Front)
x - size, y - size, z + size, // Bottom Left Of The Quad (Front)
x + size, y - size, z + size, // Bottom Right Of The Quad (Front)
x + size, y - size, z - size, // Bottom Left Of The Quad (Back)
x - size, y - size, z - size, // Bottom Right Of The Quad (Back)
x - size, y + size, z - size, // Top Right Of The Quad (Back)
x + size, y + size, z - size, // Top Left Of The Quad (Back)
};
}
private static Random ran = new Random();
public static float[] getCubeColors() {
float r1 = 1f;
float b1 = 0f;
float g1 = 0f;
float r2 = 1f;
float b2 = 1f;
float g2 = 0f;
float r3 = 1f;
float b3 = 1f;
float g3 = 1f;
float r4 = 0f;
float b4 = 1f;
float g4 = 1f;
float r5 = 0f;
float b5 = 0f;
float g5 = 1f;
float r6 = 1f;
float b6 = 0f;
float g6 = 1f;
return new float[] {
r1, b1, g1, 1,
r1, b1, g1, 1,
r1, b1, g1, 1,
r1, b1, g1, 1,
r2, b2, g2, 1,
r2, b2, g2, 1,
r2, b2, g2, 1,
r2, b2, g2, 1,
r3, b3, g3, 1,
r3, b3, g3, 1,
r3, b3, g3, 1,
r3, b3, g3, 1,
r4, b4, g4, 1,
r4, b4, g4, 1,
r4, b4, g4, 1,
r4, b4, g4, 1,
r5, b5, g5, 1,
r5, b5, g5, 1,
r5, b5, g5, 1,
r5, b5, g5, 1,
r6, b6, g6, 1,
r6, b6, g6, 1,
r6, b6, g6, 1,
r6, b6, g6, 1,
};
}