Author Topic: Dynamic texture loading / deleting. Raspberry PI 3  (Read 6698 times)

0 Members and 1 Guest are viewing this topic.

bobtarask

  • Newbie
  • *
  • Posts: 9
    • View Profile
Dynamic texture loading / deleting. Raspberry PI 3
« on: September 01, 2016, 01:46:18 PM »
Hello,

I have a list of images ( ~ 100 images in PNG format) that I need to display in a timed sequence (like a movie)

I use textures to display the images (like in the demo http://www.geeks3d.com/hacklab/20151207/how-to-control-the-window-opacity-on-the-raspberry-pi/).

Creating the texture works: with the function  gh_texture.create_from_file_v3 from the API (http://www.geeks3d.com/geexlab/reference/scripting_texture.php). I load the images at initialization, and then I am able to display the images in the FRAME script. But I am currently limited to 10 textures simultaenously in the GPU.

Is it possible to update the GPU textures from a seperated thread / process ? ( I cannot do it in the FRAME script because it takes too much time to load the texture from file, affecting the display)

Also I tried to use the functions to update textures :

gh_texture.update_gpu_memory_from_file
gh_texture.update_gpu_memory_from_buffer


but neither worked or I was not able to use them properly..

And I didn't find any way to free the textures from the GPU ?

Maybe it could be done with gh_texture.reset_texture_unit ? But I don't understand the arguments of the function.

Could someone help in those matters ?

Thanks and best regards

Etienne





JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1779
    • View Profile
    • Geeks3D.com
Re: Dynamic texture loading / deleting. Raspberry PI 3
« Reply #1 on: September 01, 2016, 04:45:47 PM »
gh_texture.update_gpu_memory_from_file() should work on RPi. The parameters are:

Code: [Select]
gh_texture.update_gpu_memory_from_file(texture_id, image_filename, is_abs_path)

texture_id is the id of an existing texture (created for example with gh_texture.create_2d() or with gh_texture.create_from_file()). And the new texture you want to upload must have the same dimensions than the existing texture.

To kill a texture just use:
Code: [Select]
gh_node.kill(texture_id)


What I should add to GeeXLab is a function to load a texture in the CPU memory only. Then later, with another function you can upload this CPU texture into GPU memory. I will try to add these functions asap.


bobtarask

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Dynamic texture loading / deleting. Raspberry PI 3
« Reply #2 on: September 02, 2016, 11:10:49 AM »
Hello thanks a lot for the support,

For our slides show (we are displayed HTML5 dynamically generated slides with transparency over a video playing in background) it was fine to spawn new demo processes each one displaying the next slide at  a defined time).

We had also had to find a way to pass arguments to the demo scripts. We managed to pass parameters through a file named after the process id. But maybe there is a way to pass the command line arguments to the lua scripts ?


Have a nice day,

Etienne

JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1779
    • View Profile
    • Geeks3D.com
Re: Dynamic texture loading / deleting. Raspberry PI 3
« Reply #3 on: September 02, 2016, 11:47:19 AM »
You can retrieve the command line in a script with:

Code: [Select]
command_line = gh_utils.get_command_line()

Once you have the command_line, just parse it with Lua/Python string functions to extract parameters.

bobtarask

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Dynamic texture loading / deleting. Raspberry PI 3
« Reply #4 on: September 03, 2016, 06:46:05 PM »
Cool thanks again! without your help and your code we would not have been able to satisfy the requirements.  Your work on the PI is pretty cool. It is the only library I found managing transparency.

Also I had a last question, is it possible to set the window size from the script or to pass it to the XML through command line parameters ?

If not possible I will have to hack the XML before running GeexLab.

Best regards,

Etienne


JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1779
    • View Profile
    • Geeks3D.com
Re: Dynamic texture loading / deleting. Raspberry PI 3
« Reply #5 on: September 04, 2016, 10:18:48 AM »
cuurently, the only ways to bypass the window size defined in the XML are: command line or init0.xml.

Command line:
Code: [Select]
geexlab /width=1024 /height=400

init0.xml:
Code: [Select]
<glslhacker_init
    demofile=""
    width="1024"
    height="400"
/>

Let me know if that helps.

bobtarask

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Dynamic texture loading / deleting. Raspberry PI 3
« Reply #6 on: September 04, 2016, 12:43:32 PM »
Hello,

merci c'est parfait on a utilisé les arguments en ligne de commande /width /height.

Bon dimanche