Kartik Thakore

On 5-Feb-10, at 6:28 AM, Guillaume Cottenceau <gcott...@gmail.com> wrote:

Hi,

On Fri, Feb 5, 2010 at 3:49 AM, Kartik Thakore <thakore.kar...@gmail.com > wrote:
HI Guillaume,

Since most of the new SDL API is ready for frozen bubble I have started to
move FB over to it.  Here is my work so far
http://github.com/kthakore/frozen-bubble/tree/redesign you will need the
SDL_perl from here http://github.com/kthakore/SDL_perl/tree/redesign

Why have you removed the sugar in your new sdlpl?

The new SDL bindings are pure bindings because there was way two much coupling between the sugar and bindings in the last api. We are going to add the sugar back in with a seperate SDLX:: layer. The idea is for each library to do one thing and do it well. The modularization also allows us to split that behemoth SDL.xs file. This way bugs and feature are easier to fix and add.




However I am getting stuck at a particular location where you try to convert
SDL::Surface to a hash_ref or something and send it to
fb_c_stuff::rotate_bicubic

The conversion is done at the subroutine surf.

sub surf {
    my ($surface) = @_;
    $surfstyle ||= UNIVERSAL::isa($surface, 'HASH') ? 'hashref' :
'scalarref';
return $surfstyle eq 'hashref' ? $surface->{-surface} : $ $surface;
}

This is to be compatible with hashref style sdl (sdl 1.x I think) and
scalarref style sdl (sdl 2.x I think), to obtain the SDL_Surface*
needed for my XS stuff (rotate_bicubic and others).


Since there are no comments here I am at a loss. Currently SDL::Surface as Opaque Objects in the typemap to prevent memory leaks. You can see the

Why being opaque prevents memory leaks?

Because opaque objects can be handed over to Perl for gc and thus get DESTROYed at the right time. Also our opaque objects now keep track of which perl thread they have been create. This was the library is thread safe down to the object.




The code starts at line 2718.


        $canon{img}{$number} = SDL::Surface->new( SDL_ANYFORMAT,
$shooter->w, $shooter->h,  32, 0,0,0,0);
        fb_c_stuff::rotate_bicubic(surf($canon{img}{$number}),
surf($shooter), $angle);

What is the need for surf here?

Thanks for any help in advance.

Cheers
Kartik Thakore



Thank you.


--
Guillaume Cottenceau - http://zarb.org/~gc/

Reply via email to