background_window.cpp 988 B

123456789101112131415161718192021222324252627282930
  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. if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress))
  19. {
  20. printf("Failed to load OpenGL and its extensions");
  21. }
  22. glGetError(); // pull and safely ignore unhandled errors like GL_INVALID_ENUM
  23. return true;
  24. }
  25. #ifdef IGL_STATIC_LIBRARY
  26. // Explicit template instantiation
  27. #endif