예제 #1
0
def rect2d(area, color=(1,1,1,1), texture=None, tex_scale=True):
    area = pygame.Rect(area)

    if texture==None:
        texture = display.get_display().blank_texture

    if tex_scale:
        w = texture.size[0]
        h = texture.size[1]
    else:
        w = clamp(0, texture.size[0], area.width)
        h = clamp(0, texture.size[1], area.height)
    topleft = texture.coord(0, 0)
    topright = texture.coord(w,0)
    bottomleft = texture.coord(0,h)
    bottomright = texture.coord(w,h)
    texture.bind()

    glColor4f(*misc.Color(color).get_rgba1())
    glBegin(GL_QUADS)
    glTexCoord2f(*topleft)
    glVertex3f(area.left, area.top, 0)
    glTexCoord2f(*bottomleft)
    glVertex3f(area.left, area.bottom, 0)
    glTexCoord2f(*bottomright)
    glVertex3f(area.right, area.bottom, 0)
    glTexCoord2f(*topright)
    glVertex3f(area.right, area.top, 0)
    glEnd()
예제 #2
0
    def __init__(self, render_type=None, max_size=100):
        """Create the array
           render_type is the OpenGL constant used in rendering, ie GL_POLYGON, GL_TRINAGLES, etc.
           max_size is the size of the array"""
        if render_type is None:
            render_type = GL_QUADS
        self.render_type = render_type
        self.texture = display.get_display().blank_texture

        self.max_size = max_size

        self.verts = numpy.zeros((max_size, 3), "f")
        self.colors = numpy.zeros((max_size, 4), "f")
        self.texcs = numpy.zeros((max_size, 2), "f")
        self.norms = numpy.array([[0,1,0]]*max_size, "f")
예제 #3
0
    def __init__(self, render_type=None, max_size=100, usage="static", cache_changes=False):
        """Create the array
           render_type is the OpenGL constant used in rendering, ie GL_POLYGON, GL_TRINAGLES, etc.
           max_size is the size of the array
           usage can be static, dynamic or stream (affecting render vs. modify speeds)
           cache_changes makes any changes between renderings be stored,
               and then only one modification is performed.
               NOTE: doing this actually modifies the entire buffer data, just efficiently
                     so this is only recommended if you are modifying a tremendous amount of points each frame!"""

        if not VBO_AVAILABLE:
            raise AttributeError("Vertex buffer objects not available!")

        self.usage = ("GL_"+usage+"_DRAW").upper()
        uses = {"GL_STATIC_DRAW":GL_STATIC_DRAW,
                "GL_DYNAMIC_DRAW":GL_DYNAMIC_DRAW,
                "GL_STREAM_DRAW":GL_STREAM_DRAW}
        self.usage_gl = uses[self.usage]

        self.cache_changes = cache_changes
        self._cached_cv = []
        self._cached_cc = []
        self._cached_ct = []
        self._cached_cn = []

        if render_type is None:
            render_type = GL_QUADS
        self.render_type = render_type

        self.texture = display.get_display().blank_texture

        self.max_size = max_size

        self.verts = vbo.VBO(numpy.zeros((max_size, 3), "f"), self.usage)
        self.colors = vbo.VBO(numpy.zeros((max_size, 4), "f"), self.usage)
        self.texcs = vbo.VBO(numpy.zeros((max_size, 2), "f"), self.usage)
        self.norms = vbo.VBO(numpy.array([[0,1,0]]*max_size, "f"), self.usage)
예제 #4
0
if __name__ == '__main__':
    glut.glutInit(sys.argv)

    width, height = 640, 480

    glut.glutInitDisplayMode(glut.GLUT_RGBA
                             | glut.GLUT_DOUBLE
                             | glut.GLUT_DEPTH)
    glut.glutInitWindowSize(width, height)
    glut.glutInitWindowPosition(0, 0)

    # assign to global window variable
    window = glut.glutCreateWindow('Invaders')
    if config.fullscreen_mode:
        glut.glutFullScreen()

    world = World(config.mode[0])

    # draw scene on display and between other calculations
    draw_func = display.get_display(world)
    glut.glutDisplayFunc(draw_func)

    glut.glutIdleFunc(draw_func)
    glut.glutReshapeFunc(resize_func)
    glut.glutKeyboardFunc(keyboard.normal_keys)
    glut.glutSpecialFunc(keyboard.get_special_keys(world))

    init_environment(width, height)

    glut.glutMainLoop()
예제 #5
0
fav_team_id = api.get_team_id(config.FAVORITE_TEAM)
game_date = datetime.today().astimezone(tz=pytz.timezone(config.TIMEZONE))

# Loop if the game is live
while True:

    game = None
    try:
        game = api.get_next_game(fav_team_id, game_date)  # -/+ timedelta(days=1)
    except NoUpcomingGameError:
        print('No upcoming game was found')

    is_live = game is not None \
        and (GameStatus.LIVE == game.status
             or GameStatus.LIVE_CRITICAL == game.status)

    d = get_display()
    d.start()
    d.clear()

    try:
        get_ui_builder(d, fp, lp, game) \
            .deploy()
    finally:
        d.stop()

    if is_live is True:
        sleep(config.CHECK_UPDATE_LIVE_GAME_SECONDS)
    else:
        break