GLFWWrapper.cpp 543 B

1234567891011121314151617181920212223242526272829
  1. #include <iostream>
  2. #include <GL/glew.h>
  3. #include <GLFW/glfw3.h>
  4. #include "client/rendering/wrapper/GLFWWrapper.h"
  5. struct GLFWInit final {
  6. bool error;
  7. GLFWInit() : error(glfwInit() == GLFW_FALSE) {
  8. if(error) {
  9. std::cout << "could not initialize GLFW\n";
  10. }
  11. }
  12. ~GLFWInit() {
  13. glfwTerminate();
  14. }
  15. };
  16. static GLFWInit init;
  17. bool GLFWWrapper::hasError() {
  18. return init.error;
  19. }
  20. u64 GLFWWrapper::getTimeNanos() {
  21. return glfwGetTimerValue() * (1000000000 / glfwGetTimerFrequency());
  22. }