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?

5

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; } 
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.