background_window.cpp 1013 B

1234567891011121314151617181920212223242526272829303132
  1. #include "background_window.h"
  2. #include <iostream>
  3. IGL_INLINE bool igl::opengl::glfw::background_window(GLFWwindow* & window)
  4. {
  5. if(!glfwInit()) return false;
  6. glfwSetErrorCallback([](int id,const char* m){std::cerr<<m<<std::endl;});
  7. glfwWindowHint(GLFW_SAMPLES, 4);
  8. // Use 3.2 core profile
  9. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  10. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
  11. glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  12. glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  13. // Use background window
  14. glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
  15. window = glfwCreateWindow(1, 1,"", NULL, NULL);
  16. if(!window) return false;
  17. glfwMakeContextCurrent(window);
  18. #ifndef __APPLE__
  19. if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress))
  20. {
  21. printf("Failed to load OpenGL and its extensions");
  22. }
  23. #endif
  24. glGetError(); // pull and safely ignore unhandled errors like GL_INVALID_ENUM
  25. return true;
  26. }
  27. #ifdef IGL_STATIC_LIBRARY
  28. // Explicit template instantiation
  29. #endif