Code example for GL10

Methods: glColorPointer, glDisableClientState, glDrawElements, glEnableClientState, glVertexPointer

0
	private static boolean init = false;
 
	public static void draw(GL10 gl) {
		if (!init)
			initIt(); 
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
 
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
		gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
		gl.glDrawElements(GL10.GL_LINES, 6, GL10.GL_UNSIGNED_BYTE, indexBuffer);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
	} 
 
	private static void initIt() { 
		init = true;
		// load the 3 axis and their colors: 
		float vertices[] = { 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2 };
		float colors[] = { 0, 0, 0, 0.5f, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1 };
		byte indices[] = { 0, 1, 0, 2, 0, 3 };