Open ToukiLiu opened 2 years ago
I'm not sure if this is possible atm. It would at least require the backbuffer to have some alpha bits in the settings for the control. But I'm not sure if that is enough.
This is hard, and in most cases it requires a lot of complicated code to interact directly with the underlying window system. On Windows, you'll need to write a number of Windows-specific DWM API calls to indicate how the window compositing should work, as described in the answers to this StackOverflow question. I'm not sure what's required on X (apparently a number of glXFBConfig calls?) or on MacOS, but I'd suspect its nontrivial.
Either way, it's way outside the scope of the OpenTK project, which currently exposes the underlying window system mostly as GLFW provides access to it. Even future versions of OpenTK are very unlikely to support this, given how complex and nonportable it is.
Making a transparent OpenGL window on windows only requires talking to WGL from what I've read from WGL documentation. GLFW supports creating transparent framebuffers, though I'm unsure if this control uses the GLFW context or some other trickery.
I've not tried enabling the GLFW transparent framebuffer feature in combination with this control, but there is a slight chance it would work. I've not looked into the code for this control thoroughly enough to be able to judge this. But I think it's definitely worth a try.
This is something that will definitely be supported by the PAL 2.0 windowing system (at least as a platform specific windows feature enable). Though that is a long long time from being ready for release.
Reading through the GLFW source code, it does look like they attempt to call the appropriate DWM APIs if you use their transparency. I didn't check to see if it uses the correct PFD flags. I can't really place any bets about what would happen if you used them with this, though, given that there's an outer window that acts as a "container" for the GLFW window under WinForms, and the outer may need to have compositing enabled on it too.
Either way, it's more than just the WGL functions: The desktop compositor needs to get involved too if you want to be able to see what's behind your window on modern Windows.
The PAL in OpenTK 5 may be able to support transparency, but it'll still need a bunch of new code to wrap it to support WinForms, so the same issue may exist there too if we're not careful about how the PAL is implemented.
Absolutely, I just think we shouldn't close the issue without trying. And if it's not possible with OpenTK 4 we should still track this for OpenTK 5 so we know it's an issue we should consider at some point.
Will look into this for 4.0
but it'll likely not be very simple to achieve, so it's likely it won't get into 4.0
.
I'm opengl beginer. And I'm trying to let GLControl overlap on other UserControls, to show both of GLControl's element and bottom UserControl's element. But GLContorl's background Transparent is not work. Both of
and
didn't work.
Is there any way set GLControl background Transparent?