def test_init_haptic(self): sdl.init(sdl.SDL_INIT_HAPTIC) ret = sdl.was_init(sdl.SDL_INIT_HAPTIC) if sys.platform.startswith("freebsd"): # not supported yet self.assertNotEqual(ret, sdl.SDL_INIT_HAPTIC) else: self.assertEqual(ret, sdl.SDL_INIT_HAPTIC) sdl.quit_subsystem(sdl.SDL_INIT_HAPTIC)
def setUp(self): sdl.init(0) if sys.version.startswith("3.1"): self.assertIsInstance = \ lambda x, t: self.assertTrue(isinstance(x, t)) def audio_cb(userdata, audiobytes, length): pass self.audiocallback = audio.SDL_AudioCallback(audio_cb)
def init(): """Initializes the underlying SDL2 video subsystem. Raises a SDLError, if the SDL2 video subsystem could not be initialised. """ if sdl.init(sdl.SDL_INIT_VIDEO) != 0: raise sdl.SDLError()
def setUp(self): sdl.init(sdl.SDL_INIT_TIMER) if sys.version.startswith("3.1"): self.assertIsInstance = \ lambda x, t: self.assertTrue(isinstance(x, t))
def setUp(self): if sys.version.startswith("3.1"): self.assertIsInstance = lambda x, t: self.assertTrue(isinstance(x, t)) sdl.init(0) sdlimage.init()
def setUp(self): if sys.version.startswith("3.1"): self.assertIsInstance = \ lambda x, t: self.assertTrue(isinstance(x, t)) sdl.init(sdl.SDL_INIT_JOYSTICK) self.jcount = joystick.joystick_num_joysticks()
def sdl_offscreen_init(): """ init sdl core and the SDL_image lib (raw.py standalone run)""" sdl.init(0) sdlimage.init()
def sdl_init(size=(1280, 800), title = "DFFG testbed", icon = None, gldebug=False, fwdcore=False): log = logging.getLogger('fgt.sdl_init') sdlhints.set_hint(SDL_HINT_RENDER_DRIVER, 'software') # do not need no renderer sdlhints.set_hint(SDL_HINT_FRAMEBUFFER_ACCELERATION, '0') # do not need no window surface sdl.init(sdl.SDL_INIT_VIDEO | sdl.SDL_INIT_NOPARACHUTE) cflags = 0 cmask = 0 fwdcore = False # mesa doesn't support it :( if fwdcore: cflags |= SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG cmask |= SDL_GL_CONTEXT_PROFILE_CORE else: cmask |= SDL_GL_CONTEXT_PROFILE_COMPATIBILITY if gldebug: cflags |= SDL_GL_CONTEXT_DEBUG_FLAG gl_attrs = ( (SDL_GL_RED_SIZE, "SDL_GL_RED_SIZE", 8), (SDL_GL_GREEN_SIZE, "SDL_GL_GREEN_SIZE", 8), (SDL_GL_BLUE_SIZE, "SDL_GL_BLUE_SIZE", 8), (SDL_GL_ALPHA_SIZE, "SDL_GL_ALPHA_SIZE", 8), (SDL_GL_DEPTH_SIZE, "SDL_GL_DEPTH_SIZE", 0), (SDL_GL_STENCIL_SIZE, "SDL_GL_STENCIL_SIZE", 0), (SDL_GL_DOUBLEBUFFER, "SDL_GL_DOUBLEBUFFER", 1), (SDL_GL_CONTEXT_MAJOR_VERSION, "SDL_GL_CONTEXT_MAJOR_VERSION", 3), (SDL_GL_CONTEXT_MINOR_VERSION, "SDL_GL_CONTEXT_MINOR_VERSION", 0), (SDL_GL_CONTEXT_PROFILE_MASK, "SDL_GL_CONTEXT_PROFILE_MASK", cmask), (SDL_GL_CONTEXT_FLAGS, "SDL_GL_CONTEXT_FLAGS", cflags), ) for attr, name, val in gl_attrs: log.debug("requesting {} [{}] = {}".format(name, attr, val)) sdlvideo.gl_set_attribute(attr, val) window = sdlvideo.create_window(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, size[0], size[1], SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE) if icon: sdlvideo.set_window_icon(window, icon) context = sdlvideo.gl_create_context(window) gldumplog("just after context", logger=log) # this catches PyOpenGL's try: glGetString() except: glGetStringiv() unsanity for attr, name, val in gl_attrs: got = sdlvideo.gl_get_attribute(attr) log.debug("{} requested {} got {}".format(name, val, got)) try: log.info("glGet: vers = {}.{} flags={} " .format( glGetInteger(GL_MAJOR_VERSION), glGetInteger(GL_MINOR_VERSION), glGetInteger(GL_CONTEXT_FLAGS))) except KeyError: pass if not fwdcore: glEnable(GL_POINT_SPRITE) glEnable(GL_VERTEX_PROGRAM_POINT_SIZE) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glDisable(GL_DEPTH_TEST) sdlttf.init() sdlimage.init() return window, context
def setUp(self): sdl.init(0)
def test_init_joystick(self): sdl.init(sdl.SDL_INIT_JOYSTICK) ret = sdl.was_init(sdl.SDL_INIT_JOYSTICK) self.assertEqual(ret, sdl.SDL_INIT_JOYSTICK) sdl.quit_subsystem(sdl.SDL_INIT_JOYSTICK)
def test_init_video(self): sdl.init(sdl.SDL_INIT_VIDEO) ret = sdl.was_init(sdl.SDL_INIT_VIDEO) self.assertEqual(ret, sdl.SDL_INIT_VIDEO) sdl.quit_subsystem(sdl.SDL_INIT_VIDEO)
def test_init_audio(self): sdl.init(sdl.SDL_INIT_AUDIO) ret = sdl.was_init(sdl.SDL_INIT_AUDIO) self.assertEqual(ret, sdl.SDL_INIT_AUDIO) sdl.quit_subsystem(sdl.SDL_INIT_AUDIO)
def test_init_timer(self): sdl.init(sdl.SDL_INIT_TIMER) ret = sdl.was_init(sdl.SDL_INIT_TIMER) self.assertEqual(ret, sdl.SDL_INIT_TIMER) sdl.quit_subsystem(sdl.SDL_INIT_TIMER)
def setUp(self): sdl.init(sdl.SDL_INIT_EVERYTHING)