Download Tutorial C Files H Files

dg_framebuffer_create

This function is used to initialize the framebuffer.

Usage

dg_framebuffer_t *dg_framebuffer_create(unsigned int width, unsigned int height);

Example

dg_framebuffer_t *fb = dg_framebuffer_create(200, 300);

Source code

dg_framebuffer_t *dg_framebuffer_create(unsigned int width,
    unsigned int height) {
    dg_framebuffer_t *fb = malloc(sizeof(dg_framebuffer_t));
    sfTexture *tex = sfTexture_create(width, height);
    sfSprite *sp = sfSprite_create();

    sfSprite_setTexture(sp, tex, sfFalse);
    fb->pixels = malloc(sizeof(sfUint8) * width * height * 4);
    fb->width = width;
    fb->height = height;
    fb->sp = sp;
    fb->thickness = 1;
    fb->border = 0;
    return fb;
}