tick.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. return {
  2. tag = 'window',
  3. summary = 'Start a timer on the GPU.',
  4. description = 'Starts a named timer on the GPU, which can be stopped using `lovr.graphics.tock`.',
  5. arguments = {
  6. {
  7. name = 'label',
  8. type = 'string',
  9. description = 'The name of the timer.'
  10. }
  11. },
  12. returns = {},
  13. notes = [[
  14. The timer can be stopped by calling `lovr.graphics.tock` using the same name. All drawing
  15. commands between the tick and the tock will be timed. It is not possible to nest calls to tick
  16. and tock.
  17. GPU timers are not supported on all systems. Check the `timers` feature using
  18. `lovr.graphics.getFeatures` to see if it is supported on the current system.
  19. ]],
  20. example = [[
  21. function lovr.draw()
  22. lovr.graphics.tick('tim')
  23. -- Draw a bunch of cubes
  24. for x = -4, 4 do
  25. for y = -4, 4 do
  26. for z = -4, 4 do
  27. lovr.graphics.cube('fill', x, y, z, .2)
  28. end
  29. end
  30. end
  31. print('it took ' .. (lovr.graphics.tock('tim') or 0) .. ' seconds')
  32. end
  33. ]],
  34. related = {
  35. 'lovr.graphics.tock',
  36. 'lovr.graphics.getFeatures'
  37. }
  38. }