本文整理汇总了Python中mmfparser.bytereader.ByteReader.write方法的典型用法代码示例。如果您正苦于以下问题:Python ByteReader.write方法的具体用法?Python ByteReader.write怎么用?Python ByteReader.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mmfparser.bytereader.ByteReader
的用法示例。
在下文中一共展示了ByteReader.write方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_shader
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def get_shader(self, name, vert, frag):
writer = ByteReader()
writer.writeInt(len(vert))
writer.write(vert)
writer.writeInt(len(frag))
writer.write(frag)
return str(writer)
示例2: compress
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def compress(data):
reader = ByteReader()
compressed = zlib.compress(str(data))
reader.writeInt(len(data))
reader.writeInt(len(compressed))
reader.write(compressed)
return reader
示例3: write_runinfo
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def write_runinfo(info):
writer = ByteReader()
writer.writeInt(len(info), True)
for k, v in info.iteritems():
writer.writeInt(len(k), True)
writer.write(k)
for i in xrange(26):
reader.writeByte(v[i], True)
示例4: write_data
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def write_data(self):
header = ByteReader()
data = ByteReader()
header_size = ((len(self.images) + len(self.sounds) + len(self.fonts) +
len(self.shaders) + len(self.files)) * 4
+ len(self.images) * 2 + 5 * 4)
# image preload
self.use_count_offset = header.tell()
for _ in xrange(len(self.images)):
header.writeShort(0, True)
start = data.tell()
for image in self.images:
header.writeInt(data.tell() + header_size, True)
data.write(image)
image_size = data.tell() - start
start = data.tell()
for sound in self.sounds:
header.writeInt(data.tell() + header_size, True)
data.write(sound)
sound_size = data.tell() - start
start = data.tell()
for font in self.fonts:
header.writeInt(data.tell() + header_size, True)
data.write(font)
font_size = data.tell() - start
start = data.tell()
for shader in self.shaders:
header.writeInt(data.tell() + header_size, True)
data.write(shader)
shader_size = data.tell() - start
start = data.tell()
for packfile in self.files:
header.writeInt(data.tell() + header_size, True)
data.write(packfile)
packfile_size = data.tell() - start
for size in (image_size, sound_size, font_size, shader_size,
packfile_size):
header.writeInt(size, True)
self.fp.write(str(header))
self.fp.write(str(data))
self.image_count = len(self.images)
self.sound_count = len(self.sounds)
self.font_count = len(self.fonts)
self.shader_count = len(self.shaders)
self.file_count = len(self.files)
self.sounds = self.images = self.fonts = self.shaders = None
self.files = None
示例5: get_shader
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def get_shader(self, name, vert, frag):
vert = translate_shader_data(vert, 'vertex', 'gles')
frag = translate_shader_data(frag, 'fragment', 'gles')
writer = ByteReader()
writer.writeInt(len(vert))
writer.write(vert)
writer.writeInt(len(frag))
writer.write(frag)
return str(writer)
示例6: write
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def write(self, reader):
reader.writeIntString(self.name)
reader.writeIntString(self.extension)
reader.writeInt(self.identifier)
newReader = ByteReader()
if not self.extension:
newReader.writeShort(self.player)
newReader.writeShort(self.type)
newReader.writeByte(self.movingAtStart)
newReader.write('\x00' * 3)
newReader.writeInt(self.directionAtStart)
self.loader.write(newReader)
reader.writeIntString(str(newReader))
示例7: get_shader
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def get_shader(self, name, vert, frag):
vert_path = os.path.join(SHADERS_DIR, name + '.vsb')
frag_path = os.path.join(SHADERS_DIR, name + '.psb')
with open(vert_path, 'rb') as fp:
vert_data = fp.read()
with open(frag_path, 'rb') as fp:
frag_data = fp.read()
writer = ByteReader()
writer.writeInt(len(vert_data))
writer.write(vert_data)
writer.writeInt(len(frag_data))
writer.write(frag_data)
return str(writer)
示例8: Workspace
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
class Workspace(DataLoader):
name = ''
data = None
def initialize(self):
size = self.settings.get('defaultSize', 0)
self.data = ByteReader()
self.data.write('\x00' * size)
def read(self, reader):
self.name = reader.readString()
self.data = reader.readReader(reader.readInt(True))
def write(self, reader):
reader.writeString(self.name)
reader.writeInt(len(self.data))
reader.writeReader(self.data)
示例9: write_data
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def write_data(self):
header = ByteReader()
data = ByteReader()
header_size = (len(self.images) + len(self.sounds) + len(self.fonts) +
len(self.shaders)) * 4 + len(self.images) * 2
# image preload
self.use_count_offset = header.tell()
for _ in xrange(len(self.images)):
header.writeShort(0, True)
for image in self.images:
header.writeInt(data.tell() + header_size, True)
data.write(image)
for sound in self.sounds:
header.writeInt(data.tell() + header_size, True)
data.write(sound)
for shader in self.shaders:
header.writeInt(data.tell() + header_size, True)
data.write(shader)
self.fp.write(str(header))
self.fp.write(str(data))
self.image_count = len(self.images)
self.sound_count = len(self.sounds)
self.font_count = len(self.fonts)
self.shader_count = len(self.shaders)
self.sounds = self.images = self.fonts = self.shaders = None
示例10: get_wav
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import write [as 别名]
def get_wav(self):
reader = ByteReader()
reader.write('RIFF')
reader.writeInt(len(self.data) - 44)
reader.write('WAVEfmt ')
reader.writeInt(16, True)
reader.writeShort(self.format, True)
reader.writeShort(self.channel_count, True)
reader.writeInt(self.sample_rate, True)
reader.writeInt(self.byte_rate, True)
reader.writeShort(self.block_align, True)
reader.writeShort(self.bits_per_sample, True)
reader.write('data')
reader.writeInt(self.chunk_size, True)
reader.write(self.data)
return reader