SFML community forums
Bindings - other languages => DotNet => Topic started by: mike919 on July 09, 2012, 10:57:50 pm
-
Hi,
I am trying to use SFML for some data visualization. I'm having some good success but I think my conversion can be simplified. My source data is 32 bit uint and can't be changed. Right now this is how my data gets processed.
2D uint array -> 8 bit rgba -> SFML.Image -> SFML.Texture -> SFML.Sprite
Then after the data is a sprite, I can do some very cool things with a GLSL fragment shader like assigning colormaps and thresholds to the data :) When I do the calculations in GLSL the pixel data is a float, although I don't know where this last conversion is done.
My question is, is there someway to bypass the conversion to 8 bit rgba? If I could go directly from the source uints to floats that would seems to be the best option. Depending on my GLSL calculations converting to 8 bit rgba could cause me to lose resolution in my final displayed result. I don't know openGL very well but from the research I've done it seems to support this. Am I going to have to bite the bullet and put some openGL calls in my C# code?
-
2D uint array -> 8 bit rgba -> SFML.Image -> SFML.Texture -> SFML.Sprite
SFML.Image is not needed. You're just copying pixels somewhere before copying them again somewhere else. There's no useful operation there.
8-bit RGBA is probably not needed either. If the components of your 32-bit pixels are already in the right order (RGBA) then they need no conversion, and can be passed directly to SFML.Texture.
When I do the calculations in GLSL the pixel data is a float, although I don't know where this last conversion is done.
It is done by the graphics card when it receives data. 32-bit uint is the most common pixel format, so don't worry, graphics cards are made for that. The conversion is super fast.
My question is, is there someway to bypass the conversion to 8 bit rgba? If I could go directly from the source uints to floats that would seems to be the best option
It may seem to be a good idea, but it's not. As I said, 32-bit uint is the most common (and optimized) pixel format. Floating point pixel formats are in fact a "modern" feature, and it's definitely not "optimized".
And you would have to convert manually your pixels to floats, whereas you can pass them almost directly to SFML.Texture if you keep them as 32-bit integers.