Starting A Voxel Game

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

A “chunk system” huh? That’s just a collection of blocks. A Map or Level would then hold a collection of chunks which are holding collections of blocks.

A chunk is (usually) a equal amount of something (in your case tiles) that are grouped together so they can easily be accessed and changed without accessing too many other objects in the world. It could be used for a variety of reasons but a chunk in your case is used to store tiles. So, simply have a new class that has an array of some sort that’s stores a uniform amount of tiles. You can then render or update a chunk and it will render and update all the tiles within that chunk but none outside.

Also, a voxel is a 3D pixel. What your using are commonly referred to as tiles.

As another side note, you’re using the fixed function pipeline(immediate mode) which has been deprecated for a while and is horribly slow. If you’re just starting out in OpenGL, this is ok to use for a while, but don’t expect great performance. I would recommend looking into shaders and the programmable pipeline. Its harder, but its the standard for modern day graphics processing and is much faster than its older deprecated cousin.

Good luck!