1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
typedef struct s_my_framebuffer
{
sfUint8 *pixels;
int width;
int height;
} t_my_framebuffer;
t_my_framebuffer* my_framebuffer_create(int width, int height)
{
t_my_framebuffer *framebuffer;
if ((framebuffer = malloc(sizeof(t_my_framebuffer))) == NULL)
return (NULL);
if ((framebuffer->pixels = malloc((sizeof(sfUint8)) * (width * height))) == NULL)
return (NULL);
framebuffer->width = width;
framebuffer->height = height;
return (framebuffer);
}
int main(int argc, char **argv)
{
sfVideoMode mode;
sfRenderWindow* window;
t_my_framebuffer* framebuffer;
sfTexture* texture;
sfColor color;
mode.width = 1000;
mode.height = 1000;
window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL);
if (window == NULL)
return (-1);
if ((framebuffer = my_framebuffer_create(1000,1000)) == NULL)
return (-1);
if ((texture = sfTexture_create(1000, 1000)) == NULL)
return (-1);
sfTexture_updateFromPixels(texture, framebuffer->pixels, framebuffer->width, framebuffer->height, 0, 0);
while(42)
{
sfRenderWindow_display(window);
}
sfRenderWindow_destroy(window);
return (0);
} |