当前位置: 首页>>代码示例>>Python>>正文


Python sdl2.SDL_GetError方法代码示例

本文整理汇总了Python中sdl2.SDL_GetError方法的典型用法代码示例。如果您正苦于以下问题:Python sdl2.SDL_GetError方法的具体用法?Python sdl2.SDL_GetError怎么用?Python sdl2.SDL_GetError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sdl2的用法示例。


在下文中一共展示了sdl2.SDL_GetError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_handles

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def _create_handles(window_title, window_position, window_size, window_flags,
                    renderer_info):
    """Create the SDL2 handles."""
    window_flags = sdl2.SDL_WINDOW_SHOWN | window_flags
    if renderer_info.api == GraphicsAPI.OPENGL:
        window_flags |= sdl2.SDL_WINDOW_OPENGL
        window = sdl2.SDL_CreateWindow(
            window_title.encode(),
            window_position.x, window_position.y,
            window_size.x, window_size.y,
            window_flags)
        if not window:
            raise RuntimeError(sdl2.SDL_GetError().decode())

        context = sdl2.SDL_GL_CreateContext(window)
        if not context:
            raise RuntimeError(sdl2.SDL_GetError().decode())

        # Try to disable the vertical synchronization. It applies to the active
        # context and thus needs to be called after `SDL_GL_CreateContext`.
        sdl2.SDL_GL_SetSwapInterval(0)

        return _Handles(
            window=window,
            renderer=_GLHandles(context=context)) 
开发者ID:christophercrouzet,项目名称:hienoi,代码行数:27,代码来源:gui.py

示例2: open

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def open(self, configuration):
        '''Open and configure audio system

        *Parameters:*

        - `configuration`: Configuration parameters from Application
        '''
        if sdl2.SDL_InitSubSystem(sdl2.SDL_INIT_AUDIO) != 0:
            msg = "Cannot initialize audio system: %s" % sdl2.SDL_GetError()
            logger.critical(msg)
            raise SDL2Error(msg)

        if mixer.Mix_OpenAudio(mixer.MIX_DEFAULT_FREQUENCY,
                               mixer.MIX_DEFAULT_FORMAT, 2, 1024):
            msg = "Cannot open mixed audio: %s" % mixer.Mix_GetError()
            logger.critical(msg)
            raise SDL2Error(msg)

        mixer.Mix_AllocateChannels(configuration.audio_channel)

        logger.info("Audio initialized") 
开发者ID:realitix,项目名称:vulk,代码行数:23,代码来源:audio.py

示例3: handle_event

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def handle_event(self):
        """Busywait until SDL_Event in keyhandlers is received.
        Then the corresponding value is returned."""
        event = sdl2.SDL_Event()
        while True:
            if sdl2.SDL_WaitEvent(ctypes.byref(event)) == 0:
                raise Exception(sdl2.SDL_GetError())
            if event.type == sdl2.SDL_QUIT:
                self.quit_handler()
                return True
            elif event.type == sdl2.SDL_KEYDOWN:
                key = event.key.keysym.sym
                mod = event.key.keysym.mod
                if mod in (sdl2.KMOD_NUM, sdl2.KMOD_NUM + sdl2.KMOD_LSHIFT,
                           sdl2.KMOD_NUM + sdl2.KMOD_RSHIFT):  # ignore numlock
                    mod -= sdl2.KMOD_NUM
                if (key, mod) in self.key_handlers:
                    return self.key_handlers[(key, mod)] 
开发者ID:kampffrosch94,项目名称:pyAoEM,代码行数:20,代码来源:input_.py

示例4: _load_texture

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def _load_texture(texture_name):
    if texture_name in loaded_textures:
        cached_texture = loaded_textures[texture_name]
        cached_properties = loaded_textures_properties[texture_name]
        return cached_texture, cached_properties
    surface = sdlimage.IMG_Load(img_paths[texture_name])
    if surface is None:
        raise OSError("File " + texture_name + " could not be loaded.")
    texture = sdl2.SDL_CreateTextureFromSurface(renderer, surface)
    if texture is None:
        raise Exception(sdl2.SDL_GetError())

    rect = surface.contents.clip_rect
    sdl2.SDL_FreeSurface(surface)

    properties = (rect.x, rect.y, rect.w, rect.h)
    loaded_textures[texture_name] = texture
    loaded_textures_properties[texture_name] = properties
    return texture, properties 
