Code example for GL10

Methods: glBindTexture, glDisableClientState, glDrawArrays, glEnableClientState, glFrontFace, glTexCoordPointer, glVertexPointer

0
 
	 
	/** The draw method for the square with the GL context */ 
	public void draw(GL10 gl) {
		// bind the previously generated texture 
		gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
		 
		// Point to our buffers 
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
		 
		// Set the face rotation 
		gl.glFrontFace(GL10.GL_CW);
		 
		// Point to our vertex buffer 
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
		gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
		 
		// Draw the vertices as triangle strip 
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
 
		//Disable the client state before leaving 
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	} 
	 
	public String getFormattedTileNumber() {
		return String.format("%04d",this.tileNumber);
	}