Author Topic: NPOTexture from bitmap  (Read 282 times)

Offline lawless_c

  • int
  • **
  • Posts: 95
    • View Profile
NPOTexture from bitmap
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11983
    • View Profile
    • http://www.jpct.net
Re: NPOTexture from bitmap
« Reply #1 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), 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.

Offline lawless_c

  • int
  • **
  • Posts: 95
    • View Profile
Re: NPOTexture from bitmap
« Reply #2 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.
« Last Edit: February 26, 2019, 11:23:36 pm by lawless_c »