Example #1
0
 def __init__(self, info):
     self._c_vidinfo = info
     self._current_w = -1
     self._current_h = -1
     sdl_v = get_sdl_version()
     if sdl_v[0] >= 1 and sdl_v[1] >= 2 and sdl_v[2] >= 10:
         self._current_w = info.current_w
         self._current_h = info.current_h
Example #2
0
 def __init__(self, info):
     self._c_vidinfo = info
     self._current_w = -1
     self._current_h = -1
     sdl_v = get_sdl_version()
     if sdl_v[0] >= 1 and sdl_v[1] >= 2 and sdl_v[2] >= 10:
         self._current_w = info.current_w
         self._current_h = info.current_h
Example #3
0
def init():
    """ init() -> (numpass, numfail)
    initialize all imported pygame modules
    """
    # check that the SDL version is supported
    # TODO: preserve backwards compatibility in mixer, RWops, etc
    major, minor, patch = get_sdl_version()
    try:
        assert major == 1
        assert minor == 2
        assert patch >= 9
    except AssertionError:
        raise RuntimeError("Current version of SDL is %i.%i.%i. Only SDL "
                           "versions >= 1.2.9, < 2.0.0 are supported." %
                           (major, minor, patch))

    global _sdl_was_init
    if not platform.system().startswith('Windows') and _with_thread:
        _sdl_was_init = sdl.SDL_Init(sdl.SDL_INIT_TIMER
                                     | sdl.SDL_INIT_NOPARACHUTE
                                     | sdl.SDL_INIT_EVENTTHREAD)
    else:
        _sdl_was_init = sdl.SDL_Init(sdl.SDL_INIT_TIMER
                                     | sdl.SDL_INIT_NOPARACHUTE)
    if _sdl_was_init == -1:
        raise SDLError.from_sdl_error()

    # initialize all the things!
    success, fail = 0, 0
    if video_autoinit():
        success += 1
    else:
        fail += 1

    # pygame inspects sys.modules and finds all __PYGAMEinit__ functions.
    # We look for autoinit and only consider submodules of pygame.
    # pygame normally initializes 6 modules.
    # We are at 5 modules: cdrom is missing
    modules = [
        v for k, v in sys.modules.items() if k.startswith('pygame.')
        and v is not None and v != sys.modules[__name__]
    ]
    for module in modules:
        init_call = getattr(module, 'autoinit', None)
        if hasattr(init_call, '__call__'):
            if init_call():
                success += 1
            else:
                fail += 1

    return success, fail
Example #4
0
def init():
    """ init() -> (numpass, numfail)
    initialize all imported pygame modules
    """
    # check that the SDL version is supported
    # TODO: preserve backwards compatibility in mixer, RWops, etc
    major, minor, patch = get_sdl_version()
    try:
        assert major == 1
        assert minor == 2
        assert patch >= 9
    except AssertionError:
        raise RuntimeError("Current version of SDL is %i.%i.%i. Only SDL "
                           "versions >= 1.2.9, < 2.0.0 are supported." %
                           (major, minor, patch))

    global _sdl_was_init
    if not platform.system().startswith('Windows') and _with_thread:
        _sdl_was_init = sdl.SDL_Init(sdl.SDL_INIT_TIMER |
                                     sdl.SDL_INIT_NOPARACHUTE |
                                     sdl.SDL_INIT_EVENTTHREAD)
    else:
        _sdl_was_init = sdl.SDL_Init(sdl.SDL_INIT_TIMER |
                                     sdl.SDL_INIT_NOPARACHUTE)
    if _sdl_was_init == -1:
        raise SDLError.from_sdl_error()

    # initialize all the things!
    success, fail = 0, 0
    if video_autoinit():
        success += 1
    else:
        fail += 1

    # pygame inspects sys.modules and finds all __PYGAMEinit__ functions.
    # We look for autoinit and only consider submodules of pygame.
    # pygame normally initializes 6 modules.
    # We are at 4 modules: cdrom and joystick are missing
    modules = [v for k, v in sys.modules.iteritems() if k.startswith('pygame.')
               and v is not None and v != sys.modules[__name__]]
    for module in modules:
        init_call = getattr(module, 'autoinit', None)
        if hasattr(init_call, '__call__'):
            if init_call():
                success += 1
            else:
                fail += 1

    return success, fail