当前位置: 首页>>代码示例>>Python>>正文


Python pyglet.graphics方法代码示例

本文整理汇总了Python中pyglet.graphics方法的典型用法代码示例。如果您正苦于以下问题:Python pyglet.graphics方法的具体用法?Python pyglet.graphics怎么用?Python pyglet.graphics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyglet的用法示例。


在下文中一共展示了pyglet.graphics方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def __init__(self):
        """Create a graphics batch."""
        # Mapping to find domain.  
        # group -> (attributes, mode, indexed) -> domain
        self.group_map = {}

        # Mapping of group to list of children.
        self.group_children = {}

        # List of top-level groups
        self.top_groups = []

        self._draw_list = []
        self._draw_list_dirty = False

        # Each Batch encompasses one VAO
        self.vao = VertexArray()

        if _debug_graphics_batch:
            print("Batch created. VAO ID: {0}".format(self.vao.id)) 
开发者ID:pyglet,项目名称:pyglet,代码行数:22,代码来源:__init__.py

示例2: __init__

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def __init__(self, blend_src, blend_dest, parent=None):
        """Create a Shape group.

        The group is created internally. Usually you do not
        need to explicitly create it.

        :Parameters:
            `blend_src` : int
                OpenGL blend source mode; for example,
                ``GL_SRC_ALPHA``.
            `blend_dest` : int
                OpenGL blend destination mode; for example,
                ``GL_ONE_MINUS_SRC_ALPHA``.
            `parent` : `~pyglet.graphics.Group`
                Optional parent group.
        """
        super().__init__(_default_program, parent=parent)
        self.blend_src = blend_src
        self.blend_dest = blend_dest 
开发者ID:pyglet,项目名称:pyglet,代码行数:21,代码来源:shapes.py

示例3: _create_vertex_list

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def _create_vertex_list(self):
        if self._batch is None:
            self._vertex_list = graphics.vertex_list(4,
                'v2i/%s' % self._usage,
                'c4B', ('t3f', self._texture.tex_coords))
        else:
            self._vertex_list = self._batch.add(4, GL_QUADS, self._group,
                'v2i/%s' % self._usage,
                'c4B', ('t3f', self._texture.tex_coords))
        self._update_position()
        self._update_color() 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:13,代码来源:sprite.py

示例4: __init__

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def __init__(self):
        '''Create a graphics batch.'''
        # Mapping to find domain.
        # group -> (attributes, mode, indexed) -> domain
        self.group_map = {}

        # Mapping of group to list of children.
        self.group_children = {}

        # List of top-level groups
        self.top_groups = []

        self._draw_list = []
        self._draw_list_dirty = False 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:16,代码来源:__init__.py

示例5: draw_lane_surface

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def draw_lane_surface(self, lane):
        gl.glColor3f(0.4, 0.4, 0.4)
        W = 1000
        graphics.draw(4, gl.GL_QUAD_STRIP, ('v2f',
                                            np.hstack([lane.p - lane.m * W - 0.5 * lane.w * lane.n,
                                                       lane.p - lane.m * W + 0.5 * lane.w * lane.n,
                                                       lane.q + lane.m * W - 0.5 * lane.w * lane.n,
                                                       lane.q + lane.m * W + 0.5 * lane.w * lane.n])
                                            )) 
开发者ID:BerkeleyLearnVerify,项目名称:VerifAI,代码行数:11,代码来源:simulator.py

示例6: draw_lane_lines

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def draw_lane_lines(self, lane):
        gl.glColor3f(1., 1., 1.)
        W = 1000
        graphics.draw(4, gl.GL_LINES, ('v2f',
                                       np.hstack([lane.p - lane.m * W - 0.5 * lane.w * lane.n,
                                                  lane.p + lane.m * W - 0.5 * lane.w * lane.n,
                                                  lane.p - lane.m * W + 0.5 * lane.w * lane.n,
                                                  lane.p + lane.m * W + 0.5 * lane.w * lane.n])
                                       )) 
开发者ID:BerkeleyLearnVerify,项目名称:VerifAI,代码行数:11,代码来源:simulator.py

示例7: on_draw

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def on_draw(self):
        self.window.clear()
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        self.camera()
        gl.glEnable(self.background.target)
        gl.glEnable(gl.GL_BLEND)
        gl.glBindTexture(self.background.target, self.background.id)
        W = 10000.
        graphics.draw(4, gl.GL_QUADS,
                      ('v2f', (-W, -W, W, -W, W, W, -W, W)),
                      ('t2f', (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.))
                      )
        gl.glDisable(self.background.target)
        for lane in self.world.lanes:
            self.draw_lane_surface(lane)
            self.draw_lane_lines(lane)
        for obj in self.world.objects:
            self.draw_object(obj)
        for car in self.world.cars:
            self.draw_car(car.trajectory[-1], car.color)
        gl.glPopMatrix()

        self.label.text = self.task_name
        self.label.draw()
        self.iter +=1
        if self.iter%10 == 0:
            print('Iterations: ', self.iter)
        if self.iter == self.max_iters:
            self.event_loop.exit() 
