How to create a cube using a single grid in libgdx

To draw a cube that has 6 sides using libgdx, you need 6 grids. But this increases the time on each grid when rendering.

my code is:

for(int i=0; i<6; i++)
{

    faces[i].setvertices(new float[] {x,y,z,color};
}

So, is it possible to create a cube using a single mesh, rather than 6?

Thank.

+3
source share
1 answer

Of course, you can create a single mesh for the cube. Check out the SimpleVertexShader test in libGDX tests. It uses Shapes.genCube () to create a cubic grid.

+4
source

All Articles