Runtime-generated textures

Started by AW999, July 13, 2010, 07:47:05 PM

Previous topic - Next topic

AW999


Once I've generated the textures I need via my code, what's the easiest way to transfer that array to a usable texture graphic which jPCT can use?  I assume for a .bmp, I just need to reverse the array so it's "upside down" and then add a header?  Or is it best to use premade conversion code from a library? Or am I way off base...?

EgonOlsen

Depends on the format of the generated texture. If it's an int[]-array or similar, the best way is to use an ITextureEffect.

AW999

Quote from: EgonOlsen on July 13, 2010, 10:39:40 PM
Depends on the format of the generated texture. If it's an int[]-array or similar, the best way is to use an ITextureEffect.

  Just an array of pixels in RGB format. Is there an example of using ITextureEffect for something like this?

EgonOlsen

I have various ITextureEffect implementations lying around here, but i guess they would confuse more than they might help, because they do too much.

The steps are pretty simple:


  • Implement the ITextureEffect-interface and let the apply()-method copy your generated pixel data into the dest int[]-array
  • Assign the effect to an empty texture of that size (Texture.setEffect())
  • Apply the effect (Texture.applyEffect())
  • Remove the effect (Texture.removeEffect())

That's basically all there is to do. Hope this helps.