本文整理汇总了Python中buffer.Buffer.unmap方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.unmap方法的具体用法?Python Buffer.unmap怎么用?Python Buffer.unmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.unmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VertexStream
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import unmap [as 别名]
class VertexStream(object):
"""
VertexFormat must be set for this class to render correctly.
And before vertexformat is set, you have to bind the vbo.
"""
def __init__(self, fmt, which=GL_TRIANGLES, maxCount=4096):
self.fmt = fmt
self.fmt_ctype_p = POINTER(self.fmt.ctype)
self.which = which
self.maxCount = 4096
self.vbo = Buffer(usage=GL_STREAM_DRAW)
self.vbo.setSize(sizeof(fmt.ctype) * self.maxCount)
self.data = None
self.count = 0
def vertex(self, *data):
if self.count == 0:
address = self.vbo.map(GL_WRITE_ONLY)
assert address != 0
self.data = cast(address, self.fmt_ctype_p)
self.data[self.count] = data
self.count += 1
if self.count >= self.maxCount:
self.flush()
def flush(self):
if self.count > 0:
self.data = None
self.vbo.unmap()
glDrawArrays(self.which, 0, self.count)
self.count = 0