NAME ^

SDL::App - Parrot extension for SDL Applications

SYNOPSIS ^

        # load this library
        load_bytecode 'library/SDL/App.imc'

        # create a new SDL::App object
        .local pmc app
        .local int app_type

        find_type app_type, 'SDL::App'
        app = new app_type

        # set the app's arguments
        .local pmc app_args
        app_args = new PerlHash
        app_args[ 'height' ] = 480
        app_args[ 'width'  ] = 640
        app_args[ 'bpp'    ] =   0
        app_args[ 'flags'  ] =   1

        # initialize the object and get the main surface
        .local pmc main_surface
        main_surface = app.'BUILD'( app_args )

        # go to town filling, blitting, and updating the app
        # for example:
        main_surface.update()

        ...

        # then, shut down cleanly
        app.'quit'()

DESCRIPTION ^

SDL::App is the entry point for all SDL Applications. It handles most of the other setup for you. Trust me, there's a little bit -- if you care, it will initialize the SDL library.

This object represents the main window and the associated drawing surface. There should only be one of those per program. As this represents an SDL::Surface object, you can call any method of that class on objects of this class.

Note: It's not yet complete. Please let me know if you have added or would like someone to add missing features.

METHODS ^

The SDL::App object has the following methods:

_new( app_args )

Initialize the new object with the necessary arguments. The single argument, app_args, should be a PerlHash PMC containing the following keys:

width

the width of the main window, in pixels

height

the height of the main window, in pixels

bpp

the ideal bit depth of the screen to create. Note that you may receive a screen of different (possibly lesser) capabilities, as that's what SDL does. If you pass 0 here, you'll receive the recommended bit depth.

flags

an integer value representing the proper SDL constants from SDL::Constants. See that module for ideas on what to pass here, or give me a better suggestion about the interface here.

This method returns an SDL::Surface object representing the main surface. Keep track of it; draw into it and update or flip it if you want to see anything.

The name of this method may change, pending better ideas discussed on p6i.

surface()

Returns the main surface. This is an SDL::Surface.

quit()

Quits the main window and shuts down SDL. You probably only have one shot at this.

height()

Returns the height of the main window, in pixels. This will likely move to SDL::Surface.

width()

Returns the width of the main window, in pixels. This will likely move to SDL::Surface.

bpp()

Returns the bit depth of the main window, in pixels.

AUTHOR ^

Written and maintained by chromatic, <chromatic at wgz dot org>, with suggestions from Jens Rieks. Please send patches, feedback, and suggestions to the Perl 6 Internals mailing list.

COPYRIGHT ^

Copyright (c) 2004, The Perl Foundation.


parrot