开发者ID:BerkeleyLearnVerify,项目名称:VerifAI,代码行数:33,代码来源:simulator.py

示例8: __init__

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def __init__(self, texture, blend_src, blend_dest, program=None, order=0, parent=None):
        """Create a sprite group.

        The group is created internally when a :py:class:`~pyglet.sprite.Sprite`
        is created; applications usually do not need to explicitly create it.

        :Parameters:
            `texture` : `~pyglet.image.Texture`
                The (top-level) texture containing the sprite image.
            `blend_src` : int
                OpenGL blend source mode; for example,
                ``GL_SRC_ALPHA``.
            `blend_dest` : int
                OpenGL blend destination mode; for example,
                ``GL_ONE_MINUS_SRC_ALPHA``.
            `program` : `~pyglet.graphics.shader.ShaderProgram`
                A custom ShaderProgram.
            `order` : int
                Change the order to render above or below other Groups.
            `parent` : `~pyglet.graphics.Group`
                Optional parent group.
        """
        super().__init__(order, parent)
        self.texture = texture
        self.blend_src = blend_src
        self.blend_dest = blend_dest
        self.program = program or _default_program 
开发者ID:pyglet,项目名称:pyglet,代码行数:29,代码来源:sprite.py

示例9: batch

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def batch(self):
        """Graphics batch.

        The sprite can be migrated from one batch to another, or removed from
        its batch (for individual drawing).  Note that this can be an expensive
        operation.

        :type: :py:class:`pyglet.graphics.Batch`
        """
        return self._batch 
开发者ID:pyglet,项目名称:pyglet,代码行数:12,代码来源:sprite.py

示例10: group

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def group(self):
        """Parent graphics group.

        The sprite can change its rendering group, however this can be an
        expensive operation.

        :type: :py:class:`pyglet.graphics.Group`
        """
        return self._group.parent 
开发者ID:pyglet,项目名称:pyglet,代码行数:11,代码来源:sprite.py

示例11: _nearest_pow2

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def _nearest_pow2(v):
    # From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
    # Credit: Sean Anderson
    v -= 1
    v |= v >> 1
    v |= v >> 2
    v |= v >> 4
    v |= v >> 8
    v |= v >> 16
    return v + 1 
开发者ID:pyglet,项目名称:pyglet,代码行数:12,代码来源:vertexdomain.py

示例12: create_domain

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def create_domain(shader_program_id, *attribute_usage_formats):
    """Create a vertex domain covering the given attribute usage formats.
    See documentation for :py:func:`create_attribute_usage` and
    :py:func:`pyglet.graphics.vertexattribute.create_attribute` for the grammar
    of these format strings.

    :rtype: :py:class:`VertexDomain`
    """
    attribute_usages = [create_attribute_usage(shader_program_id, f)
                        for f in attribute_usage_formats]
    return VertexDomain(attribute_usages) 
开发者ID:pyglet,项目名称:pyglet,代码行数:13,代码来源:vertexdomain.py

示例13: create_indexed_domain

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def create_indexed_domain(shader_program_id, *attribute_usage_formats):
    """Create an indexed vertex domain covering the given attribute usage
    formats.  See documentation for :py:class:`create_attribute_usage` and
    :py:func:`pyglet.graphics.vertexattribute.create_attribute` for the grammar
    of these format strings.

    :rtype: :py:class:`VertexDomain`
    """
    attribute_usages = [create_attribute_usage(shader_program_id, f)
                        for f in attribute_usage_formats]
    return IndexedVertexDomain(attribute_usages) 
开发者ID:pyglet,项目名称:pyglet,代码行数:13,代码来源:vertexdomain.py

示例14: draw

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def draw(self, mode):
        """Draw this vertex list in the given OpenGL mode.

        :Parameters:
            `mode` : int
                OpenGL drawing mode, e.g. ``GL_POINTS``, ``GL_LINES``, etc.

        """
        with pyglet.graphics.get_default_batch().vao:
            pyglet.graphics.get_default_group().set_state()
            self.domain.draw_subset(mode, self)
            pyglet.graphics.get_default_group().unset_state() 
开发者ID:pyglet,项目名称:pyglet,代码行数:14,代码来源:vertexdomain.py

示例15: vertex_list

# 需要导入模块: import pyglet [as 别名]
# 或者: from pyglet import graphics [as 别名]
def vertex_list(count, *data):
    """Create a :py:class:`~pyglet.graphics.vertexdomain.VertexList` not associated with a batch, group or mode.

    :Parameters:
        `count` : int
            The number of vertices in the list.
        `data` : data items
            Attribute formats and initial data for the vertex list.  See the
            module summary for details.

    :rtype: :py:class:`~pyglet.graphics.vertexdomain.VertexList`
    """
    # Note that mode=0 because the default batch is never drawn: vertex lists
    # returned from this function are drawn directly by their draw() method.
    return get_default_batch().add(count, 0, None, *data) 
开发者ID:pyglet,项目名称:pyglet,代码行数:17,代码来源:__init__.py


注:本文中的pyglet.graphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。