VANYA wrote:I3I2UI/I0 wrote:&hff00 -> p[y] += 1 -> &hff01 = green
&hffFF -> p[y] += 1 -> &hff00 = green, the same color.
Why green?
y - Red
y+1 - Green
y+2 - Blue
y+3 - Alpha
Or i do not understand something?
P.S. Thanks for the answers
32bit color values in memory are layed out in groups of 4 bytes, each byte representing a different component of the color. Because you are using a 'Ubyte ptr' with a step size of 4, your loop is iterating over every 4th byte of memory which is where the blue component is stored.
Colors are &hAARRGGBB where AA is alpha, RR is red, GG is green, and BB is blue. Because of the endianess the low order byte comes first in memory and blue is actually the first byte: (blue) (green) (red) (alpha) (blue2) ...
Cyan is &h0000ffff or (255) (255) (0) (0)
If we have a Ubyte variable representing the blue component, 255 + 1 = 0 because of overflow and we get (0) (255) (0) (0) = &h0000ff00 = green.
Its seems you are thinking reversed blue/red. FB internal formats seem to be red/blue reversed relative to other graphics systems (VB/OpenGL), I had to correct for this when making VoxelGFX.
p[y] - Blue
p[y+1] - Green
p[y+2] - Red
p[y+3] - Alpha