Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing to renderTextures  (Read 1384 times)

0 Members and 1 Guest are viewing this topic.

sodah

  • Newbie
  • *
  • Posts: 11
    • View Profile
Drawing to renderTextures
« on: May 11, 2018, 12:08:01 am »
Hey,

I am doing some simulations with autonomous agents that are controlled by an artificial neural network.
The input into the ANNs is the world rendered from their perspective i.e a renderTexture with a corresponding view.

Since i'm new to SFML i'm not sure how to do this in the fastest way possible.
My current way is just simply:

renderTexture.setView(...);
renderTexture.draw(...);
image = renderTexture.getTexture().copyToImage();
... feed pixels to ANN

Is there anyway to do this with better performance or do you have any better approach?
« Last Edit: May 11, 2018, 12:09:53 am by sodah »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Drawing to renderTextures
« Reply #1 on: May 11, 2018, 12:29:38 am »
Create the ANN as shader, then you don't need to go from VRAM to RAM. If you need the pixel data, that's the only way I currently know of.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sodah

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Drawing to renderTextures
« Reply #2 on: May 11, 2018, 11:10:08 am »
If i did that i would still need to copy the output from the ANN to RAM to run my physics simulation but i guess it would be faster since there would be less stuff to copy.

Is there any way to render using the cpu in SFML? The textures i want to create for my agents are very small so it should be pretty quick with the cpu aswell. Or do you know any other libs where i could do this?