def setup(self): """ Setup that takes more time. Shows a loading screen, and initializes SDL to poll joysticks. Should be called after pyglet's run_app function has been started. """ if self.load_joystick: print("Loading SDL") SDL.start() SDL.SDL_Init(SDL.SDL_INIT_JOYSTICK) print("Done loading SDL") self.camera = Camera(self) self.tickers.append(self.camera) pyglet.clock.schedule_interval(self.tick, 1.0/60) while self.setup_hook: self.setup_hook.pop().setup() self.init = True
oldtime = newtime waittime = 1000 / maxfps - dt if waittime > 0: SDL.SDL_Delay(waittime) def app_main(): print "loaded SDL" SDL.SDL_Init(SDL.SDL_INIT_EVERYTHING) global screen screen = SDL.SDL_SetVideoMode(640,480,0,0) SDL.SDL_EnableUNICODE(1) print "initialized SDL" if SDL.IMG_Init(SDL.IMG_INIT_JPG | SDL.IMG_INIT_PNG | SDL.IMG_INIT_TIF) == 0: print "failed to init SDL_image" return print "initialized SDL_image" main_loop() SDL.SDL_Quit() print "quit" if __name__ == '__main__': print "parsing SDL headers and loading SDL ..." SDL.start(app_main)