NPOTexture from bitmap

Started by lawless_c, February 11, 2019, 11:23:03 PM

Previous topic - Next topic

lawless_c

is it possible to create a non power of two texture from a bitmap?

I have been trying for a few days now, but NPOTexture only has one constructor, which only allows for the creation of colour textures.

And the Texture object itself replaces my NPO Bitmaps with a square black bitmap to use as a texture instead.

EgonOlsen

NPOTTexture was added to render videos into them stuff like that. They weren't meant to be used for general purpose applications, because they have quite a few drawbacks. Whenever possible, use square textures instead. That said, there are two ways to feed pixels into them. One is by using http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Texture.html#overrideTexelData(java.nio.ByteBuffer), but that will leave dealing with context changes all by yourself. The other way is to implement an ITextureEffect (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/ITextureEffect.html) and let it set the new pixels. Just make sure that you give your NPOTTexture a color and not null or otherwise, it won't create any pixel data buffer at all.

lawless_c

#2
Thanks for that :-)

I went getting pixels as integers in the end, as able to save them and then add them to the framebuffer again using blitting.