PrusaSlicer/bundled_deps/libigl/igl/opengl/glfw/background_window.cpp
Martin Šach 21116995d7 Refactor CMake and improve #includes.
* 1. Remove all global include_directories.
* 2. Move 3d party dependencies from src to budled deps if possible.
* Unify and enforce one way of including headers:
    e.g. #include "libslic3r/GCode.hpp" vs #include "GCode.hpp"
    (always use the "libslic3r/GCode.hpp" option).
* Make all dependencies (also header only) a cmake target.
2024-07-08 15:36:46 +02:00

31 lines
988 B
C++

#include "background_window.h"
#include <iostream>
IGL_INLINE bool igl::opengl::glfw::background_window(GLFWwindow* & window)
{
if(!glfwInit()) return false;
glfwSetErrorCallback([](int id,const char* m){std::cerr<<m<<std::endl;});
glfwWindowHint(GLFW_SAMPLES, 4);
// Use 3.2 core profile
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// Use background window
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(1, 1,"", NULL, NULL);
if(!window) return false;
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress))
{
printf("Failed to load OpenGL and its extensions");
}
glGetError(); // pull and safely ignore unhandled errors like GL_INVALID_ENUM
return true;
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
#endif