I am stuck with window transparency in GLFW, I followed their window guide and examples but nothing seems to work... GLFW version 3.3 with OpenGL 3.3 as well.
I went through the gears example in GLFW's repository, which introduces a completely transparent window, copied the required window hint (GLFW_FRAMEBUFFER_TRANSPARENCY) and set it to true. This does not work for me
I am initializing my window using the following:
if (!glfwInit()) {
printf("Could not initialize GLFW\n");
return 1;
}
GLFWwindow *window = glfwCreateWindow(500, 500, "opengl", NULL, NULL);
if (!window) {
printf("Could not create GLFW window");
return 1;
}
glfwWindowHint(GLFW_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, 1);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetFramebufferSizeCallback(window, resizeCallback);
Then I clear this way:
glClearColor(1.0, 1.0, 1.0, 0.1);
glClear(GL_COLOR_BUFFER_BIT);
I expect the window to be semi-transparent, did I missed something?
1 Answer
glfwWindowHint has to be called before the window gets created (which can be seen in the demo you mentioned). Otherwise they do not have any effect. Correct code:
glfwWindowHint(GLFW_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, 1);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
GLFWwindow *window = glfwCreateWindow(500, 500, "opengl", NULL, NULL);
if (!window) {
printf("Could not create GLFW window");
return 1;
}