protected static int loadTexture(GL10 gl, Bitmap bmp) { ByteBuffer bb = ByteBuffer.allocateDirect(bmp.height() * bmp.width() * 4); bb.order(ByteOrder.nativeOrder()); IntBuffer ib = bb.asIntBuffer(); for (int y = 0; y < bmp.height(); y++) for (int x = 0; x < bmp.width(); x++) { ib.put(bmp.getPixel(x, y)); } ib.position(0); bb.position(0); int[] tmp_tex = new int[1]; gl.glGenTextures(1, tmp_tex, 0); int tx = tmp_tex[0]; gl.glBindTexture(GL10.GL_TEXTURE_2D, tx); gl.glTexImage2D( GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, bmp.width(), bmp.height(), 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, bb); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); return tx; }