Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLES20; import android.opengl.GLUtils; import java.io.IOException; import javax.microedition.khronos.opengles.GL10; public class Main { private static Context context; public static int loadTexture(String s) { Bitmap img; try { img = BitmapFactory.decodeStream(context.getAssets().open(s)); } catch (IOException e) { return 0; } int tex[] = new int[1]; GLES20.glGenTextures(1, tex, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex[0]); GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, img, 0); GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D); GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR_MIPMAP_LINEAR); GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); img.recycle(); return tex[0]; } }