示例#1
0
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()
示例#2
0
 def __init__(self, w, h, map_file=None):
     self.initSize = Dimension(w, h)
     self.GL = jgl.GL()
     self.GLU = jgl.GLU(self.GL)
     self.GL.glXMakeCurrent(self, 0, 0)
     self.game = Game(map_file)
     self._resized = 0
     self._image = None
     self._image_source = None
     self.addKeyListener(self)
     self.addComponentListener(self)
     gl_draw.init(self.GL, self.GLU, self.game)