tock.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. return {
  2. tag = 'window',
  3. summary = 'Stop a timer on the GPU.',
  4. description = 'Stops a named timer on the GPU, previously started with `lovr.graphics.tick`.',
  5. arguments = {
  6. {
  7. name = 'label',
  8. type = 'string',
  9. description = 'The name of the timer.'
  10. }
  11. },
  12. returns = {
  13. {
  14. name = 'time',
  15. type = 'number',
  16. description = 'The number of seconds elapsed, or `nil` if the data isn\'t ready yet.'
  17. }
  18. },
  19. notes = [[
  20. All drawing commands between tick and tock will be timed. It is not possible to nest calls to
  21. tick and tock.
  22. The results are delayed, and might be `nil` for the first few frames. This function returns
  23. the most recent available timer value.
  24. GPU timers are not supported on all systems. Check the `timers` feature using
  25. `lovr.graphics.getFeatures` to see if it is supported on the current system.
  26. ]],
  27. example = [[
  28. function lovr.draw()
  29. lovr.graphics.tick('tim')
  30. -- Draw a bunch of cubes
  31. for x = -4, 4 do
  32. for y = -4, 4 do
  33. for z = -4, 4 do
  34. lovr.graphics.cube('fill', x, y, z, .2)
  35. end
  36. end
  37. end
  38. print('it took ' .. (lovr.graphics.tock('tim') or 0) .. ' seconds')
  39. end
  40. ]],
  41. related = {
  42. 'lovr.graphics.tick',
  43. 'lovr.graphics.getFeatures'
  44. }
  45. }