Wow, It WORKED!
I'm posting my code here to help anyone who like to add background from an image that does not comply with the texture factory policy.
Hope it helps. Thanks EgonOlsen for helping to figure this out!
I'm posting my code here to help anyone who like to add background from an image that does not comply with the texture factory policy.
Quote
// open the background as input stream
InputStream inputStream = getAssets().open("background.jpg");
// create a bitmap
final Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
// create an NPOT texture
final NPOTTexture npotTexture = new NPOTTexture(bitmap.getWidth(),
bitmap.getHeight(), RGBColor.BLACK);
// set the effect
npotTexture.setEffect(new ITextureEffect() {
@Override
public void init(Texture texture) {
}
@Override
public boolean containsAlpha() {
return false;
}
@Override
public void apply(int[] dest, int[] source) {
// we apply the effect, but really all we do is copying the ARGB from the bitmap to "dest"
bitmap.getPixels(dest, 0, bitmap.getWidth(), 0, 0,
bitmap.getWidth(), bitmap.getHeight());
}
});
// apply the effect
npotTexture.applyEffect();
// now render everything..
frameBuffer.clear(..)
frameBuffer.blit(npotTexture, 0, 0, 0, 0,
bitmap.getWidth(), bitmap.getHeight(),
FrameBuffer.OPAQUE_BLITTING);
world.renderScene(frameBuffer);
world.draw(frameBuffer);
frameBuffer.display();
Hope it helps. Thanks EgonOlsen for helping to figure this out!