time.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package glfw
  2. //#define GLFW_INCLUDE_NONE
  3. //#include "glfw/include/GLFW/glfw3.h"
  4. import "C"
  5. // GetTime returns the value of the GLFW timer. Unless the timer has been set
  6. // using SetTime, the timer measures time elapsed since GLFW was initialized.
  7. //
  8. // The resolution of the timer is system dependent, but is usually on the order
  9. // of a few micro- or nanoseconds. It uses the highest-resolution monotonic time
  10. // source on each supported platform.
  11. func GetTime() float64 {
  12. ret := float64(C.glfwGetTime())
  13. panicError()
  14. return ret
  15. }
  16. // SetTime sets the value of the GLFW timer. It then continues to count up from
  17. // that value.
  18. //
  19. // The resolution of the timer is system dependent, but is usually on the order
  20. // of a few micro- or nanoseconds. It uses the highest-resolution monotonic time
  21. // source on each supported platform.
  22. func SetTime(time float64) {
  23. C.glfwSetTime(C.double(time))
  24. panicError()
  25. }
  26. // GetTimerFrequency returns frequency of the timer, in Hz, or zero if an error occurred.
  27. func GetTimerFrequency() uint64 {
  28. ret := uint64(C.glfwGetTimerFrequency())
  29. panicError()
  30. return ret
  31. }
  32. // GetTimerValue returns the current value of the raw timer, measured in 1 / frequency seconds.
  33. func GetTimerValue() uint64 {
  34. ret := uint64(C.glfwGetTimerValue())
  35. panicError()
  36. return ret
  37. }