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

Keyed Access to ManagedStruct, part two

6 views
Skip to first unread message

Chromatic

unread,
Feb 10, 2004, 12:01:10 AM2/10/04
to perl6-i...@perl.org
I've just checked in another SDL example,
examples/sdl/move_parrot_logl.imc. This example uses the cursor keys to
move the logo around. Hitting escape or closing the window exits the
program.

To make the image handling work (and it (ab)uses objects, so that
part'll need to change in the near future), I had to hard-code the image
size.

Applying the attached patch will demonstrate my current problem in keyed
access to a ManagedStruct. It's not for checkin. It's only here to
demonstrate the problem.

Bugfixes and advice warmly welcomed.

-- c


access_surface.patch

Leopold Toetsch

unread,
Feb 10, 2004, 4:27:42 AM2/10/04
to Chromatic, perl6-i...@perl.org
Chromatic <chro...@wgz.org> wrote:

> To make the image handling work (and it (ab)uses objects, so that
> part'll need to change in the near future), I had to hard-code the image
> size.

You seem to be mixing params for _SDL_Image_draw():
screen, surface, color <-> parrot, screen, color

So 'parrot -t' thinks that you are accessing an UnManagedStruct (w/o
attached layout) by object attribute accessors.

That's as of current CVS.

> Applying the attached patch will demonstrate my current problem in keyed
> access to a ManagedStruct. It's not for checkin. It's only here to
> demonstrate the problem.

> .sub _SDL_Surface_height prototyped
> .param pmc surface
>
> + .sym pmc layout
> + layout = _SDL_Surface_layout()
> + assign surface, layout

You sould probably attach the structure layout, when the Surface is
created.

BTW: could you change the INIT_Flags to 0x21 or so (doesn't trigger
loading of esd if that's not running)

leo

Chromatic

unread,
Feb 20, 2004, 1:20:48 AM2/20/04
to l...@toetsch.at, perl6-i...@perl.org
On Tue, 2004-02-10 at 01:27, Leopold Toetsch wrote:

> You sould probably attach the structure layout, when the Surface is
> created.

Good idea. I've done this for surfaces, screens, and images. Now we
can use images of different sizes than Leon's parrot logo.

I figured out the segfault problem. Inline struct definitions of this
sort (taken from the declaration of SDL_Surface):

/* info for fast blit mapping to other surfaces */
struct SDL_BlitMap *map; /* Private */

require .DATATYPE_PTR, not .DATATYPE_STRUCT_PTR. Since there is no
struct body, I wasn't attaching a '_struct' property, which of course
caused segfaults in calc_offsets() in unmanagedstruct.c.

Fixed now.

> BTW: could you change the INIT_Flags to 0x21 or so (doesn't trigger
> loading of esd if that's not running)

Also fixed.

When Jens and I are satisfied with a flag scheme, I'll change the
examples. For now, it's 32, which should suffice.

-- c

0 new messages