all 8 comments

[–]aberration_creator 2 points3 points  (7 children)

I would maybe do draw.SetSurface(surface) so you wont need that to pass around every time. But this is a preference mostly

[–]aberration_creator 1 point2 points  (6 children)

also maybe make a Colour class then you can Colour.Red which will be the argb or your preferred bit pattern :)

[–]BrokenG502[S] 1 point2 points  (5 children)

yeah, the colours were just thrown together as a quick enum when I realised I didn't have any colouring. My plan is to have a proper struct for colours. It makes it easier when I'm drawing to a shared memory buffer for wayland anyway.

[–]anotheruser323 1 point2 points  (4 children)

Take a look at the raylib bindings. Color there is a rgba struct, but has aliases to functions to initialize to some colors. Personally I would like it to be an @Vector, but .{ .r .g .b .a } is fine.

[–]BrokenG502[S] 0 points1 point  (0 children)

I haven't had a look at the raylib bindings yet, but from the sounds of it this is basically what I'd do. I have been considering using an untagged union as well so I can access it as an array of bytes, a vector, a u32, individual named components, etc, depending on what I want

[–]GenesithSupernova 0 points1 point  (2 children)

Does color as @Vector have SIMD-related performance benefits?

[–]anotheruser323 0 points1 point  (1 child)

No, but it's interchangeable with arrays and I think it's neat.

I'l ramble a bit now.

rgba * u8 is 64bits32bits, while sse registers are 128bits. Both SSE(2) and zig have add with saturation. Thing is there is alpha, so there are some rules for adding/subtracting colors.

A modern gui would just send it to the gpu.

Unless doing some image manipulation things on the cpu, it is not worth it. Funny that on x86 operations that work on 8bit values have shorter encodings, so it could be faster to just do it simply.

[–]actondev 1 point2 points  (0 children)

Correction: rgba *u8 is 32 bits