Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sdl2

pperl-specific module built into the interpreter. Runtime: PP.

Native SDL2 module — dlopen-based SDL2 bindings with direct SDL2-style API.

Uses dlopen("libSDL2.so") at registration time. Exposes SDL2 functions directly with pointer handles as i64 scalars.

API

use SDL2;
SDL2::init(SDL2::INIT_VIDEO);
my $win  = SDL2::create_window("Title", $w, $h, $flags);
my $rend = SDL2::create_renderer($win, $flags);
my $tex  = SDL2::create_texture($rend, $w, $h);
## ... render loop ...
SDL2::update_texture($tex, $pixel_data, $pitch);
SDL2::render_clear($rend);
SDL2::render_copy($rend, $tex);
SDL2::render_present($rend);
my $type = SDL2::poll_event();  # returns event type or 0
SDL2::destroy_texture($tex);
SDL2::destroy_renderer($rend);
SDL2::destroy_window($win);
SDL2::quit();

Functions

INIT_AUDIO

INIT_EVERYTHING

INIT_TIMER

INIT_VIDEO

KEYDOWN

KEYUP

QUIT

RENDERER_ACCELERATED

RENDERER_PRESENTVSYNC

RENDERER_SOFTWARE

WINDOWPOS_UNDEFINED

WINDOW_FULLSCREEN

WINDOW_RESIZABLE

create_renderer

create_texture

Creates ARGB8888 streaming texture.

create_window

delay

destroy_renderer

destroy_texture

destroy_window

fill_rect

draw filled rect

get_error

get_ticks

init

poll_event

quit

render_clear

render_copy

render_mandelbrot_frame

Full Mandelbrot frame: compute + upload + present. All in native Rust with Rayon parallelism.

render_present

set_draw_color

update_frame

Takes an array ref of integer ARGB color values. No binary strings involved. This is the clean path — integers in, bytes out, no encoding issues.

update_texture

$pixel_data is a packed binary string of ARGB8888 pixels (perl5 path).