I'm trying to have lots of updateing textures in my project,and keep running into this error;
AndroidRuntime(22498): java.lang.RuntimeException: - ERROR: Too many textures added to the TextureManager. Adjust Config.maxTextures!
Heres my code for updating the texture;
private void updatedTexture(String Texturename, String text) {
Log.i("add", "update texture triggered with:"+Texturename+"|"+text);
paint.setColor(Color.BLACK);
Bitmap.Config config = Bitmap.Config.ARGB_8888;
FontMetricsInt fontMetrics = paint.getFontMetricsInt();
int fontHeight = fontMetrics.leading - fontMetrics.ascent
+ fontMetrics.descent;
int baseline = -fontMetrics.top;
int height = fontMetrics.bottom - fontMetrics.top;
// have to add multiline support here
Bitmap charImage = Bitmap.createBitmap(closestTwoPower((int) paint
.measureText(text) + 10), 32, config);
Canvas canvas = new Canvas(charImage);
canvas.drawColor(Color.WHITE);
canvas.drawText(text, 10, baseline, paint); // draw text with a margin
// of 10
TextureManager tm = TextureManager.getInstance();
Texture testtext = new Texture(charImage, true); // the true specifys
// the texture has
// its own alpha. If
// not, black is
// assumed to be
// alpha!
//
if (tm.containsTexture(Texturename)) {
Log.i("add", "updating texture="+Texturename);
tm.removeAndUnload(Texturename,fb);
Log.i("add", "updated texture="+Texturename);
tm.addTexture(Texturename, testtext);
} else {
tm.addTexture(Texturename, testtext);
}
}
Note the last bit.
Surely this should ensure the texture is replaced and thus not cause too many to form :? Instead I get my textures either turning completely white, or causing this error. (or both) after a few updates.