1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
public class Texture {
static boolean update = false, recyle = false ;
static int[] textures = null ;
static Bitmap[] bitmaps = null ;
static void loadTexture(int[] txt__, Bitmap[] btm__, boolean recycle__ ){
while ( update ){}
bitmaps = btm__;
recyle = recycle__;
textures = txt__;
update = true ;
}
static void update(){
if ( update ){
for ( int i = 0 ; i < textures.length ; i ++ ){
GLES20.glDeleteTextures(1, textures, i);
GLES20.glGenTextures(1, textures, i);
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false ;
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[i]);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmaps[i], 0);
if ( recyle ){
bitmaps[i].recycle();
}
}
update = false ;
}
}
} |
Partager