本文整理汇总了Python中pyglet.graphics.Batch方法的典型用法代码示例。如果您正苦于以下问题:Python graphics.Batch方法的具体用法?Python graphics.Batch怎么用?Python graphics.Batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.graphics
的用法示例。
在下文中一共展示了graphics.Batch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self):
# A Batch is a collection of vertex lists for batched rendering.
self.batch = Batch()
# A TextureGroup manages an OpenGL texture.
self.texture_group = {}
# Mapping from position to a pyglet `VertextList` for all shown blocks.
self._shown = {}
self.show_hide_queue = OrderedDict()
# Which sector the player is currently in.
self.sector = None
# Mapping from sector to a list of positions inside that sector.
self.sectors = {}
# Same mapping as `world` but only contains blocks that are shown.
self.shown = {}
self.shader = None
PycraftOpenGL()
self.init_shader()
# A mapping from position to the texture of the block at that position.
# This defines all the blocks that are currently in the world.
self.area = Area()
示例2: text_window
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def text_window(request):
class _TestWindow(window.Window):
def __init__(self, doctype, *args, **kwargs):
super(_TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = doctype()
self.layout = layout.IncrementalTextLayout(self.document,
self.width, self.height, batch=self.batch)
def on_draw(self):
gl.glClearColor(1, 1, 1, 1)
self.clear()
self.batch.draw()
def set_bold(self):
self.document.set_style(0, len(self.document.text), {"bold": True})
return _TestWindow(request.param)
示例3: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, multiline, wrap_lines, msg, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_attributed(msg)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
(self.width - self.margin * 2),
self.height - self.margin * 2,
multiline=multiline,
wrap_lines=wrap_lines,
batch=self.batch)
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.wrap_lines = wrap_lines
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
示例4: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, vertex_lists, groups, batch):
"""Create a model.
:Parameters:
`vertex_lists` : list
A list of `~pyglet.graphics.VertexList` or
`~pyglet.graphics.IndexedVertexList`.
`groups` : list
A list of `~pyglet.model.TexturedMaterialGroup`, or
`~pyglet.model.MaterialGroup`. Each group corresponds to
a vertex list in `vertex_lists` of the same index.
`batch` : `~pyglet.graphics.Batch`
Optional batch to add the model to. If no batch is provided,
the model will maintain it's own internal batch.
"""
self.vertex_lists = vertex_lists
self.groups = groups
self._batch = batch
self._rotation = 0, 0, 0
self._translation = 0, 0, 0
示例5: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_text(doctext)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
self.width - self.margin * 2, self.height - self.margin * 2,
multiline=True,
batch=self.batch)
self.layout.content_valign = 'center'
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
示例6: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_text(doctext)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
self.width - self.margin * 2, self.height - self.margin * 2,
multiline=True,
batch=self.batch)
self.layout.content_valign = 'bottom'
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
示例7: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_attributed(doctext)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
self.width - self.margin * 2, self.height - self.margin * 2,
multiline=True,
batch=self.batch)
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
示例8: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_text(doctext)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
self.width - self.margin * 2, self.height - self.margin * 2,
multiline=True,
batch=self.batch)
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
示例9: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, doctype, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = doctype()
self.layout = layout.IncrementalTextLayout(self.document,
self.width, self.height, batch=self.batch)
示例10: _create_text
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def _create_text(self):
assert self.window is not None
self.text_batch = Batch()
self.text_document = FormattedDocument()
layout = TextLayout(self.text_document, self.window.width, self.window.height,
multiline=True, wrap_lines=True, batch=self.text_batch)
layout.content_valign = 'bottom'
示例11: draw
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def draw(self):
"""Draw the shape at its current position.
Using this method is not recommended. Instead, add the
shape to a `pyglet.graphics.Batch` for efficient rendering.
"""
self._group.set_state_recursive()
self._vertex_list.draw(GL_TRIANGLES)
self._group.unset_state_recursive()
示例12: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, x, y, radius, segments=25, angle=math.pi*2, color=(255, 255, 255), batch=None, group=None):
# TODO: Finish this shape and add docstring.
self._x = x
self._y = y
self._radius = radius
self._segments = segments
self._rgb = color
self._angle = angle
self._batch = batch or Batch()
self._group = _ShapeGroup(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, group)
self._vertex_list = self._batch.add(self._segments*2, GL_LINES, self._group, 'v2f', 'c4B')
self._update_position()
self._update_color()
示例13: batch
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def batch(self):
"""The graphics Batch that the Model belongs to.
The Model can be migrated from one batch to another, or removed from
a batch (for individual drawing). If not part of any batch, the Model
will keep it's own internal batch. Note that batch migration can be
an expensive operation.
:type: :py:class:`pyglet.graphics.Batch`
"""
return self._batch
示例14: batch
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def batch(self, batch):
if self._batch == batch:
return
if batch is None:
self._batch = graphics.Batch()
self._own_batch = True
self._update()
elif batch is not None:
self._batch = batch
self._own_batch = False
self._update()
示例15: __init__
# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, x: int, y: int):
self.tile_images = {
TileType.WATER: WATER_TILE,
TileType.ICE: ICE_TILE,
TileType.WEAK_ICE: WEAK_ICE_TILE,
TileType.WALL: WALL_TILE
}
self.x = x
self.y = y
self.batch = Batch()
# Tiles is in the format [y][x]
self.tiles = []