SDL::App - Parrot extension for SDL Applications


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

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

    app = new 'SDL::App'

    # set the app's arguments
    .local pmc app_args
    app_args = new 'Hash'
    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:


    # then, shut down cleanly


The parrot SDL libraries require the C SDL library: See for information on how to obtain and install this library.

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.


The SDL::App object has the following methods:

init( [ width => xxx ], [ height => xxx ], [ bpp => xx ], [ flags => xx ])
Initialize the new object with the necessary arguments. The named arguments areas follows:
the width of the main window, in pixels
the height of the main window, in pixels
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.
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.
Returns the main surface. This is an SDL::Surface.
Quits the main window and shuts down SDL. You probably only have one shot at this.
Returns the height of the main window, in pixels. This will likely move to SDL::Surface.
Returns the width of the main window, in pixels. This will likely move to SDL::Surface.
Returns the bit depth of the main window, in pixels.


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 (C) 2004-2008, The Perl Foundation.