[SOLVED] Updating Textures with Texture2D

How does one update a texture once the texture already has been set.

For instance, say we have this:
Shape3d shape;
ImageComponent ic;
Texture2D texture;
BufferedImage bImage;

bImage = new BufferedImage(…);
bImage.createGraphics().drawString(“message”,0,0);
ic = new ImageComponent(…,bImage);
texture = new Texture2D(…);
texture.setImage(0,ic);
shape = magicShapeCreator(…); // say this function handles creating the shape with the right Appearance, normals, and texture coordinates
shape.setTexture(texture);

OK. so at this point the shape is added to the scene and displays the textuer properly.

Now what i want to do is to be able to update the texture.
I’ve tried so far to just update bImage ( but that doesn’t update whats being drawn on the screne).
(for instance bImage.createGraphics().drawString(a new message poped",0,100);

Any thoughts?

I just made up a small test and it looks like you have to do the following.

For the ImageComponent2D - set the ALLOW_IMAGE_WRITE capability.

Then any time you update the BufferedImage, you must re-set it in the ImageComponent2D.

For instance:
bImage.createGraphics().drawString(“text”,0,0);
// now reset the image
ic.set(bImage);