Make sure to clear alpha channel when presenting Texture
This fix once and for all the transparency issue on Windows.
This commit is contained in:
parent
a528199cd4
commit
58d501f758
2 changed files with 29 additions and 13 deletions
|
@ -22,15 +22,30 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
public void Present(ITexture texture, ImageCrop crop)
|
public void Present(ITexture texture, ImageCrop crop)
|
||||||
{
|
{
|
||||||
TextureView view = (TextureView)texture;
|
|
||||||
|
|
||||||
GL.Disable(EnableCap.FramebufferSrgb);
|
GL.Disable(EnableCap.FramebufferSrgb);
|
||||||
|
|
||||||
|
CopyTextureToFrameBufferRGB(0, GetCopyFramebufferHandleLazy(), (TextureView)texture, crop);
|
||||||
|
|
||||||
|
GL.Enable(EnableCap.FramebufferSrgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSize(int width, int height)
|
||||||
|
{
|
||||||
|
_width = width;
|
||||||
|
_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void CopyTextureToFrameBufferRGB(int drawFramebuffer, int readFramebuffer, TextureView view, ImageCrop crop)
|
||||||
|
{
|
||||||
|
bool[] oldFramebufferColorWritemask = new bool[4];
|
||||||
|
|
||||||
int oldReadFramebufferHandle = GL.GetInteger(GetPName.ReadFramebufferBinding);
|
int oldReadFramebufferHandle = GL.GetInteger(GetPName.ReadFramebufferBinding);
|
||||||
int oldDrawFramebufferHandle = GL.GetInteger(GetPName.DrawFramebufferBinding);
|
int oldDrawFramebufferHandle = GL.GetInteger(GetPName.DrawFramebufferBinding);
|
||||||
|
GL.GetBoolean(GetIndexedPName.ColorWritemask, drawFramebuffer, oldFramebufferColorWritemask);
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, 0);
|
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, drawFramebuffer);
|
||||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, GetCopyFramebufferHandleLazy());
|
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, readFramebuffer);
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
GL.FramebufferTexture(
|
||||||
FramebufferTarget.ReadFramebuffer,
|
FramebufferTarget.ReadFramebuffer,
|
||||||
|
@ -93,16 +108,17 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
ClearBufferMask.ColorBufferBit,
|
ClearBufferMask.ColorBufferBit,
|
||||||
BlitFramebufferFilter.Linear);
|
BlitFramebufferFilter.Linear);
|
||||||
|
|
||||||
|
// Remove Alpha channel
|
||||||
|
GL.ColorMask(drawFramebuffer, false, false, false, true);
|
||||||
|
GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { 0.0f, 0.0f, 0.0f, 1.0f });
|
||||||
|
GL.ColorMask(drawFramebuffer,
|
||||||
|
oldFramebufferColorWritemask[0],
|
||||||
|
oldFramebufferColorWritemask[1],
|
||||||
|
oldFramebufferColorWritemask[2],
|
||||||
|
oldFramebufferColorWritemask[3]);
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle);
|
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle);
|
||||||
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle);
|
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle);
|
||||||
|
|
||||||
GL.Enable(EnableCap.FramebufferSrgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSize(int width, int height)
|
|
||||||
{
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetCopyFramebufferHandleLazy()
|
private int GetCopyFramebufferHandleLazy()
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Ryujinx.Ui
|
||||||
private Input.NpadController _primaryController;
|
private Input.NpadController _primaryController;
|
||||||
|
|
||||||
public GLRenderer(Switch device)
|
public GLRenderer(Switch device)
|
||||||
: base (new GraphicsMode(new ColorFormat(24)),
|
: base (new GraphicsMode(new ColorFormat()),
|
||||||
3, 3,
|
3, 3,
|
||||||
GraphicsContextFlags.ForwardCompatible)
|
GraphicsContextFlags.ForwardCompatible)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue