Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transparency?

9 views
Skip to first unread message

Jack Maney

unread,
Jun 10, 2012, 4:35:49 AM6/10/12
to sdl-...@perl.org
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 old<http://www.velocityreviews.com/forums/t906303-problem-with-alphachannel-with-sdl-xxx-blitting.html> questions<http://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


Tobias Leich

unread,
Jun 10, 2012, 4:47:28 AM6/10/12
to Jack Maney, sdl-...@perl.org
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:

Alex

unread,
Jun 10, 2012, 12:42:22 PM6/10/12
to Tobias Leich, Jack Maney, sdl-...@perl.org
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-...@perl.org
Betreff: AW: Transparency?
-----
eMail ist virenfrei.
Von AVG überprüft - www.avg.de
Version: 2012.0.2177 / Virendatenbank: 2425/5054 - Ausgabedatum: 07.06.2012

Tobias Leich

unread,
Jun 10, 2012, 1:23:32 PM6/10/12
to Alex, Jack Maney, sdl-...@perl.org
These draw_something methods out of the SDLx packages just use blit at
the end anyway.

A tip: dont care about speed right now, just try to get things working.
Optimize at the end.

Cheers
0 new messages