Handmade Hero»Forums»Code
Kareem
7 posts
Day 004 - Switching Blue and Green var types
Hello,
In the last few minutes of day 004, Casey switched to updating 32 bit updates instead of individual 4 8 byte updates:
1
2
3
4
            uint8 Blue = X + XOffset;
            uint8 Green = Y + YOffset;
            *Pixel = ((Green << 8) | Blue);
            Pixel++;


Before Casey did that I stopped the video to try to do it myself. And I did almost the same code with 1 difference:
1
2
3
4
            uint32 Blue = X + XOffset;
            uint32 Green = Y + YOffset;
            *Pixel = ((Green << 8) | Blue);
            Pixel++;


When I did this I got a different result. My animation produced squares that have some kind of stripes. You can find an image attached. Any pointers on what is the difference here between uint8 and uint32?
[attachment=56]Output.jpg[/attachment]
Kareem
7 posts
Day 004 - Switching Blue and Green var types
Oops, my bad. I got now after a little debugging. When uint32 vars are used, value chopping doesn't happen any more like the uint8 case. So the values don't cycle through 0 to 255 anymore.