Download Tutorial C Files H Files

dg_fb_putpx

This function modify a pixel of a framebuffer.

Usage

int dg_fb_putpx(dg_framebuffer_t *fb, unsigned int x, unsigned int y, sfColor color);

Example

dg_fb_putpx(fb, 500, 50, sfRed);

Source code

int dg_fb_putpx(dg_framebuffer_t *fb, unsigned int x,
    unsigned int y, sfColor color)
{
    if (x >= fb->width || y >= fb->height)
        return 1;
    int pos = (x + y * fb->width) * 4;
    fb->pixels[pos] = color.r;
    fb->pixels[pos + 1] = color.g;
    fb->pixels[pos + 2] = color.b;
    fb->pixels[pos + 3] = color.a;
    return 0;
}