NAME ^

SDL::App - Parrot extension for SDL Applications

SYNOPSIS ^

    # 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:
    main_surface.update()

    ...

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

DESCRIPTION ^

The parrot SDL libraries require the C SDL library: See http://www.libsdl.org/ 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.

METHODS ^

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:

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.

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-2008, The Perl Foundation.


parrot