3

So, I have a texture in my res/drawable-hdpi (text.png, for example) folder, how I can load this texture and bind it with glBindTexture?

1
  • I've try to load it with R class Commented Sep 12, 2012 at 12:50

1 Answer 1

9
Bitmap img = BitmapFactory.decodeResource(context.getResources(), R.drawable.text);
int[] texId = new int[1];
GLES20.glGenTextures(1, texId, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texId[0]);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, img, 0);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
  1. Decode resource to bitmap
  2. Generate texture
  3. Bind Texture
  4. Upload texture
  5. Set minification filter for completeness
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.