X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2Fblog-0019.html-inc;h=e65be37dd7211e92b433042690e9c72fb1ba4899;hb=ca0a3441dd72000cbbbb4be484b18d0d305fdb29;hp=464b6583b16a3e895757406ada41abb06276ab5c;hpb=50ebf4949c9eed8f2d3fb629f12d11e95ec4e938;p=sdlgit%2FSDL-Site.git diff --git a/pages/blog-0019.html-inc b/pages/blog-0019.html-inc index 464b658..e65be37 100644 --- a/pages/blog-0019.html-inc +++ b/pages/blog-0019.html-inc @@ -1,6 +1,36 @@
This is the first time perldoc has disappointed me. The example on perlxs is wrong and fails. I do not wish to flame writers of perlxs but please check that your examples work! Ironically I know that broken tutorials is a problem with SDL perl too.
If anyone can point me to the simplest working exaple of XS with a c struct, it would be greatly appreciated.
#!/usr/bin/env perl + +use SDL; +use SDL::Events; +use SDL::Event; +use SDL::Video; + +SDL::init(SDL_INIT_VIDEO); + +my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); +my $event = SDL::Event->new(); + +while(1) +{ + SDL::Events::pump_events(); + + if(SDL::Events::poll_event($event) && $event->type == SDL_ACTIVEEVENT) + { + print "Hello Mouse!!!\n" if ($event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); + print "Bye Mouse!!!\n" if (!$event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) ); + } + + exit if($event->type == SDL_QUIT); +}+ \ No newline at end of file