microsoft / angle

ANGLE: OpenGL ES to DirectX translation
Other
615 stars 166 forks source link

What blending operation is used to merge transparent OpenGL surface with XAML? #85

Closed dmitriano closed 8 years ago

dmitriano commented 8 years ago

Hello! What blending operation is used to merge OpenGL surface with XAML, if I draw a transparent image in SwapChainPanel (with OpenGL calls)? Is it possible to change it to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)? If my question sounds a bit wired, my article describing the experimentation I done with a UWP app will give you more detailed picture on what I am asking.

austinkinross commented 8 years ago

Hi, apologies for the delayed reply. The blending mode isn't customizable. On some hardware (particularly phones), the blending operation between surfaces will be performed by highly optimized hardware that may not be configurable.

The alpha mode of the surface can be configured, but not using an Open GL ES API. You would have to modify ANGLE's source code yourself by changing the D3D swapchain's alpha mode to another valid DXGI_ALPHA_MODE value.

    swapChainDesc.AlphaMode =
        containsAlpha ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE;

https://github.com/Microsoft/angle/blob/ms-master/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp

dmitriano commented 8 years ago

Thank you very much, for detailed explanation.