mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Show FPS, and don't clobber the time module
This commit is contained in:
parent
8ce2470dfb
commit
0fc80889c9
26
main.py
26
main.py
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
@ -74,7 +75,6 @@ def main(args):
|
|||||||
genome_ptr, ngenomes = pyflam3.Genome.from_string(args.flame.read())
|
genome_ptr, ngenomes = pyflam3.Genome.from_string(args.flame.read())
|
||||||
genomes = cast(genome_ptr, POINTER(pyflam3.Genome*ngenomes)).contents
|
genomes = cast(genome_ptr, POINTER(pyflam3.Genome*ngenomes)).contents
|
||||||
|
|
||||||
|
|
||||||
if args.qs:
|
if args.qs:
|
||||||
for g in genomes:
|
for g in genomes:
|
||||||
g.sample_density *= args.qs
|
g.sample_density *= args.qs
|
||||||
@ -163,6 +163,8 @@ def main(args):
|
|||||||
def on_mouse_motion(x, y, dx, dy):
|
def on_mouse_motion(x, y, dx, dy):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
last_time = [time.time()]
|
||||||
|
|
||||||
frames = anim.render_frames(times, sync=args.sync)
|
frames = anim.render_frames(times, sync=args.sync)
|
||||||
def poll(dt):
|
def poll(dt):
|
||||||
out = next(frames, False)
|
out = next(frames, False)
|
||||||
@ -170,11 +172,13 @@ def main(args):
|
|||||||
label.text = "Done. ('q' to quit)"
|
label.text = "Done. ('q' to quit)"
|
||||||
pyglet.clock.unschedule(poll)
|
pyglet.clock.unschedule(poll)
|
||||||
elif out is not None:
|
elif out is not None:
|
||||||
time, buf = out
|
real_dt = time.time() - last_time[0]
|
||||||
save(args, time, buf)
|
last_time[0] = time.time()
|
||||||
|
ftime, buf = out
|
||||||
|
save(args, ftime, buf)
|
||||||
imgbuf = np.uint8(buf.flatten() * 255)
|
imgbuf = np.uint8(buf.flatten() * 255)
|
||||||
image.set_data('RGBA', -anim.features.width*4, imgbuf.tostring())
|
image.set_data('RGBA', -anim.features.width*4, imgbuf.tostring())
|
||||||
label.text = '%s %4g' % (args.name, time)
|
label.text = '%s %4g (%g fps)' % (args.name, ftime, 1./real_dt)
|
||||||
else:
|
else:
|
||||||
label.text += '.'
|
label.text += '.'
|
||||||
if args.sleep:
|
if args.sleep:
|
||||||
@ -185,8 +189,8 @@ def main(args):
|
|||||||
pyglet.app.run()
|
pyglet.app.run()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for time, out in ifilter(None, anim.render_frames(times, sync=args.sync)):
|
for ftime, out in ifilter(None, anim.render_frames(times, sync=args.sync)):
|
||||||
save(args, time, out)
|
save(args, ftime, out)
|
||||||
if args.sleep:
|
if args.sleep:
|
||||||
time.sleep(args.sleep)
|
time.sleep(args.sleep)
|
||||||
|
|
||||||
@ -209,7 +213,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--raw', action='store_true', dest='raw',
|
parser.add_argument('--raw', action='store_true', dest='raw',
|
||||||
help="Do not write files; instead, send raw RGBA data to stdout.")
|
help="Do not write files; instead, send raw RGBA data to stdout.")
|
||||||
|
|
||||||
time = parser.add_argument_group('Sequence options', description="""
|
seq = parser.add_argument_group('Sequence options', description="""
|
||||||
Control which frames are rendered from a genome sequence. If '-k' is
|
Control which frames are rendered from a genome sequence. If '-k' is
|
||||||
not given, '-s' and '-e' act as limits, and any control point with a
|
not given, '-s' and '-e' act as limits, and any control point with a
|
||||||
time in bounds is rendered at its central time. If '-k' is given,
|
time in bounds is rendered at its central time. If '-k' is given,
|
||||||
@ -217,14 +221,14 @@ if __name__ == "__main__":
|
|||||||
Python's range operator, as in range(start, end, skip).
|
Python's range operator, as in range(start, end, skip).
|
||||||
|
|
||||||
If no options are given, all control points are rendered.""")
|
If no options are given, all control points are rendered.""")
|
||||||
time.add_argument('-s', dest='start', metavar='TIME', type=float,
|
seq.add_argument('-s', dest='start', metavar='TIME', type=float,
|
||||||
help="Start time of image sequence (inclusive)")
|
help="Start time of image sequence (inclusive)")
|
||||||
time.add_argument('-e', dest='end', metavar='TIME', type=float,
|
seq.add_argument('-e', dest='end', metavar='TIME', type=float,
|
||||||
help="End time of image sequence (exclusive)")
|
help="End time of image sequence (exclusive)")
|
||||||
time.add_argument('-k', dest='skip', metavar='TIME', type=float,
|
seq.add_argument('-k', dest='skip', metavar='TIME', type=float,
|
||||||
help="Skip time between frames in image sequence. Auto-sets "
|
help="Skip time between frames in image sequence. Auto-sets "
|
||||||
"--tempscale, use '--tempscale 1' to override.")
|
"--tempscale, use '--tempscale 1' to override.")
|
||||||
time.add_argument('--renumber', metavar="TIME", type=float,
|
seq.add_argument('--renumber', metavar="TIME", type=float,
|
||||||
dest='renumber', nargs='?', const=0,
|
dest='renumber', nargs='?', const=0,
|
||||||
help="Renumber frame times, counting up from the supplied start time "
|
help="Renumber frame times, counting up from the supplied start time "
|
||||||
"(default is 0).")
|
"(default is 0).")
|
||||||
|
Loading…
Reference in New Issue
Block a user