pixels data from a sprite

edited April 2013 in Help request
Hi. Can I take information about each pixels from a sprite. Also can I edit this information

Comments

  • edited April 2013
    Hi mig29, and welcome here! :)

    Do you mean access the sprite data once it's loaded in a texture?

    Yes, you can access its content and modify it, however this is not a fast operation as the data has to be transferred between GPU and main memory every time: GPU memory -> main memory -> modification -> GPU memory.
    In addition to using bandwidth, it also forces a sync point between GPU and CPU.

    Anyway, in order to do that, you need those steps:
    - from your texture you need to get its bitmap with orxTexture_GetBitmap()
    - then you need to allocate a buffer large enough to get the data from that bitmap, you can get the dimension of your bitmap by calling orxDisplay_GetBitmatSize(), then BufferSize = BitmapWidth * BitmapHeight * sizeof(orxRGBA)
    - then fill your buffer with the content of the bitmap by calling orxDisplay_GetBitmapData()
    - then modify that buffer as you see fit
    - and finally send the new content back to the GPU with orxDisplay_SetBitmapData().

    Can you tell us what you want to do exactly? Maybe there are better ways of achieving a similar result.
  • edited April 2013
    I want mix different textures (grass, sand, ....) according some mask (maybe another texture, which represent transparency between different textures)
  • edited April 2013
    In that case, an alternative would be to use a custom fragment shader to do the mix on the fly, with the added bonus of allowing more dynamism.
  • edited April 2013
    iarwain wrote:
    In that case, an alternative would be to use a custom fragment shader to do the mix on the fly, with the added bonus of allowing more dynamism.

    does orx engine support pixel shaders?
  • edited April 2013
    Yes. There are examples a bit everywhere like this one.
Sign In or Register to comment.