Skip to Main Content

Dynamically change Textures

843799Nov 5 2001 — edited Nov 8 2001
I need to dynamically draw on a texture.
There is a short description at how to do this, but i cant get it to work.
Can anyone give me a code-example?

This is what I did so far:

//create an Image
img = new Bufferedimage(width, height, BufferedImage.TYPE_3BYTE_BGR);
// I do some drawing on the img;
//create a TextureLoader with setting the Flag: byReference
loader = new TextureLoader(img, TextureLoader.Y_UP | TextureLoader.BY_REFERENCE);
//get the Texture from the TextureLoader
tex = loader.getTexture();
//create an Appearance
appear = new Appearance();
// then I create my Scene, texture coordinates and put it all together

later in the Code i want to change the texture:

// get the Pixels of img;
int[] imgData = img.getRGB(0,0, width, height, null, 0, width);
// do something with the pixels
// write the change pixels back into the img
img.setRGB(0,0,width, height, imgData, 0, width);

And this is where it ends. Here I would like the change of the img to be visible in my scene.
According to above link this should be possible by setting the Flag "BY_REFERENCE" and "Y_UP".
Somehow it does not work in my code.

Does anyone have a solution?

Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Dec 6 2001
Added on Nov 5 2001
1 comment