use strict; no warnings; use SDL v2.3; use SDL::Video; use SDL::Surface; use Cairo; SDL::init(SDL_INIT_VIDEO); my $screen = SDL::Video::set_video_mode(400, 300, 32, SDL_SWSURFACE); SDL::Video::lock_surface($screen) if SDL::Video::MUSTLOCK($screen); my $surface = Cairo::ImageSurface->create_for_data ( $screen->get_pixels_ptr, 'argb32', $screen->w, $screen->h, $screen->pitch ); my $cr = Cairo::Context->create($surface); $cr->rectangle(10, 10, 40, 40); $cr->set_source_rgb(255, 0, 0); $cr->fill; SDL::Video::unlock_surface($screen) if SDL::Video::MUSTLOCK($screen); SDL::Video::flip($screen); SDL::delay(2000); SDL::quit();