Menu

8bit textures

Anonymous
2009-11-07
2012-12-26
  • Anonymous

    Anonymous - 2009-11-07

    hi,
    first thanks for your library, impressive job

    I have a byte array b

    i try to manipulate it

    first how to declare an alpha texture, i tried :
      tex0 = new GLTexture(this,nbpixelxy,nbpixelxy,GLConstants.TEX1);

      tex0.putByteBuffer(int(b),1);

      tex1.render(0, 0, 4096, 4096);

    well i see a picture but it seems that my data was converted in an rgba texture and i see a beautiful rba vertical lines grid

    thanks for any  help

     
  • Andres Colubri

    Andres Colubri - 2009-11-08

    Hey, thanks for your comment, in fact this is an important conceptual point I overlooked in the architecture of GLGraphics. GLTextures should only be 4 channel, for two reasons:
    * the underlying PImages are always in ARGB format.
    * the behavior of rendering a 1 or 2 channel texture is driver dependent, i.e. not well defined.

    Because of these two reasons, GLTextures can only be 4 channels. But, if GLGraphics gives you the option with the putByteBuffer() method of setting only one channel in a 4 channel texture, how this should work? I think it should work as follows:

    tex0.putByteBuffer(buffer, ALPHA);
    tex0.putByteBuffer(buffer, RED);
    tex0.putByteBuffer(buffer, GREEN);
    tex0.putByteBuffer(buffer, BLUE);

    meaning that the buffer will be used to set the selected channel, while the other three are set to zero. Well, this if you are setting the ALPHA channel. If you are setting a color channel, say RED, then GREEN and BLUE will be set to zero while ALPHA to 255, i.e.: full opacity. This is to keep consistency with the behavior inherited from PImage.

    Does this make sense?

     
  • Anonymous

    Anonymous - 2009-11-12

    thanks for your clear answer

    I will manage to use ARGB by multiplexing data ( i have to save memory)

    thank you again for your libraries that saved me a lot of time

     

Log in to post a comment.