示例#1
0
def get_sdl_version():
    """Get the version of the linked SDL runtime.

    :rtype: int, int, int
    :return: major, minor, patch
    """
    v = SDL.SDL_Linked_Version()
    return v.major, v.minor, v.patch
示例#2
0
def get_error():
    """Get current error message.

    SDL maintains an internal current error message. This message is
    usually given to you when an SDL related exception occurs, but
    sometimes you may want to call this directly yourself.

    :rtype: str
    """
    return SDL.SDL_GetError()
示例#3
0
def init():
    """Autoinitialize all imported pygame modules.

    Initialize all imported pygame modules. Includes pygame modules
    that are not part of the base modules (like font and image).

    It does not raise exceptions, but instead silently counts which
    modules have failed to init. The return argument contains a count
    of the number of modules initialized, and the number of modules
    that failed to initialize.

    You can always initialize the modules you want by hand. The
    modules that need it have an `init` and `quit` routine built in,
    which you can call directly. They also have a `get_init` routine
    which you can use to doublecheck the initialization. Note that
    the manual `init` routines will raise an exception on error. Be
    aware that most platforms require the display module to be
    initialized before others. This `init` will handle that for you,
    but if you initialize by hand, be aware of this constraint.

    As with the manual `init` routines. It is safe to call this
    `init` as often as you like.

    :rtype: int, int
    :return: (count_passed, count_failed)
    """
    success = 0
    fail = 0

    SDL.SDL_Init(SDL.SDL_INIT_EVENTTHREAD |
                 SDL.SDL_INIT_TIMER |
                 SDL.SDL_INIT_NOPARACHUTE)

    if _video_autoinit():
        success += 1
    else:
        fail += 1

    for mod in list(sys.modules.values()):
        if (hasattr(mod, '__PYGAMEinit__') and isinstance(mod.__PYGAMEinit__,
                                                          collections.Callable)):
            try:
                mod.__PYGAMEinit__()
                success += 1
            except:
                fail += 1
    return success, fail
示例#4
0
def _video_autoquit():
    if SDL.SDL_WasInit(SDL.SDL_INIT_VIDEO):
        SDL.SDL_QuitSubSystem(SDL.SDL_INIT_VIDEO)
示例#5
0
def _atexit_quit():
    while _quitfunctions:
        func = _quitfunctions.pop()
        func()
    _video_autoquit()
    SDL.SDL_Quit()
示例#6
0
def _video_autoinit():
    if not SDL.SDL_WasInit(SDL.SDL_INIT_VIDEO):
        SDL.SDL_InitSubSystem(SDL.SDL_INIT_VIDEO)
        SDL.SDL_EnableUNICODE(1)
    return 1