Reputation: 110
I'm in the process of converting an app from OpenGLES 1.0 to OpenGLES 2.0 and I've managed to get most of it done. Annoyingly though a few textures (out of many and the same ones each time) render black instead of anything useful. They are small images (about 32x32) and in PNG format with an alpha channel although that isn't a unique in its own right as a similar image is loading fine.
I've narrowed it down to GLUtils.texImage2D returning a 1280 error on those images but I don't see why it should cause a problem.
Can anybody suggest why this could be occuring and/or possible remedies? Would it be pertinent to use GLES20.glTexImage2D manually (whatever it does)?
Upvotes: 0
Views: 2135
Reputation: 46
I had a similar problem and solved it by loading my images using:
BitmapFactory.decodeResource(context.getResources(), R.drawable.resourceName)
instead of the code from the sample (my guess is this is what you currently have):
InputStream is = mContext.getResources()
.openRawResource(R.raw.robot);
Bitmap bitmap;
try {
bitmap = BitmapFactory.decodeStream(is);
} finally {
try {
is.close();
} catch(IOException e) {
// Ignore.
}
}
Upvotes: 3