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

Author Topic: read backbuffer?  (Read 1647 times)

0 Members and 1 Guest are viewing this topic.

Mike Versteeg

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
read backbuffer?
« on: March 17, 2014, 09:43:53 am »
Hi,

Can I use SFML as a hardware accelerator for bitmap processing, i.e. create an invisible surface, scale and write some bitmaps to it, and read back the result? I googled for it, searched this forum (which keeps giving me database errors) and even bought the SFML Game Development book, but am still unsure if this is even possible. I currently use GDI for this purpose, but it's too slow.

Thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: read backbuffer?
« Reply #1 on: March 17, 2014, 09:55:30 am »
Not sure what you mean exactly with "bitmap processing", but yes, you can load an image into a texture, render that texture to a RenderTexture with all the "processing" you want and then retrieve the texture of the RenderTexture and copy it back to an image again, which allows you to save it - see the documentation for detailed function descriptions.

Keep in mind however that uploading and download an image to and from the GPU is a relatively slow process, but if it's just for one image then it shouldn't be that big of an issue, plus once uploaded you can reuse the texture however you like. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mike Versteeg

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: read backbuffer?
« Reply #2 on: March 17, 2014, 10:31:59 am »
Hi, thanks for your quick reply and for pointing me in the right direction.

Actually it's for video, so speed is important. From DirectX I know that getting data to/form the GPU is (relatively) slow, but there the advantages outweigh the disadvantages. Unless you know from experience, I'll write a little test to see how much ms this takes in OpenGL/SFML. I also need to find out if there is a bottleneck somewhere, i.e. what happens if multiple threads start uploading to/from the GPU.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: read backbuffer?
« Reply #3 on: March 17, 2014, 01:42:36 pm »
You could have a look at the sfeMovie project.

And you can't really make the GPU downloads/uploads faster by using multiple CPU threads; OpenGL is already an asynchronous API. It usually adds a lot of complexity, so if possible, I would limit the graphics card interaction to one thread.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: