In my previous example I said you could draw images on the screen of an SDL2 window. Here's how you create a texture (or surface) which has width 320 and height 200. Think of it as a rectangle where you can draw on :
use SDL2::Raw; my $tile = SDL_CreateTexture($renderer, RGBA8888, STREAMING, 320, 200);
To put pixels on the $tile texture, you can update the texture with an array of pixels (pixelpoints on the surface) Each pixel is 32 bits wide in SDL2, there is red, green blue and an alpha (transparent) channel (RGBA8888, where 8+8+8+8=32 bits).
my $data = 0; ### pixelbuffer is empty sub render { SDL_UpdateTexture($tile, NULL, $data, 320*32); ### update 32 bits of 3 +20 pixels }

Replies are listed 'Best First'.
Re: Perl 6 SDL2 example - continued
by holyghost (Beadle) on Jul 10, 2016 at 06:36 UTC
    To correct:
    my @data; my $tile = SDL_CreateTexture($render, %PIXELFORMAT<ARGB8888>, TARGET, +320, 200);
    Then posting the tile to the viewport (this belongs in the render function):
    my SDL_Rect $src .= new: x => 0, y => 0, w => 320, h => 200; SDL_RenderCopy($render, $tile, $src, SDL_Rect); ### blits the data arr +ay of, in this case 32 bit wide pixels (ARGB8888)