private ETC1Util.ETC1Texture createTexture(InputStream input) throws IOException { int width = 0; int height = 0; byte[] ioBuffer = new byte[4096]; { if (input.read(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE) != ETC1.ETC_PKM_HEADER_SIZE) { throw new IOException("Unable to read PKM file header."); } if(headerBuffer==null){ headerBuffer = ByteBuffer.allocateDirect(ETC1.ETC_PKM_HEADER_SIZE) .order(ByteOrder.nativeOrder()); } headerBuffer.put(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE).position(0); if (!ETC1.isValid(headerBuffer)) { throw new IOException("Not a PKM file."); } width = ETC1.getWidth(headerBuffer); height = ETC1.getHeight(headerBuffer); } int encodedSize = ETC1.getEncodedDataSize(width, height); ByteBuffer dataBuffer = ByteBuffer.allocateDirect(encodedSize).order(ByteOrder.nativeOrder()); int len; while ((len =input.read(ioBuffer))!=-1){ dataBuffer.put(ioBuffer,0,len); } dataBuffer.position(0); return new ETC1Util.ETC1Texture(width, height, dataBuffer); }
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,texture[0]); ETC1Util.loadTexture(GLES20.GL_TEXTURE_2D,0,0,GLES20.GL_RGB,GLES20 .GL_UNSIGNED_SHORT_5_6_5,new ETC1Util.ETC1Texture(width,height,emptyBuffer)); GLES20.glUniform1i(mHTexture,getTextureType()); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,texture[1]); ETC1Util.loadTexture(GLES20.GL_TEXTURE_2D,0,0,GLES20.GL_RGB,GLES20 .GL_UNSIGNED_SHORT_5_6_5,new ETC1Util.ETC1Texture(width,height,emptyBuffer)); GLES20.glUniform1i(mGlHAlpha,1+getTextureType()); isPlay=false;
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,texture[0]); ETC1Util.loadTexture(GLES20.GL_TEXTURE_2D,0,0,GLES20.GL_RGB,GLES20 .GL_UNSIGNED_SHORT_5_6_5,new ETC1Util.ETC1Texture(width,height,emptyBuffer)); GLES20.glUniform1i(mHTexture,getTextureType()); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,texture[1]); ETC1Util.loadTexture(GLES20.GL_TEXTURE_2D,0,0,GLES20.GL_RGB,GLES20 .GL_UNSIGNED_SHORT_5_6_5,new ETC1Util.ETC1Texture(width,height,emptyBuffer)); GLES20.glUniform1i(mGlHAlpha,1+getTextureType()); isPlay=false;