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


Python sdl2.SDL_Init方法代码示例

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


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

示例1: run

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_Init [as 别名]
def run():
    sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO)
    window = sdl2.SDL_CreateWindow(b"Hello World",
                                   sdl2.SDL_WINDOWPOS_CENTERED,
                                   sdl2.SDL_WINDOWPOS_CENTERED,
                                   592, 460, sdl2.SDL_WINDOW_SHOWN)
    fname = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         "resources", "hello.bmp")
    image = sdl2.SDL_LoadBMP(fname.encode("utf-8"))
    windowsurface = sdl2.SDL_GetWindowSurface(window)
    sdl2.SDL_BlitSurface(image, None, windowsurface, None)
    sdl2.SDL_UpdateWindowSurface(window)
    sdl2.SDL_FreeSurface(image)

    running = True
    event = sdl2.SDL_Event()
    while running:
        while sdl2.SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == sdl2.SDL_QUIT:
                running = False
                break
        sdl2.SDL_Delay(10)

    sdl2.SDL_DestroyWindow(window)
    sdl2.SDL_Quit()
    return 0 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:28,代码来源:sdl2hello.py

示例2: init

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_Init [as 别名]
def init(cls):
        sdl2.SDL_Init(sdl2.SDL_INIT_JOYSTICK | sdl2.SDL_INIT_HAPTIC) 
开发者ID:jisaiahgarrett,项目名称:KSURCT-TEST,代码行数:4,代码来源:xbox.py

示例3: createWindow

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_Init [as 别名]
def createWindow(self):
		# Create the window context
		if sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) != 0:
			print(sdl2.SDL_GetError())
			return -1
		sdl2ttf.TTF_Init()
		sdl2img.IMG_Init(sdl2img.IMG_INIT_PNG)

		self.window = sdl2.SDL_CreateWindow(self.params["title"].encode(),
					   sdl2.SDL_WINDOWPOS_UNDEFINED,
					   sdl2.SDL_WINDOWPOS_UNDEFINED,
					   self.window_width,
					   self.window_height,
					   sdl2.SDL_WINDOW_OPENGL)
		sdl2.SDL_SetWindowBordered(self.window, self.show_borders)
		if not self.window:
			print(sdl2.SDL_GetError())
			return -1

		# Renderer
		self.renderer = sdl2.SDL_CreateRenderer(self.window, -1,
			sdl2.SDL_RENDERER_ACCELERATED|sdl2.SDL_RENDERER_PRESENTVSYNC)

		# Build the GUI
		self.buildElements()

		# onStart handler
		if self.onStart is not None:
			if self.onStart[1] is None:
				self.onStart[0]()
			else:
				self.onStart[0](self.onStart[1])

		# look for events
		self._loopForEvents() 
开发者ID:Romaingin,项目名称:Antlia,代码行数:37,代码来源:renderer.py

示例4: __init__

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_Init [as 别名]
def __init__(self, **options):
        Component.__init__(self, self, None, **options)
        self.viewport = sdl2.SDL_Rect()
        self._components_activation = OrderedDict()
        self.resources = {}
        self.tints = []
        self.timers = []
        self._running = True
        self.logger.info("Initializing application: %s", self.name)
        sdl2.SDL_Init(self.props.get('init_flags', 0))
        self.register_event_handler(sdl2.SDL_QUIT, self._quit)
        self.register_event_handler(sdl2.SDL_WINDOWEVENT, self._window_event)
        self.keys = sdl2.SDL_GetKeyboardState(None)
        self.window = self._get_window()
        self.renderer = self._get_renderer()
        self.load_resource('font-6', 'font-6.png')
        self.resources['font-6'].make_font(
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?("
            ")[][email protected]:/'., ")
        self.enable()
        try:
            _deep_call(self, 'init')
        except:
            self.quit()
            self._clean_up()
            raise
        sdl2.SDL_ShowWindow(self.window) 
开发者ID:cecton,项目名称:pysdl2-sdl2ui,代码行数:29,代码来源:app.py

示例5: run

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_Init [as 别名]
def run():
    if sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) != 0:
        print(sdl2.SDL_GetError())
        return -1

    window = sdl2.SDL_CreateWindow(b"OpenGL demo",
                                   sdl2.SDL_WINDOWPOS_UNDEFINED,
                                   sdl2.SDL_WINDOWPOS_UNDEFINED, 800, 600,
                                   sdl2.SDL_WINDOW_OPENGL)
    if not window:
        print(sdl2.SDL_GetError())
        return -1

    context = sdl2.SDL_GL_CreateContext(window)

    GL.glMatrixMode(GL.GL_PROJECTION | GL.GL_MODELVIEW)
    GL.glLoadIdentity()
    GL.glOrtho(-400, 400, 300, -300, 0, 1)

    x = 0.0
    y = 30.0

    event = sdl2.SDL_Event()
    running = True
    while running:
        while sdl2.SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == sdl2.SDL_QUIT:
                running = False

        GL.glClearColor(0, 0, 0, 1)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT)
        GL.glRotatef(10.0, 0.0, 0.0, 1.0)
        GL.glBegin(GL.GL_TRIANGLES)
        GL.glColor3f(1.0, 0.0, 0.0)
        GL.glVertex2f(x, y + 90.0)
        GL.glColor3f(0.0, 1.0, 0.0)
        GL.glVertex2f(x + 90.0, y - 90.0)
        GL.glColor3f(0.0, 0.0, 1.0)
        GL.glVertex2f(x - 90.0, y - 90.0)
        GL.glEnd()

        sdl2.SDL_GL_SwapWindow(window)
        sdl2.SDL_Delay(10)
    sdl2.SDL_GL_DeleteContext(context)
    sdl2.SDL_DestroyWindow(window)
    sdl2.SDL_Quit()
    return 0 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:49,代码来源:opengl.py


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