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

Author Topic: fastest way to get pixel from RenderTexture?  (Read 7350 times)

0 Members and 1 Guest are viewing this topic.

NinjaFighter

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • http://www.sebagames.wordpress.com
fastest way to get pixel from RenderTexture?
« on: May 27, 2012, 09:03:35 pm »
I don't know how to Get a pixel information of a RenderTexture, without copy it on a new Image. There's a way to do this more faster?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: fastest way to get pixel from RenderTexture?
« Reply #1 on: May 27, 2012, 09:48:25 pm »
There's no way, the texture lives in the graphics card's memory, you have to copy it in an image in system memory to read a pixel.

Why do you need to read pixels of a render-texture?
Laurent Gomila - SFML developer

NinjaFighter

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • http://www.sebagames.wordpress.com
Re: fastest way to get pixel from RenderTexture?
« Reply #2 on: May 28, 2012, 05:18:43 am »
It's just curiosity, because I remember that old versions uses myRenderImage.Image.GetPixel() for that purpose. So, in old versions do you store for (each Image instance) a Texture and another Image for Set/Get pixel purposes?
I don't want to use GetPixel now, but I think could be useful for some graphics editing application.
I repeat, it's only curiosity. This is not crucial for me.  :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: fastest way to get pixel from RenderTexture?
« Reply #3 on: May 28, 2012, 08:09:50 am »
Depending on what you're doing, I guess it's faster to work directly with a sf::Image instead of a sf::RenderTexture and then just call Update(...) on a sf::Texture.
But if you need to do some shape/image rendering, I guess you'll have copy the texture to an image.
If you want to create a graphics editing application I bet there are better libraries for that. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: fastest way to get pixel from RenderTexture?
« Reply #4 on: May 28, 2012, 10:30:00 am »
In SFML 1.6, the Image class was maintaining a copy of the pixel data both in graphics and system memory. When one was outdated, it performed an automatic copy -- so GetPixel could be very slow.

That's why things are now split in two classes :)
Laurent Gomila - SFML developer

NinjaFighter

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • http://www.sebagames.wordpress.com
Re: fastest way to get pixel from RenderTexture?
« Reply #5 on: May 28, 2012, 08:23:07 pm »
Ah... this make sense now. Thats 100% clear my doubts. Thanks  :)