main.lua 877 B

12345678910111213141516171819202122232425262728293031323334
  1. function lovr.load()
  2. readbacks = {}
  3. buffer = lovr.graphics.newBuffer('uint')
  4. pixels = 0
  5. end
  6. function lovr.update(dt)
  7. while readbacks[1] and readbacks[1]:isComplete() do
  8. pixels = readbacks[1]:getData()
  9. table.remove(readbacks, 1)
  10. end
  11. end
  12. function lovr.draw(pass)
  13. -- Track metrics in the Tally when drawing the cube
  14. pass:beginTally()
  15. pass:cube(0, 0.7, -1, .5, lovr.headset.getTime())
  16. pass:finishTally()
  17. -- Render most recent tally result
  18. pass:text(('Cube is %d pixels'):format(pixels), 0, 1.7, -1, .1)
  19. -- Tell the pass to copy the tally result to the buffer
  20. pass:setTallyBuffer(buffer)
  21. -- Submit the pass
  22. lovr.graphics.submit(pass)
  23. -- Read back the tally result from the buffer (after submission)
  24. table.insert(readbacks, buffer:newReadback())
  25. -- We already submitted the pass, tell lovr not to submit it again!
  26. return true
  27. end