I am having problems rendering textures loaded from the assets folder. If I do exactly the same procedure loading the same texture from the resources folder, everything works fine. Also the image from the assets seems to be loading correctly as when I get the width and height property from the bitmap object, these correspond with the dimensions of the file on disk. However attempting to render the texture results in plain black.
// [...]
int [] tmpId = new int[1];
GLES20.glGenTextures(1, tmpId, 0);
int id = tmpId[0];
InputStream in = null;
try {
in = context.getAssets().open(resource);
}
catch (IOException e)
{
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(in);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, id);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
bitmap.recycle();
Am I missing something, are there rules which apply to assets which are different from resources? I can´t seem to figure out why this isn´t working.
The image is 512x512 png format with transparency.