Search code examples
androidopengl-esandenginetexture-mapping

texture mapping


I'm trying to apply texture to a sprite using opengl as follows:

int[] textures=new int[1];
gl.glEnableClientState(GL10.GL_TEXTURE_2D);
gl.glGenTextures(1, textures, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
Bitmap bitmap=null;
try {
   bitmap=  BitmapFactory.decodeStream(contxt.getAssets().open("gfx/garf.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

GLUtils.texImage2D(GL10.GL_VERTEX_ARRAY, 0, bitmap, 0);
bitmap.recycle();

.....

I'm using andEngine framework in android and using onManagedDraw method of Sprite to do this.

Can anyone help in this direction?


Solution

  • I think you need texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);