ImageGraphics clean update does not work?


I'm trying to update a texture according to what was painted in an ImageGraphics object. When I call the ImageGraphic's update(Texture texture, boolean clean) method and set clean to true, any subsequent painting on the ImageGraphics object will never again mark an area dirty and subsequent update()s  don't have any visible effect.

To demonstrate this I prepared a SimpleGame:

I'm writing "First Update" on a texture and after an update(texture, true) I repaint the image and write "Second Update" and call update(texture, true) again => Only "First Update" is visible.

When tying the same with calls to update(texture, false), then one will read "Second Update"…

import java.awt.Color;

import com.jme.image.Texture;
import com.jme.image.Texture2D;
import com.jme.input.MouseInput;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;
import com.jmex.awt.swingui.ImageGraphics;

public class Test extends SimpleGame {
   protected void simpleInitGame() {
      try {
         int width = 100;
         int height = 20;
         Quad q = new Quad("q", 5, 1);

         // Create texture state and texture
         TextureState ts = display.getRenderer().createTextureState();
         Texture t = new Texture2D();
         // Create ImageGraphics and set our texture's image
         ImageGraphics ig = ImageGraphics.createInstance(width, height, 0);
         // Flip y-axis
         ig.scale(1, -1);
         ig.translate(0, -height);
         // Write some message string on the texture
         ig.fillRect(0, 0, width, height);
         ig.drawString("First Update", 0, height);
         // Update and set it to clean
         ig.update(t, true);

         // Repaint completely with another message
         ig.fillRect(0, 0, width, height);
         ig.drawString("Second Update", 0, height);
         // Update again...
         ig.update(t, true);
         // Attach the quad with the texture.
         // We don't see the second message...
      } catch (Exception ex) {
   public static void main(String[] args) {
      Test app = new Test();

So, am I missing something or is this maybe a bug?

The following line must be changed:

ig.update(t, true);


ig.update(t, false);

"True" means that only dirty areas will be updated, but the ImageGraphics does not know which areas are dirty itself…

You'll need a repaintmanager or something like that… That repaints exactly the dirty areas…