Reputation: 10309
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?
Upvotes: 0
Views: 473
Reputation: 13026
I think you need texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
Upvotes: 4
Reputation: 56417
I'm just guessing that your problem is that the texture doesn't show up :)
This is wrong:
GLUtils.texImage2D(GL10.GL_VERTEX_ARRAY, 0, bitmap, 0);
Should be:
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
Upvotes: 2