3 ms·
There is at least two bugs in the blog post, here: Next simple task would be to fill the complete framebuffer with a solid colour: memset(f->buf, rgb, f->
by unwind 1y ago
There is at least two bugs in the blog post, here:
Next simple task would be to fill the complete framebuffer with a solid colour:
memset(f->buf, rgb, f->width*f->height*sizeoof(uint32_t));
The first is the obvious typo around `sizeof`, which I didn't even see at first (edit: this).
The second is that code will only work for 8-bit colors, i.e. only the 8 (technically CHAR_BIT, "a byte") least-significant bits of `rgb` will be used. This is a quirk of the `memset()` standard C function, which has the prototype:
void *memset(void s[.n], int c, size_t n);
but then the man page [1] says:
The memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c.
[1]: https://man7.org/linux/man-pages/man3/memset.3.html https://man7.org/linux/man-pages/man3/memset.3.html
- deleted 1y ago[deleted]
- naruhodo 1y agoIt will fill the screen with any of 256 shades of grey, for which r == g == b.