def runLoop(scene, mainWindow): # Print message to console, and kick off the loop to get it rolling. print("Hit ESC key to quit.") frame = 0 totalSleep = 0 start = time.time() while not dgui.window_should_close(mainWindow): dgui.make_context_current(mainWindow) scene.render() now = time.time() toSleep = max(0,(frame+1)/config.maxFPS+start-now) time.sleep(toSleep) dgui.swap_buffers(mainWindow) dgui.poll_events() animateScene(scene, frame) totalSleep += toSleep frame += 1 end = time.time() dgui.terminate() elapsed = end-start computePct = (1-totalSleep/elapsed)*100 renderTime = elapsed-totalSleep frameTime = renderTime/frame*1000 print('Average frame took %.4f ms to render.\nRendered %.4f seconds of a total %.4f seconds.\nRendering %.2f%% of the time.'%(frameTime,renderTime,elapsed,computePct)) exit(0)
def runLoop(scene, mainWindow): # Print message to console, and kick off the loop to get it rolling. renderGraph = scene[list(scene.renderGraphs)[0]] display = renderGraph[list(renderGraph.displays)[0]] frame = 0 totalSleep = 0 start = time.time() while not dgui.window_should_close(mainWindow): dgui.make_context_current(mainWindow) scene.render() now = time.time() toSleep = max(0, (frame + 1) / display.fps + start - now) time.sleep(toSleep) dgui.swap_buffers(mainWindow) dgui.poll_events() scene.animate(frame) totalSleep += toSleep frame += 1 end = time.time() dgui.terminate() elapsed = end - start computePct = (1 - totalSleep / elapsed) * 100 renderTime = elapsed - totalSleep frameTime = renderTime / frame * 1000 print( 'Average frame took %.4f ms to render.\nRendered %.4f seconds of a total %.4f seconds.\nRendering %.2f%% of the time.' % (frameTime, renderTime, elapsed, computePct))
def runLoop(renderStack, mainWindow): # Print message to console, and kick off the loop to get it rolling. print("Hit ESC key to quit.") start = time.time() while not ui.window_should_close(mainWindow): ui.make_context_current(mainWindow) drawScene(renderStack) now = time.time() time.sleep(max((frame+1)/config.maxFPS+start-now,0)) ui.swap_buffers(mainWindow) ui.poll_events() #ui.wait_events() ui.terminate() exit(0)
def runLoop(renderStack, windows, requestedDepth, stillRunning): # Print message to console, and kick off the loop to get it rolling. print("Hit ESC key to quit.") index = 0 while not ui.window_should_close(windows[0]): animate(renderStack) ui.make_context_current(windows[0]) test.drawScene(renderStack) ui.swap_buffers(windows[0]) if TIMING: now = time.time() if (now % 5) < .01: index = int(((now % 15)/5))%len(DEPTHS) switchDepths(windows[0],DEPTHS[index],requestedDepth,renderStack) ui.poll_events() #ui.wait_events() stillRunning.value=False ui.terminate() exit(0)