Last active
August 29, 2015 14:11
-
-
Save ictrobot/5c16df061fd2afa5a138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ethanjones.jnierror; | |
import com.badlogic.gdx.ApplicationAdapter; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.graphics.Mesh; | |
import com.badlogic.gdx.graphics.VertexAttributes; | |
import com.badlogic.gdx.graphics.g3d.utils.MeshBuilder; | |
public class JniError extends ApplicationAdapter { | |
private static short[] indices; | |
public static final int VERTEX_SIZE = 8; //3 for position, 3 for normal, 2 for texture coordinates | |
public static final VertexAttributes vertexAttributes = MeshBuilder.createAttributes(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates); | |
public static final int SIZE_BLOCKS = 16; | |
public static final int SIZE_BLOCKS_CUBED = SIZE_BLOCKS * SIZE_BLOCKS * SIZE_BLOCKS; | |
static { | |
int len = SIZE_BLOCKS_CUBED * 6 * 2; | |
indices = new short[len]; | |
short j = 0; | |
for (int i = 0; i < len; i += 6, j += 4) { | |
indices[i + 0] = (short) (j + 0); | |
indices[i + 1] = (short) (j + 1); | |
indices[i + 2] = (short) (j + 2); | |
indices[i + 3] = (short) (j + 2); | |
indices[i + 4] = (short) (j + 3); | |
indices[i + 5] = (short) (j + 0); | |
} | |
} | |
public void create() { | |
int i = 0; | |
for (int x = -5; x <= 5; x++) { | |
for (int y = 0; y <= 5; y++) { | |
for (int z = -5; z <= 5; z++) { | |
Mesh mesh = new Mesh(false, VERTEX_SIZE * 6 * SIZE_BLOCKS_CUBED, indices.length, vertexAttributes); | |
mesh.setIndices(indices); //Normally stored... | |
i++; | |
System.out.println(i + " mesh(es)"); | |
} | |
} | |
} | |
} | |
public void render() { | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment