Each chunk is 16x16x16 voxels.
I have been drawing in immediate mode, as the code below shows.
However now I am trying to convert to OpenGL 3.1.
I have got alot working and I can draw a chunk on screen without ANY deprecated functions at all.
(Finally, YAY!)
However the problem is now drawing the world.
The world is 25x25x25 Chunks.
Before I would just translate to the chunks position and then draw.
The question is how to do this most effeciently in GLSL?
I have each chunk stored in a VBO.
I mean can I use 3 nested For loops to draw the VBO's somehow?
Right now I'm passing the verticies and tex coords to the Program like normal.
This is just like a tilemap, however it's 3d, and each Position has a unique VBO as opposed to a reference.
Anyone have any ideas?
Thanks in advance, Walker
Old technique:
for (int iChunkY=0+DEPTH;iChunkY<CLIPDIST-DEPTH;iChunkY++)
{
for (int iChunkX=0+DEPTH;iChunkX<CLIPDIST-DEPTH;iChunkX++)
{
for (int iChunkZ=0+DEPTH;iChunkZ<CLIPDIST-DEPTH;iChunkZ++)
{
if (chunkExists[iChunkX][iChunkY][iChunkZ]==true)
{
if (Chunk[iChunkX][iChunkY][iChunkZ]->vertexBuffer.size()!=0)
Chunk[iChunkX][iChunkY][iChunkZ]->renderDraw(iChunkX*16,iChunkY*16,iChunkZ*16);
}
}
}
}
void chunk::renderDraw(float x, float y, float z)
{
if (vertexBuffer.size()!=0)
{
glPushMatrix();
glTranslatef(x,y,z);
glVertexPointer(3, GL_INT, 0, &vertexBuffer[0]);
glTexCoordPointer(2, GL_FLOAT, 0, &textureBuffer[0]);
//Draw
glDrawArrays(GL_QUADS, 0, vertexBuffer.size()*4);
glPopMatrix();
}
}