in reply to Re^2: SDL and Cairo segfault
in thread SDL and Cairo segfault

I used "no warnings" after I finished the script. Always "use warnings" is always the right thing, but, with SDL, it likes to keep sending out little messsages that aren't useful. That's why I used "no warnings".

I adjusted your script a little. It produces a red rectangle png. Give it a test drive.

#!/usr/bin/perl use strict; use Cairo; use SDL; use SDL::Video; use SDL::Surface; use SDL::Rect; use constant WIDTH => 400; use constant HEIGHT => 300; SDL::init(SDL_INIT_VIDEO); my $screen = SDL::Video::set_video_mode(WIDTH, HEIGHT, 32, SDL_SWSURFACE); my $surface = Cairo::ImageSurface->create( 'rgb24', WIDTH, HEIGHT); my $cr = Cairo::Context->create($surface); $0 =~ /(.*)\.pl/; my $out = "$1.png"; $cr->rectangle (0, 0, WIDTH, HEIGHT); $cr->set_source_rgb (255, 0, 0); $cr->fill; $cr->show_page; $surface->write_to_png ($out); SDL::quit();