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

Author Topic: Fastest way to update screen from pixels.  (Read 2537 times)

0 Members and 1 Guest are viewing this topic.

luke1985

  • Newbie
  • *
  • Posts: 2
    • View Profile
Fastest way to update screen from pixels.
« on: June 21, 2015, 01:38:22 pm »
There is a specific situation:
I've got array of pixels sf::Uint8* that I want to alter every frame and draw to the whole screen.

What is the fastest way to do it?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
AW: Fastest way to update screen from pixels.
« Reply #1 on: June 21, 2015, 01:44:29 pm »
Pass the array to the texture.update() function and draw the texture.

Depending on what you do, using shaders might be a better option though.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Fastest way to update screen from pixels.
« Reply #2 on: June 21, 2015, 02:07:02 pm »
Maybe there's an alternative. But you have to tell us what you want to do, not how you plan to do it.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

luke1985

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Fastest way to update screen from pixels.
« Reply #3 on: June 21, 2015, 02:44:57 pm »
Well, what I want to achieve is a little more complicated. I want to make an isometric engine that sorts pixels by the depth they appear on scene and alpha composites the result, so for each screen pixel coordinate in the screen i need to check if it belongs to a sprite and if it does, add it to an array of pixels at that position, then sort the pixels in this array based on it's depth, calculated elsewhere.

I've searched for alternative methods, that would use GLSL. But due to it's big limitations (like lack of ability to store sampler objects in an array) it seems impossible.

Critkeeper

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Fastest way to update screen from pixels.
« Reply #4 on: June 21, 2015, 06:24:46 pm »
Well, what I want to achieve is a little more complicated. I want to make an isometric engine that sorts pixels by the depth they appear on scene and alpha composites the result, so for each screen pixel coordinate in the screen i need to check if it belongs to a sprite and if it does, add it to an array of pixels at that position, then sort the pixels in this array based on it's depth, calculated elsewhere.

I've searched for alternative methods, that would use GLSL. But due to it's big limitations (like lack of ability to store sampler objects in an array) it seems impossible.

a typical 1080p monitor has 1080 * 1920 = 2073600 pixels.

You are talking about having 2073600 arrays of at most size N, where N is the upper bound on the number of times a sprite can be overlapped by another sprite-- or you are talking about 2073600 dynamically growing vectors.

Not only do you have 2073600 vectors, you will need to update each of them 60 times per second if you intend to maintain 60 frames per second.

That means you will only have 8 nano seconds to update each array.

Not going to happen in this decade bro.
if(CritKeeper.askQuestion()){return question.why();}

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Fastest way to update screen from pixels.
« Reply #5 on: June 24, 2015, 09:24:29 am »
"You're doing it wrong." :)

Do you want to do some "hidden object" drawing? Any more details or possibly a mockup screenshot?

 

anything