开发者ID:kampffrosch94,项目名称:pyAoEM,代码行数:21,代码来源:res.py

示例5: test_SDL_GetClosestDisplayMode

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GetClosestDisplayMode(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support closest display modes")
        numdisplays = video.SDL_GetNumVideoDisplays()
        for index in range(numdisplays):
            modes = video.SDL_GetNumDisplayModes(index)
            dmode = video.SDL_DisplayMode()
            for mode in range(modes):
                ret = video.SDL_GetDisplayMode(index, mode, byref(dmode))
                #self.assertIsInstance(dmode.contents, video.SDL_DisplayMode)
                self.assertEqual(ret, 0)
                cmode = video.SDL_DisplayMode(dmode.format,
                                              dmode.w - 1, dmode.h - 1,
                                              dmode.refresh_rate)
                closest = video.SDL_DisplayMode()
                video.SDL_GetClosestDisplayMode(index, cmode, byref(closest))
                self.assertEqual(closest, dmode, SDL_GetError()) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:19,代码来源:video_test.py

示例6: test_SDL_GL_GetProcAddress

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GL_GetProcAddress(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support GL loading")

        procaddr = video.SDL_GL_GetProcAddress(b"glGetString")
        self.assertIsNone(procaddr)

        self.assertEqual(video.SDL_GL_LoadLibrary(None), 0, SDL_GetError())

        # Behaviour is undefined as long as there is no window and context.
        window = video.SDL_CreateWindow(b"OpenGL", 10, 10, 10, 10,
                                        video.SDL_WINDOW_OPENGL)

        ctx = video.SDL_GL_CreateContext(window)

        procaddr = video.SDL_GL_GetProcAddress(b"glGetString")
        self.assertTrue(procaddr is not None and int(procaddr) != 0)

        video.SDL_GL_DeleteContext(ctx)
        video.SDL_DestroyWindow(window)
        video.SDL_GL_UnloadLibrary()

        procaddr = video.SDL_GL_GetProcAddress(b"glGetString")
        self.assertIsNone(procaddr) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:26,代码来源:video_test.py

示例7: test_SDL_GL_ExtensionSupported

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GL_ExtensionSupported(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support GL loading")

        self.assertFalse(video.SDL_GL_ExtensionSupported(b"GL_EXT_bgra"))

        self.assertEqual(video.SDL_GL_LoadLibrary(None), 0, SDL_GetError())
        window = video.SDL_CreateWindow(b"OpenGL", 10, 10, 10, 10,
                                        video.SDL_WINDOW_OPENGL)

        ctx = video.SDL_GL_CreateContext(window)

        self.assertTrue(video.SDL_GL_ExtensionSupported(b"GL_EXT_bgra"))

        video.SDL_GL_DeleteContext(ctx)
        video.SDL_DestroyWindow(window)
        video.SDL_GL_UnloadLibrary()

        self.assertFalse(video.SDL_GL_ExtensionSupported(b"GL_EXT_bgra")) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:21,代码来源:video_test.py

示例8: test_SDL_GL_MakeCurrent

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GL_MakeCurrent(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support GL loading")

        self.assertEqual(video.SDL_GL_LoadLibrary(None), 0, SDL_GetError())

        # self.assertRaises((AttributeError, TypeError),
        #                  video.SDL_GL_MakeCurrent, None, None)

        window = video.SDL_CreateWindow(b"No OpenGL", 10, 10, 10, 10,
                                        video.SDL_WINDOW_BORDERLESS)

        #self.assertRaises(sdl.SDLError, video.SDL_GL_CreateContext, window)
        video.SDL_DestroyWindow(window)

        # self.assertRaises((AttributeError, TypeError),
        #                  video.SDL_GL_MakeCurrent, None, None)

        video.SDL_GL_UnloadLibrary() 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:21,代码来源:video_test.py

示例9: test_SDL_GL_SwapWindow

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GL_SwapWindow(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support GL loading")

        self.assertEqual(video.SDL_GL_LoadLibrary(None), 0, SDL_GetError())
        window = video.SDL_CreateWindow(b"OpenGL", 10, 10, 10, 10,
                                        video.SDL_WINDOW_OPENGL)
        ctx = video.SDL_GL_CreateContext(window)
        video.SDL_GL_MakeCurrent(window, ctx)
        video.SDL_GL_SwapWindow(window)
        video.SDL_GL_SwapWindow(window)
        video.SDL_GL_SwapWindow(window)
        video.SDL_GL_SwapWindow(window)
        video.SDL_GL_DeleteContext(ctx)
        video.SDL_DestroyWindow(window)
        video.SDL_GL_UnloadLibrary() 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:18,代码来源:video_test.py

示例10: test_SDL_GetSetWindowOpacity

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GetSetWindowOpacity(self):
        window = video.SDL_CreateWindow(b"Opacity", 10, 10, 10, 10, 0)
        opacity = c_float()
        ret = video.SDL_GetWindowOpacity(window, byref(opacity))
        self.assertEqual(ret, 0)
        self.assertEqual(opacity.value, 1.0)
        if video.SDL_GetCurrentVideoDriver() != b"dummy":
            ret = video.SDL_SetWindowOpacity(window, 0.0)
            self.assertEqual(ret, 0, SDL_GetError())
            ret = video.SDL_GetWindowOpacity(window, byref(opacity))
            self.assertEqual(ret, 0)
            self.assertEqual(opacity.value, 0.0)
            ret = video.SDL_SetWindowOpacity(window, 0.653)
            self.assertEqual(ret, 0)
            ret = video.SDL_GetWindowOpacity(window, byref(opacity))
            self.assertEqual(ret, 0)
            self.assertAlmostEqual(opacity.value, 0.653, 2)
        video.SDL_DestroyWindow(window) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:20,代码来源:video_test.py

示例11: init

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def init(self):
        self.c_callback = sdl2.SDL_AudioCallback(self._audio_callback)
        want = sdl2.SDL_AudioSpec(
            self.props['frequency'], self.props['format'],
            self.props['channels'], self.props['chunksize'], self.c_callback)
        self.audio_spec = sdl2.SDL_AudioSpec(
            self.props['frequency'], self.props['format'],
            self.props['channels'], self.props['chunksize'])
        self.logger.info("Opening audio device...")
        self.index = sdl2.SDL_OpenAudioDevice(
            None, 0, want, self.audio_spec,
            self.props.get('allowed_changes', 0))
        if self.index == 0:
            raise ValueError(
                "can't open audio device: %s" % sdl2.SDL_GetError().decode())
        self.app.register_event_handler(sdl2.SDL_QUIT, self.quit)
        self.load() 
开发者ID:cecton,项目名称:pysdl2-sdl2ui,代码行数:19,代码来源:audio.py

示例12: open

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def open(self, configuration):
        '''Open the SDL2 Window

        *Parameters:*

        - `configuration`: Configurations parameters from Application
        '''
        if sdl2.SDL_InitSubSystem(sdl2.SDL_INIT_VIDEO) != 0:
            msg = "Can't open window: %s" % sdl2.SDL_GetError()
            logger.critical(msg)
            raise SDL2Error(msg)

        flags = 0
        if configuration.fullscreen and \
           configuration.width and configuration.height:
            flags |= sdl2.SDL_WINDOW_FULLSCREEN
        elif configuration.fullscreen:
            flags |= sdl2.SDL_WINDOW_FULLSCREEN_DESKTOP
        if not configuration.decorated:
            flags |= sdl2.SDL_WINDOW_BORDERLESS
        if configuration.resizable:
            flags |= sdl2.SDL_WINDOW_RESIZABLE
        if configuration.highdpi:
            flags |= sdl2.SDL_WINDOW_ALLOW_HIGHDPI

        self.window = sdl2.SDL_CreateWindow(
            configuration.name.encode('ascii'), configuration.x,
            configuration.y, configuration.width, configuration.height, flags)

        if not self.window:
            msg = "Can't open window: %s" % sdl2.SDL_GetError()
            logger.critical(msg)
            raise SDL2Error(msg)

        logger.debug("SDL2 window opened with configuration: %s",
                     (configuration,))

        self.info = sdl2.SDL_SysWMinfo()
        sdl2.SDL_VERSION(self.info.version)
        sdl2.SDL_GetWindowWMInfo(self.window, ctypes.byref(self.info)) 
开发者ID:realitix,项目名称:vulk,代码行数:42,代码来源:context.py

示例13: test_SDL_GL_LoadUnloadLibrary

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GL_LoadUnloadLibrary(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support GL loading")
        # Try the default library
        self.assertEqual(video.SDL_GL_LoadLibrary(None), 0, SDL_GetError())
        video.SDL_GL_UnloadLibrary()

        if has_opengl_lib():
            fpath = get_opengl_path().encode("utf-8")
            self.assertEqual(video.SDL_GL_LoadLibrary(fpath), 0, SDL_GetError())
            video.SDL_GL_UnloadLibrary()

        #self.assertRaises(sdl.SDLError, video.SDL_GL_LoadLibrary, "Test")
        #self.assertRaises(sdl.SDLError, video.SDL_GL_LoadLibrary, False)
        #self.assertRaises(sdl.SDLError, video.SDL_GL_LoadLibrary, 0) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:17,代码来源:video_test.py

示例14: test_SDL_GL_GetSetSwapInterval

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GL_GetSetSwapInterval(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support GL loading")

        #self.assertRaises(ValueError, video.SDL_GL_SetSwapInterval, None)
        #self.assertRaises(ValueError, video.SDL_GL_SetSwapInterval, "Test")
        #self.assertRaises(ValueError, video.SDL_GL_SetSwapInterval, 1234)

        # No current OpenGL context yet.
        # Might crash on certain platforms, since the internal state of
        # SDL2 does not support calling GL functions without having a
        # GL library loaded.
        # self.assertRaises(sdl.SDLError, video.SDL_GL_SetSwapInterval, 1)
        # self.assertRaises(sdl.SDLError, video.SDL_GL_SetSwapInterval, 0)

        self.assertEqual(video.SDL_GL_LoadLibrary(None), 0, SDL_GetError())
        window = video.SDL_CreateWindow(b"OpenGL", 10, 10, 10, 10,
                                        video.SDL_WINDOW_OPENGL)
        ctx = video.SDL_GL_CreateContext(window)
        video.SDL_GL_MakeCurrent(window, ctx)

        ret = video.SDL_GL_SetSwapInterval(0)
        if ret == 0:
            self.assertEqual(video.SDL_GL_GetSwapInterval(), 0)
        ret = video.SDL_GL_SetSwapInterval(1)
        if ret == 0:
            self.assertEqual(video.SDL_GL_GetSwapInterval(), 1)

        video.SDL_GL_DeleteContext(ctx)
        video.SDL_DestroyWindow(window)
        video.SDL_GL_UnloadLibrary() 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:33,代码来源:video_test.py

示例15: test_SDL_GetDisplayDPI

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_GetError [as 别名]
def test_SDL_GetDisplayDPI(self):
        if video.SDL_GetCurrentVideoDriver() == b"dummy":
            self.skipTest("dummy video driver does not support display DPI")
        numdisplays = video.SDL_GetNumVideoDisplays()
        for index in range(numdisplays):
            ddpi, hdpi, vdpi = c_float(), c_float(), c_float()
            ret = video.SDL_GetDisplayDPI(index, byref(ddpi), byref(hdpi),
                                          byref(vdpi))
            self.assertEqual(ret, 0, SDL_GetError())
            self.assertGreaterEqual(ddpi.value, 96.0)
            self.assertGreaterEqual(hdpi.value, 96.0)
            self.assertGreaterEqual(vdpi.value, 96.0) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:14,代码来源:video_test.py


注:本文中的sdl2.SDL_GetError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。