def main(): GLUT.glutInit(sys.argv) GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH) GLUT.glutInitWindowSize(320, 240) global window window = GLUT.glutCreateWindow("Babal") GLUT.glutDisplayFunc(display_cb) GLUT.glutVisibilityFunc(visibility_cb) GLUT.glutReshapeFunc(reshape_cb) GLUT.glutIgnoreKeyRepeat(1) GLUT.glutKeyboardFunc(keyboard_cb) GLUT.glutKeyboardUpFunc(keyboard_up_cb) GLUT.glutSpecialFunc(special_cb) GLUT.glutSpecialUpFunc(special_up_cb) GLUT.glutJoystickFunc(joystick_cb, 0) map_file = None if len(sys.argv) > 1: map_file = open(sys.argv[1]) global game game = Game(map_file) gl_draw.init(GL, GLU, game) # reshape_cb gets called when window is made visible GLUT.glutMainLoop()
def main(): scanner = SimpleScanner() gl.glClearColor(0.1, 0.1, 0.2, 1.0) timer_msec = int(1000 / 60) # 60 times per second renderer = Renderer() drawings_list = [] fish_queue = Queue( ) # Queue to maintain order of the fish and kill the oldest ones fish_limit = 10 # Maximum amount of fish to draw scanned_fish_queue = Queue() draw_ocean(drawings_list) fish_shader_program = Renderer.create_shader(gl.GL_VERTEX_SHADER, FISH_SHADER_CODE) bubble_texture = Renderer.create_texture_from_file( 'ocean/images/bubble.png') load_fish_from_files(scanner, drawings_list, fish_queue, fish_shader_program, bubble_texture) glut.glutDisplayFunc(partial(renderer.render, drawings_list)) glut.glutIgnoreKeyRepeat(True) glut.glutKeyboardFunc(create_key_processor(scanner, scanned_fish_queue)) glut.glutTimerFunc( timer_msec, create_animation_function(renderer, drawings_list, scanned_fish_queue, fish_queue, fish_limit, timer_msec, fish_shader_program, bubble_texture), 0) glut.glutMainLoop()
def start(self): GLUT.glutIgnoreKeyRepeat(True) GLUT.glutSpecialFunc(self.special_keyboard_down) GLUT.glutSpecialUpFunc(self.special_keyboard_up)