Reputation: 761
The source is this:
public static int loadTexture ( Bitmap bitmap )
{
//long time1 = System.currentTimeMillis();
int[] textureId = new int[1];
GLES20.glGenTextures ( 1, textureId, 0 );
GLES20.glBindTexture ( GLES20.GL_TEXTURE_2D, textureId[0] );
GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
try{
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
}
catch(Exception ex)
{
ex.printStackTrace();
}
return textureId[0];
}
I want to recycle the bitmap int the method GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0) and free the memory,please help me how to do it?
Upvotes: 1
Views: 1962
Reputation: 131
To delete the texture from OpenGL, use:
GLES20.glDeleteTextures(1, textureId, 0);
to free the bitmap itself, use:
bitmap.recycle();
You can recycle the bitmap once it has been loaded into OpenGL.
Upvotes: 2