I have started making a Voxel game, so far I only have a block renderer with Textures. I can’t find a tutorial that shows how to create a Chunk system that is easy to understand, so I can get it working with my code.
Block Code:
package test.voxel;
import java.io.IOException;
import org.lwjgl.opengl.GL11;
import test.voxel.Blocks.BlockType;
import test.voxel.data.TextureMananger;
public class BlockCreator {
public static void NewBlock(float base,float x, float y, float z, BlockType blocktype) throws IOException {
GL11.glBindTexture(GL11.GL_TEXTURE_2D,TextureMananger.getTexture(blocktype.GetTexture()));
GL11.glTranslatef(x, y, z);
GL11.glBegin(GL11.GL_QUADS);
// Back Face
GL11.glTexCoord2f(1.0F,1.0F);
GL11.glVertex3f(base, base, base);
GL11.glTexCoord2f(0.0F,1.0F);
GL11.glVertex3f(-base, base, base);
GL11.glTexCoord2f(0.0F,0.0F);
GL11.glVertex3f(-base, -base, base);
GL11.glTexCoord2f(1.0F,0.0F);
GL11.glVertex3f(base, -base, base);
// Front Face
GL11.glTexCoord2f(1.0F,1.0F);
GL11.glVertex3f(base, base, -base);
GL11.glTexCoord2f(0.0F,1.0F);
GL11.glVertex3f(-base, base, -base);
GL11.glTexCoord2f(0.0F,0.0F);
GL11.glVertex3f(-base, -base, -base);
GL11.glTexCoord2f(1.0F,0.0F);
GL11.glVertex3f(base, -base, -base);
// Right Face
GL11.glTexCoord2f(1.0F,1.0F);
GL11.glVertex3f(base, base, base);
GL11.glTexCoord2f(0.0F,1.0F);
GL11.glVertex3f(base, -base, base);
GL11.glTexCoord2f(0.0F,0.0F);
GL11.glVertex3f(base, -base, -base);
GL11.glTexCoord2f(1.0F,0.0F);
GL11.glVertex3f(base, base, -base);
// Left Face
GL11.glTexCoord2f(1.0F,1.0F);
GL11.glVertex3f(-base, base, base);
GL11.glTexCoord2f(0.0F,1.0F);
GL11.glVertex3f(-base, -base, base);
GL11.glTexCoord2f(0.0F,0.0F);
GL11.glVertex3f(-base, -base, -base);
GL11.glTexCoord2f(1.0F,0.0F);
GL11.glVertex3f(-base, base, -base);
// Top Face
GL11.glTexCoord2f(1.0F,1.0F);
GL11.glVertex3f(base, base, base);
GL11.glTexCoord2f(0.0F,1.0F);
GL11.glVertex3f(-base, base, base);
GL11.glTexCoord2f(0.0F,0.0F);
GL11.glVertex3f(-base, base, -base);
GL11.glTexCoord2f(1.0F,0.0F);
GL11.glVertex3f(base, base, -base);
// Bottom Face
GL11.glTexCoord2f(1.0F,1.0F);
GL11.glVertex3f(base, -base, base);
GL11.glTexCoord2f(0.0F,1.0F);
GL11.glVertex3f(-base, -base, base);
GL11.glTexCoord2f(0.0F,0.0F);
GL11.glVertex3f(-base, -base, -base);
GL11.glTexCoord2f(1.0F,0.0F);
GL11.glVertex3f(base, -base, -base);
GL11.glEnd();
}
}
This is the out come of the game:
Thanks