SomeNetworkGuy has asked for the wisdom of the Perl Monks concerning the following question:

From the documentation, I'm trying to set video mode and get the returned surface.

my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_ANYFORMAT) or die "$!\n";

But I am getting this error when I run it.

No such file or directory

Out of curiosity I did this:

my $screen_surface = SDL::Video; $screen_surface->set_video_mode($screen_width, $screen_height, 32, SD +L_ANYFORMAT) or die $!;

And it told me how to use it...

Usage: SDL::Video::set_video_mode(width, height, bpp, flags) at ./test.pl line 16.

Any ideas on how to go about troubleshooting this? I'm reasonably certain SDL Perl is installed properly, as I don't get errors upon 'using' the SDL modules.

Replies are listed 'Best First'.
Re: Setting Video Mode in SDL
by Corion (Patriarch) on Nov 08, 2010 at 08:18 UTC
Re: Setting Video Mode in SDL
by Khen1950fx (Canon) on Nov 07, 2010 at 23:54 UTC
    SDL::Video can be diffficult to install and use. Here's a list of dependencies and a Makefile.PL that I used to install SDL. The documentation's SYNOPSIS gives a working example of usage. Here it is:
    #!/usr/bin/perl use strict; use warnings; use SDL; use SDL::Video; use SDL::Surface; use SDL::Rect; my $screen_width = 800; my $screen_height = 600; SDL::init(SDL_INIT_VIDEO); my $screen_surface = SDL::Video::set_video_mode( $screen_width, $screen_height, 32, SDL_ANYFORMAT); my $mapped_color = SDL::Video::map_RGB( $screen_surface->format(), 0, 0, 255); SDL::Video::fill_rect($screen_surface, SDL::Rect->new( $screen_width / 4, $screen_height / 4, $screen_width / 2, $screen_height / 2), $mapped_color); SDL::Video::update_rect( $screen_surface, 0, 0, $screen_width, $screen_height); sleep(5); SDL::quit();

      I think I may be making progress. That example you gave is what I was using. After running your CPAN install script (woowee that is a lot of stuff) I had an issue running your Build.PL script.

      Gonna use 'My::Builder::Unix' class ... Require 'My::Builder::Unix' failed: Can't locate My/Builder/Unix.pm in + @INC

      Assuming I should've used the My/Builder/* files in the Alien::SDL package, I copied them over, but got another error

      Can't locate object method "find_subsystems" via package "My::Builder: +:Unix" at Build.PL line 526.

      Where and what version is the My::Builder::Unix class in your Build script coming from?

      Using the Build.PL that comes with SDL Perl, the Build test gives these results.
      root@sw:~/sdl/SDL_Perl-v2.2.6# ./Build test t/apppm.t .......... ok t/cdrompm.t ........ ok t/colorpm.t ........ ok t/cursorpm.t ....... ok t/eventpm.t ........ ok t/fontpm.t ......... ok t/manifest.t ....... skipped: Author tests not required for installati +on t/mixerpm.t ........ ok t/mpegpm.t ......... skipped: smpeg support not compiled t/musicpm.t ........ ok t/opengl.t ......... ok t/palettepm.t ...... ok t/rectpm.t ......... ok t/sdlgamerect.t .... ok t/sdlpm.t .......... ok t/soundpm.t ........ ok t/surfaceML.t ...... skipped: Author tests not required for installati +on t/surfacepm.t ...... ok t/timerpm.t ........ ok t/toolfontpm.t ..... ok t/toolgraphicpm.t .. skipped: SDL_gfx support not compiled t/ttfontpm.t ....... ok t/videopm.t ........ skipped: smpeg support not compiled All tests successful. Files=23, Tests=184, 2 wallclock secs ( 0.12 usr 0.25 sys + 1.03 cu +sr 0.50 csys = 1.90 CPU) Result: PASS

      The t/videopm.t being skipped seems like something to be concerned about. I thought I saw smpeg being installed as a dependency in that CPAN script?

      Currently, when I run the SDL test script, I get this.

      Use of inherited AUTOLOAD for non-method SDL::init() is deprecated at +./test.pl line 14. Can't locate auto/SDL/init.al in @INC

      I changed that part of the code to SDL->init() and got this  Can't locate auto/SDL/init.al in @INC Is it safe to assume that that init() sub should get installed when t/videopm.t isn't 'skipped'?

Re: Setting Video Mode in SDL
by PeterPeiGuo (Hermit) on Nov 07, 2010 at 23:16 UTC

    Try to add this first:

    SDL::init(SDL_INIT_VIDEO);

    Peter (Guo) Pei