Author Topic: Where to put blit(...)?  (Read 2624 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Where to put blit(...)?
« on: June 11, 2015, 06:43:33 pm »
The docs make reference to a non-existent buffer.update(). Where do I put it in Android? Just after clear()?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Where to put blit(...)?
« Reply #1 on: June 11, 2015, 06:46:58 pm »
Where you want/have to. blit() draws over the current content of the framebuffer. Usually, you want to put it after draw to render some GUI elements but there might the situations where you want to put before the 3d rendering as well.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Where to put blit(...)?
« Reply #2 on: June 11, 2015, 06:48:44 pm »
OK, thank you. Would you mind fixing the docs?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Where to put blit(...)?
« Reply #3 on: June 11, 2015, 06:51:12 pm »
Yes, I'll remove that reference to update from the AE-docs. I wasn't aware of it.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Where to put blit(...)?
« Reply #4 on: June 12, 2015, 03:08:58 am »
Thanks.

Now, I have to keep updating a texture with which to blit the FrameBuffer. How could I go about updating its data without constantlly recreating it (I'm drawing onto a single Bitmap and would like to update the texture to the Bitmap without destroying and recreating it)?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Where to put blit(...)?
« Reply #5 on: June 12, 2015, 05:01:26 am »
To answer my own question, I just used the int[] blit instead:

Code: [Select]
                int i = 0;
                for (int y = 0; y < textMap.getHeight(); y++)
                    for (int x = 0; x < textMap.getWidth(); x++)
                        array[i++] = textMap.getPixel(x, y);
                 buffer.blit(array, textMap.getWidth(), textMap.getHeight(), 0, 0, 80, 100, textMap.getWidth(), textMap.getHeight(), false);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Where to put blit(...)?
« Reply #6 on: June 12, 2015, 07:56:23 am »
This still triggers a new texture upload for each blit, which might become a performance problem. What are you doing exactly with the texture's content? Maybe there's a faster way of doing it...!?