www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: lawless_c on February 11, 2019, 11:23:03 pm

Title: NPOTexture from bitmap
Post by: lawless_c on February 11, 2019, 11:23:03 pm
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.
Title: Re: NPOTexture from bitmap
Post by: EgonOlsen on February 12, 2019, 08:52:42 am
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) (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 (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.
Title: Re: NPOTexture from bitmap
Post by: lawless_c on February 26, 2019, 11:21:55 pm
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.