SFML community forums
Help => Graphics => Topic started by: Core Xii on December 16, 2008, 01:43:50 pm
-
I'd like to use a software renderer, how would I go about accessing raw pixel data? Is sf::Image's SetPixel() fast enough for going through the entire image every frame?
-
It depends. For some applications, SFML might be enough to do software rendering. But for advanced rendering, there's no point and you will get better performances not using it.
Anyway, you can still do everything in memory and just upload your final bunch of pixels to the video memory with Image::LoadFromPixels. Should be fast enough, especially if the dimensions never change.
-
Anyway, you can still do everything in memory and just upload your final bunch of pixels to the video memory with Image::LoadFromPixels. Should be fast enough, especially if the dimensions never change.
That was my first thought, but the documentation said that loading an Image is slow. I suppose it's sufficiently fast, then? I presume it copies the data? And I should proceed to draw it as a Sprite?
-
That was my first thought, but the documentation said that loading an Image is slow
That's true, the three slower things are:
1- Accessing the pixels from a file on the disk
2- Creating an OpenGL texture
3- Uploading all the pixels in video memory
Since you're not using 1, and that 2 is optimized (i.e. skipped) when the same Image instance is reused with the same dimensions, your only concern is 3, which is optimized enough for real-time update.
I presume it copies the data?
Yes, both to system and video memory. In the future, there should be an option to skip the system memory copy when it's not necessary.
And I should proceed to draw it as a Sprite?
Absolutely.
-
Great, thank you for your assistance! :mrgreen: