GLFWWrapper.cpp 571 B

12345678910111213141516171819202122232425262728293031
  1. #include <iostream>
  2. #include <GL/glew.h>
  3. #include <GLFW/glfw3.h>
  4. #include "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. if(!error) {
  14. glfwTerminate();
  15. }
  16. }
  17. };
  18. static GLFWInit init;
  19. bool GLFWWrapper::hasError() {
  20. return init.error;
  21. }
  22. u64 GLFWWrapper::getTimeNanos() {
  23. return glfwGetTimerValue() * (1000000000 / glfwGetTimerFrequency());
  24. }