Code example for GL10

Methods: glDisableClientState, glDrawElements, glEnable, glEnableClientState, glFrontFace, glGetError, glMaterialf, glMaterialfv, glNormalPointer, glVertexPointer

0
	 * @param gl 
	 *            the gl 
	 */ 
	private void drawMaterial(GL10 gl) {
 
		gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mMaterial.createDiffuseArray(), 0);
 
		gl.glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mMaterial.createAmbientArray(), 0);
 
		gl.glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mMaterial.createSpecularArray(), 0);
 
		gl.glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mMaterial.shininess);
	} 
 
	/** 
	 * Draw. 
	 *  
	 * @param gl 
	 *            the gl 
	 */ 
	public void draw(GL10 gl) {
		drawMaterial(gl);
		gl.glEnable(GL10.GL_NORMALIZE);
		gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		// set the color for the triangle 
		gl.glFrontFace(GL10.GL_CCW);
 
		// Enable the vertex and texture state 
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
		gl.glNormalPointer(GL10.GL_FLOAT, 0, mNormalBuffer);
//		gl.glColor4f(0f, 0f, 1f, 1f); 
 
		// Draw the vertices as triangle strip 
//		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3); 
		gl.glDrawElements(GL10.GL_TRIANGLES, mIndexBuffer.capacity(), GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
 
		int error = gl.glGetError();
		if (error != GL10.GL_NO_ERROR) {
			Log.d("GLError", "OpenGL Error: " + error);
		} 
	}