AW: Transparency?
Hi! When do we use blit and when do we use draw_something? Is blit faster / better? Best regards, Alex -Ursprüngliche Nachricht- Von: Tobias Leich [mailto:em...@froggs.de] Gesendet: Sonntag, 10. Juni 2012 10:47 An: Jack Maney; sdl-devel@perl.org Betreff: AW: Transparency? Hi, you have to know that draw_rect works differently for your app surface and regular surfaces. If you draw to your app, the pixels just get the value of the color. But if you do this to a regular surface, and blit that to your app surface, the pixels will be blendet... So create a new surface, modify that, blit and update. Cheers Jack Maney jma...@adknowledge.com hat geschrieben: Hello, I'm not so terribly new to Perl but very new to SDL. I was fiddling with the following Hello, World!-ish code in the SDL manual: use strict; use warnings; use SDL; use SDLx::App; my $app = SDLx::App-new( width= 800, height = 600 ); $app-draw_rect([ $app-width / 4, $app-height / 4, $app-width / 2, $app-height / 2, ], [ 0, 0, 255, 255] ); $app-update(); sleep(5); and found that changing the alpha portion of the rectangle color (eg fading the rectangle out completely via [0,0,255,0]) had no effect on the rendering of the rectangle. I did some searching on this and found some oldhttp://www.velocityreviews.com/forums/t906303-problem-with-alphachannel-with-sdl-xxx-blitting.html questionshttp://markmail.org/message/lqtdvmmjmiryumrw#query:+page:1+mid:q63xng5hz7lpcsbl+state:results from 4+ years ago, but I'm wondering if there is a simple workaround or an approach that has come about since then. Thank you for your time, Jack - eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 2012.0.2177 / Virendatenbank: 2425/5054 - Ausgabedatum: 07.06.2012
AW: CPAN Testers Daily Summary Report
Hi! As I saw the MSWin32-x64-multi-thread / 5.14.2 report: I'm on MSWin32-x32-multi-thread / 5.14.2 (ActiveState Perl) here and it works fine. Best regards, Alex -Ursprüngliche Nachricht- Von: Kartik Thakore [mailto:thakore.kar...@gmail.com] Gesendet: Mittwoch, 23. Mai 2012 21:07 An: sdl-devel@perl.org; Tobias Leich Betreff: Fwd: CPAN Testers Daily Summary Report And we have some fails! SDL-2.538: - MSWin32-x64-multi-thread / 5.14.2: - FAIL http://www.cpantesters.org/cpan/report/26ee8b64-6bf6-1014-ad3c-44931eecb6a3 - x86_64-linux-thread-multi / 5.15.8: - FAIL http://www.cpantesters.org/cpan/report/5bd4ba90-a46b-11e1-a210-b03bf4b14d39 - x86_64-linux-thread-multi / 5.15.9: - FAIL http://www.cpantesters.org/cpan/report/a5aaaff4-a46a-11e1-8dfd-c832f4b14d39 - eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 2012.0.1913 / Virendatenbank: 2425/5017 - Ausgabedatum: 23.05.2012
Compiling SDL Perl scripts
Hi all! During my experiments with ActiveState's PDK and compiling my SDL Perl script (which is impossible atm), I came along this piece of support ticket: [snip] However, I think that will likely just be the tip of the iceberg. .\Makefile.PL: error: Can't locate .\Makefile.PL refby: C:\Perl\site\lib\ExtUtils\MakeMaker.pm line 232 ExtUtils\XSSymSet.pm: error: Can't locate ExtUtils\XSSymSet.pm refby: C:\Perl\site\lib\ExtUtils\ParseXS.pm line 90 suggests that Alien::SDL is compiling Perl XS modules on the fly. This is a design which will be incompatible with the PDK, as an application wrapped with the PDK will not use a standard Perl at runtime. [/snip] So, does Alien::SDL compile Perl XS modules on the fly? In case it is, what exactly does this mean and can it be done in another way? Best regards, Alex
AW: How to play an mp3 file from a database
Dear all! It took me quite some time, but I'm moving forward. Here are some screens from my vocabulary trainer: https://picasaweb.google.com/104129024313554475104/Vokabeltrainer?authuser=0 authkey=Gv1sRgCKLyn6SSwIvCgwEfeat=directlink Now I want to play a vocable audio file (that is of course, stored in a database :)). I can't use SDL::Mixer::Music for that, because there is already some background music playing. AFAIK I need to use SDL::Mixer::Samples. I tried it, but there occurred an error when using mp3 files: Cannot load music file [music/terminal.mp3]: Unrecognized sound file type at play_effect.pl line 34 Here is the script: [code] #!perl use strict; use warnings; use utf8; use SDL; use SDL::Event; use SDL::Events; use SDLx::App; use SDLx::Controller; use SDL::Mixer; use SDL::Mixer::Music; use SDL::RWOps; use SDL::Mixer::Samples; use SDL::Mixer::Channels; SDL::init(SDL_INIT_AUDIO); SDL::Mixer::init( MIX_INIT_MP3 | MUS_MP3 ); my $app = SDLx::App-new( title = 'play mp3 effect', exit_on_quit = 1, ); unless( SDL::Mixer::open_audio( 44100, AUDIO_S16SYS, 2, 4096 ) == 0 ) { Carp::croak Cannot open audio: .SDL::get_error(); } my $file = 'music/terminal.mp3'; #my $file = 'music/br_crossing_bell_dop.r.wav'; #my $file = 'music/Windows Logon Sound.wav'; my $sample = SDL::Mixer::Samples::load_WAV( $file ); unless( $sample ) { Carp::croak Cannot load music file [$file]: . SDL::get_error(); } my $playing_channel = SDL::Mixer::Channels::play_channel( -1, $sample, 0 ); $app-run(); SDL::Mixer::Music::halt_music(); SDL::Mixer::close_audio; exit(0); [/code] There also occurred some other errors using .wav files: - Cannot load music file [music/br_crossing_bell_dop.r.wav]: Complex WAVE files not supported at play_effect.pl line 34 - Cannot load music file [music/Windows Logon Sound.wav]: MPEG Layer 3 data not supported play_effect.pl line 34 But, I only want to play mp3 files. Maybe you can hint me at the solution for this problem? How can I play an mp3 file once, e.g. on a button click event? Best regards, Alex -Ursprüngliche Nachricht- Von: breno [mailto:oainikus...@gmail.com] Gesendet: Dienstag, 29. November 2011 06:34 An: Alexander Becker Cc: sdl-devel@perl.org Betreff: Re: How to play an mp3 file from a database On Mon, Nov 28, 2011 at 8:13 PM, Alexander Becker alexanderbec...@gmx.net wrote: Dear all! Hi there! I just tried the example code of the SDL Manual where you play some music. By the SDL manual, I refer to the one that is hidden at the bottom of the sdl.perl.org page, so that you really have to search for it in order to find it - and even then you have to get along with an ugly github interface. There's a new project website under way, but we're missing people to work in it. Please join #sdl in irc.perl.org if you want to help us get it right :) So, in general: Is there a way to play mp3 files? Yup. If your libsdl was compiled with mp3 support, all you have to do (iirc) is set the MIX_INIT_MP3 (for effects) and MUS_MP3 (for audio) flags when you call SDL::Mixer::init(): SDL::Mixer::init( MIX_INIT_MP3 | MUS_MP3 ); then use load_MUS() and play_music() from SDL::Mixer::Music to play mp3 files as background music, or load_WAV() from SDL::Mixer::Samples to play mp3 effects (yes, the function is named load_WAV() but plays different formats too if they're available). The documentation in SDL::Mixer, SDL::Mixer::Music and SDL::Mixer::Samples should be helpful, as some of the test files (t/mixer_music.t comes to mind). And in particular: is there a way to play mp3 files that are in a variable? Or do I have to work with temporary files? Not sure. I *think* SDL::Mixer::quick_load_WAV( $buffer ) might do the right thing. You'll have to test it though. Cheers, breno
AW: How to play an mp3 file from a database
Hi! Ok, now I don't get any error when playing mp3 files from the database, but I don't get any sound either. I updated Alien::SDL to the latest version, that worked. However, SDL itself didn't pass the tests, it's the channels test that fails. So I installed with force, but no change. Is there anything in particular I could do to provide information about the error that occurs with the cannels test? Any information you need to fix this issue (in case it is one)? Best regards, Alex [snip] Test Summary Report --- t\core.t (Wstat: 0 Tests: 28 Failed: 0) TODO passed: 21-22 t\core_video.t(Wstat: 0 Tests: 110 Failed: 0) TODO passed: 57, 59 t\mixer_channels.t(Wstat: 65280 Tests: 35 Failed: 0) Non-zero exit status: 255 Parse errors: No plan found in TAP output Files=59, Tests=3942, 233 wallclock secs ( 0.94 usr + 0.23 sys = 1.17 CPU) Result: FAIL Failed 1/59 test programs. 0/3942 subtests failed. (C:\strawberry\perl\bin\perl.exe ./Build test exited with 65280) CPAN::Reporter: Test result is 'fail', One or more tests failed. CPAN::Reporter: preparing a CPAN Testers report for SDL-2.536 CPAN::Reporter: this appears to be a duplicate report for the test phase: FAIL SDL-2.536 MSWin32-x64-multi-thread 6.1 Test report will not be sent. FROGGS/SDL-2.536.tar.gz C:\strawberry\perl\bin\perl.exe ./Build test -- NOT OK //hint// to see the cpan-testers results for installing this module, try: reports FROGGS/SDL-2.536.tar.gz Running Build install make test had returned bad status, won't install without force Failed during this command: FROGGS/SDL-2.536.tar.gz : make_test NO [/snip] -Ursprüngliche Nachricht- Von: Tobias Leich [mailto:em...@froggs.de] Gesendet: Sonntag, 22. April 2012 19:31 An: Alex Betreff: Re: How to play an mp3 file from a database Hi Alex, At first, you are on windows and used the prebuklt libSDL binaries shipped with Alien::SDL? If yes, mp3 should be supported, but only files without VBR. So please try a few mp3 files and maybe check how it is encoded. Then, to play an mp3 file from a database, do somethind like: use DBI; use SDL; use SDL::Mixer; use SDL::Mixer::Channels; use SDL::Mixer::Samples; use SDL::RWOps; $dbh-prepare(SELECT music FROM ...); $sth = $dbh-execute(); if( $row = $sth-fetchrow_hashref ) { $rwops = SDL::RWOps-new_const_mem( $row-{music} ); $chunk = SDL::Mixer::Samples::load_WAV_RW( $rwops, 0 ); SDL::Mixer::Channels::play_channel( -1, $chunk, 1 ); } Cheers, FROGGS Am 22.04.2012 18:35, schrieb Alex: Dear all! It took me quite some time, but I'm moving forward. Here are some screens from my vocabulary trainer: https://picasaweb.google.com/104129024313554475104/Vokabeltrainer?auth user=0 authkey=Gv1sRgCKLyn6SSwIvCgwEfeat=directlink Now I want to play a vocable audio file (that is of course, stored in a database :)). I can't use SDL::Mixer::Music for that, because there is already some background music playing. AFAIK I need to use SDL::Mixer::Samples. I tried it, but there occurred an error when using mp3 files: Cannot load music file [music/terminal.mp3]: Unrecognized sound file type at play_effect.pl line 34 Here is the script: [code] #!perl use strict; use warnings; use utf8; use SDL; use SDL::Event; use SDL::Events; use SDLx::App; use SDLx::Controller; use SDL::Mixer; use SDL::Mixer::Music; use SDL::RWOps; use SDL::Mixer::Samples; use SDL::Mixer::Channels; SDL::init(SDL_INIT_AUDIO); SDL::Mixer::init( MIX_INIT_MP3 | MUS_MP3 ); my $app = SDLx::App-new( title = 'play mp3 effect', exit_on_quit = 1, ); unless( SDL::Mixer::open_audio( 44100, AUDIO_S16SYS, 2, 4096 ) == 0 ) { Carp::croak Cannot open audio: .SDL::get_error(); } my $file = 'music/terminal.mp3'; #my $file = 'music/br_crossing_bell_dop.r.wav'; #my $file = 'music/Windows Logon Sound.wav'; my $sample = SDL::Mixer::Samples::load_WAV( $file ); unless( $sample ) { Carp::croak Cannot load music file [$file]: . SDL::get_error(); } my $playing_channel = SDL::Mixer::Channels::play_channel( -1, $sample, 0 ); $app-run(); SDL::Mixer::Music::halt_music(); SDL::Mixer::close_audio; exit(0); [/code] There also occurred some other errors using .wav files: - Cannot load music file [music/br_crossing_bell_dop.r.wav]: Complex WAVE files not supported at play_effect.pl line 34 - Cannot load music file [music/Windows Logon Sound.wav]: MPEG Layer 3 data not supported play_effect.pl line 34 But, I only want to play mp3 files. Maybe you can hint me at the solution for this problem? How can I play an mp3 file once, e.g. on a button click event? Best regards, Alex -Ursprüngliche Nachricht- Von: breno [mailto:oainikus...@gmail.com] Gesendet: Dienstag, 29. November 2011 06:34 An: Alexander Becker Cc: sdl-devel@perl.org Betreff: Re: How to play an mp3 file from a database On Mon, Nov 28, 2011
AW: SDL::Event - invalid button_state on SDL_MOUSEMOTION ?
Ah, thanks! Now it works fine. Here is the code, maybe someone knows a better or more efficient way to do it: [code] #!perl use strict; use warnings; use SDL; use SDLx::App; use SDL::Event; # for the event object itself use SDL::Events; # functions for event queue handling my $app = SDLx::App-new( title = 'text wrap', exit_on_quit = 1, init = SDL_INIT_VIDEO ); $app-add_show_handler( \render ); $app-add_event_handler( \handle_events ); $app-run(); exit(0); sub handle_events { my $event = shift; my $controller = shift; my ($mask, undef, undef) = @{ SDL::Events::get_mouse_state( ) }; if( $event-type == SDL_MOUSEMOTION !($mask SDL_BUTTON_LMASK) ) { print mousemotion and no left key pressed\n; }elsif( $event-type == SDL_MOUSEMOTION ($mask SDL_BUTTON_LMASK) ) { print mousemotion with left key pressed\n; } return; } # /handle_events sub render { my ($delta, $app) = @_; $app-update(); return; } # /render [/code] -Ursprüngliche Nachricht- Von: Tobias Leich [mailto:em...@froggs.de] Gesendet: Dienstag, 31. Januar 2012 09:13 An: Alex Cc: sdl-devel@perl.org Betreff: Re: SDL::Event - invalid button_state on SDL_MOUSEMOTION ? Documentation tells that you have to use -motion_state instead of -button_state. See: http://sdl.perl.org/SDL-Event.html#Mouse_motion_events -- Cheers, Tobias Am 30.01.2012 23:23, schrieb Alex: Dear all! I'm still working on this kind of button-like widget and I want to implement the behaviour when hovering over the button. Unfortunately, the button_state does not work as I expected (maybe I expected it wrong). When I click somewhere, continue to hold down the mouse button (so there is no SDL_MOUSEBUTTONUP event) and move the mouse, shouldn't $event-button_state return SDL_PRESSED (which is 1)? Because, using the script attached, I always get SDL_RELEASED (0). The single case where I get SDL_PRESSED is when I check it on SDL_MOUSEBUTTONDOWN. So, is this behaviour intended? Or, to ask it in another way: do I have to keep track of the SDL_MOUSEBUTTONUP event myself in order to determine if the user still holds down the mouse button? Kind regards, Alex #!perl use strict; use warnings; use SDL; use SDLx::App; use SDL::Event; # for the event object itself use SDL::Events; # functions for event queue handling my $app = SDLx::App-new( title = 'text wrap', exit_on_quit = 1, init = SDL_INIT_VIDEO ); $app-add_show_handler( \render ); $app-add_event_handler( \handle_events ); $app-run(); exit(0); sub handle_events { my $event = shift; my $controller = shift; if( $event-type == SDL_MOUSEMOTION ) { printf Button state: [%s]\n,$event-button_state; } return; } sub render { my ($delta, $app) = @_; $app-update(); return; } # /render - eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 2012.0.1901 / Virendatenbank: 2109/4776 - Ausgabedatum: 30.01.2012
AW: Revamping SDL_Manual
Hi Kartik, I had a look at Agar and I didn't find it that useful. One would stick with just another UI framework, that runs on SDL and has another design philosophy (GUI around the app, not vice versa). In the end, you still face the question, how you would do it yourself. Have a look at current games. Starcraft has its own kind of menu with a rotating planet and a hover event, warcraft series has some sort of animated moving menu (with hover, too) and battlefield 1942 even has a video as background (which I find quite fascinating, is this possible with SDL, too?). They don't use the same set of UI items. But they all use the same kind of logic. There are UI items and events attached to them. How they are forged, drawn, if they are 3d models or surfaces doesn't matter. That's where the interesting part begins. How do you create such an interactive item? And how to use it? And would there be other ways of doing it? Maybe a gentle reader would explore such a way. The single thing I really would appreciate out of the Agar package would be the table, as I imagine this a whole lot of work. I would like to use a drop-in for that :) Please note: I hope my word choice doesn't sound that negative, it isn't intended that way. English is simply not my native language. Best regards, Alex -Ursprüngliche Nachricht- Von: Kartik Thakore [mailto:thakore.kar...@gmail.com] Gesendet: Dienstag, 10. Januar 2012 15:13 An: Alexander Becker Cc: chroma...@wgz.org; sdl-devel@perl.org Betreff: Re: Revamping SDL_Manual On 2012-01-10, at 2:03 AM, Alexander Becker cap...@gmx.de wrote: Hi Kartik, I recently started working with the SDL Manual, but I don't have a game in mind. Regardless of that, I find it very useful to see the things you can do with SDL demonstrated with games. What I'm missing so far, and what is part of every game, too, is UI stuff. How do buttons work with SDL, how do you change the state of a button element (normal, active, hover, diabled, etc.) and how do you encapsulate such UI elements properly. Perhaps getting Agar working again in perl will help? Http://libagar.org/ Basically, I'm still experimenting to find a way to create a good button class for a menu. I know there is a package out there that provides methods for drawing menus, but especially when writing your own games / apps, I guess one might want to implement its own kind of menu with nifty nice effects, layout and so on. Hmm we would love it if you can provide feedback/issues on the SDLx::Widgets github site. So this is my idea: add a chapter on UI elements (not only buttons, but (high-score-tables, text fields etc.). Unfortunately, all I can add to this project so far (I'm still a SDL n00b) are possibly dumb questions. For example, I don't know how to adjust a text on a surface for a button. By adjusting, I mean something like aligning to the left or the right or automatically splitting the text up an breaking into a new line when a given with would be exceeded (I'm generating buttons with unknown text length, which is quite problematic). Seems like a good idea. Thanks. hth, Alex Kartik Original-Nachricht Datum: Mon, 9 Jan 2012 16:34:25 -0500 Von: Kartik Thakore thakore.kar...@gmail.com An: sdl-devel@perl.org, chromatic chroma...@wgz.org Betreff: Revamping SDL_Manual Hello guys, So as I have gotten busy over the last couple months with my startup and masters the SDL Manual has fell behind, and I would like to ask if anyone is interested in taking on writing new chapters or reorganizing SDL Manual. We can discuss any new chapters to add and work with reorganize it. An idea I have is to change the name to Perl Game Development and incorporate more then just SDL chapters into the manual. Any suggestions are welcome! Regards, Kartik -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone - eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 10.0.1416 / Virendatenbank: 2109/4132 - Ausgabedatum: 09.01.2012
AW: SDLx::Text - replace old text?
So, when I have an application, that uses a background image (which is the origincal background for my question), the appropriate way to redraw a text would be: - calculate the surface of a text one wants to draw - store this specific piece of the old surface somewhere - draw the text now, when redrawing the text: - blit the old surface over the text surface - repeat the above 3 steps for the new text Or is it done in another way? I'm not that familiar with SDL programming, maybe I'm just doing it wrong. Best regards joyeux noel, Alex -Ursprüngliche Nachricht- Von: Dominique Dumont [mailto:domi.dum...@free.fr] Gesendet: Sonntag, 25. Dezember 2011 10:24 An: sdl-devel@perl.org Betreff: Re: SDLx::Text - replace old text? Le Friday 23 December 2011 21:02:17, Kartik Thakore a écrit : Regarding the surface, SDLx::App is a SDLx::Surface. That's what I was referring to. I don't think it's safe to make any assumptions about what's behind the text, so it should be the module user's responsibility to clear whatever is behind it. Hmm can we just not make the blit for clearing the text surface? Cause it wraps an sdl::surface. Don't go that way: next thing user will ask is to restore what was behind the text on the surface. Dominique -- http://config-model.wiki.sourceforge.net/ -o- http://search.cpan.org/~ddumont/ http://www.ohloh.net/accounts/ddumont -o- http://ddumont.wordpress.com/
SDLx::Text - replace old text?
Dear all! I want to replace an SDLx::Text by some other text. Do I have to redraw the whole surface that was covered by the old text in order to replace it by a new text? The following script demonstrates my problem: [code] #!perl use strict; use warnings; use SDL; use SDL; use SDLx::App; use SDLx::Text; my $app = SDLx::App-new( exit_on_quit = 1, ); my $message = SDLx::Text-new; $message-write_to( $app, Hello, World! ); $app-update; $message-text('Susan'); $message-write_to( $app ); $app-update(); $app-run(); [/code] First, the text Hello World! is drawn to the surface. Then, I alter the text and draw it again. But the old hello world text still remains on the surface. I don't want that. I want Hello World! to disappear and Susan so show up. How do I do that? Best regards, Alex
How to draw image sections
Dear all! I would like to draw a menu like the one in the game TRAUMA (cf. http://images.netzwelt.de/thumb/27/2011/4322/32288-test-trauma.jpg no, I don't want to code a game). So, it's basically 4 picture slides in a row. For testing purposes, I assume my window to be 640x400. Each of the 4 pics should have 160 x 400 px. I need to load each one of the 4 images and blit them to the surface. How do I do that? Here is what I got so far and I don't see anything else than a black screen with 640 x 400 pixels :-s [code] #!perl use strict; use warnings; use utf8; use Data::Dumper qw/Dumper/; use SDL; use SDLx::Surface; use SDL::Event; use SDL::Events; use SDLx::App; use SDL::Image; # create our main screen my $app = SDLx::App-new( w = 640, h = 400, exit_on_quit = 1, dt = 0.2, title = 'SDLx Menu' ); $app-update(); # make it black my $some_jpg_file = 'images/1-0d5ff539c7a3d166.jpg'; my $image = SDL::Image::load( $some_jpg_file ); $app-blit_by( $image, [0, 0, 160, 400], ); $app-run(); # -- Cleanup. exit(0); [/code] And, is it possible to extract a picture section from the image loaded? In case the app is loaded with 4:3 aspect ratio, I would like to snip a bit of the images at the left and the right, so that the pictures fit in without the need of black bars at the top and the bottom of the screen. Best regards, Alex