Thank you so much...
I resolve the problem using ITextureEffect, this is the code:
And in onDrawFrame:
[...]
[...]
I resolve the problem using ITextureEffect, this is the code:
Code Select
private Bitmap overlayBitmap = null;
private Canvas overlayCanvas = null;
private Texture overlay = null;
private void drawOverlay(int width, int height) {
if(overlayBitmap == null || nextPow2(width) != overlayBitmap.getWidth() || nextPow2(height) != overlayBitmap.getHeight()){
overlayBitmap = Bitmap.createBitmap(nextPow2(width), nextPow2(height), Bitmap.Config.ARGB_8888);
overlayCanvas = new Canvas(overlayBitmap);
overlay = new Texture(Bitmap.createBitmap(overlayBitmap));
overlay.setEffect(new ITextureEffect() {
@Override
public void init(Texture arg0) {}
@Override
public boolean containsAlpha() {
return true;
}
@Override
public void apply(int[] dest, int[] src) {
overlayBitmap.getPixels(dest, 0, overlay.getWidth(), 0, 0, overlay.getWidth(), overlay.getHeight());
}
});
}
overlayCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
//Paint what you want
Paint p = new Paint();
p.setColor(Color.CYAN);
overlayCanvas.drawText("" + (SystemClock.uptimeMillis() / 1000), 50, 50, p);
//End Paint
overlay.applyEffect();
}
public int nextPow2(int num) {
return (int)Math.pow(2, num == 0 ? 0 : 32 - Integer.numberOfLeadingZeros(num - 1));
}
And in onDrawFrame:
[...]
Code Select
drawOverlay(fb.getWidth(), fb.getHeight());
fb.blit(overlay, 0, 0, 0, 0, fb.getWidth(), fb.getHeight(), true);
[...]