When I create a window with GLFW (on a Windows operating system) and set GLFW_TRANSPARENT_FRAMEBUFFER to 1 via glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1); I can't draw a rect with a magenta color glColor3f(1.f, 0.f, 1.f);. This color causes the rect to be transparent and makes me able to click through this part of the window.
I did not expect this behavior and also did not find any documentation that explains this.
I used the example code on the GLFW homepage and added a gray, yellow and magenta rect of which only the gray and yellow rect produce expected behavior.
Screenshot that shows the window
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
// ADDED THIS LINE
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
// ADDED THE FOLLOWING LINES
// background
glColor3f(0.1f, 0.1f, 0.1f); // gray
glRectf(-0.75f, 0.75f, 0.75f, -0.75f);
// unexpected behavior: makes part of the window transparent and click through
glColor3f(1.f, 0.f, 1.f); // magenta
glRectf(-0.1f, -0.1f, 0, 0);
// draws yellow rect
glColor3f(1.0f, 1.f, 0.f); // yellow
glRectf(-0.1f, 0.1f, 0, 0);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
The magenta color gets drawn correctly when GLFW_TRANSPARENT_FRAMEBUFFER is set to 0.