Skip to content

Commit

Permalink
Fix tex viewer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiker committed May 25, 2024
1 parent d6856ca commit 36ccb34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 6 additions & 4 deletions GUI/Controls/GLViewerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ private static void OnDebugMessage(DebugSource source, DebugType type, int id, D

public Framebuffer GLDefaultFramebuffer;
public Framebuffer MainFramebuffer;
public Framebuffer FinalFramebuffer;
private int MaxSamples;
private int NumSamples => Math.Max(1, Math.Min(Settings.Config.AntiAliasingSamples, MaxSamples));

Expand Down Expand Up @@ -529,10 +528,13 @@ private void Draw()
}
}

MainFramebuffer.Bind(FramebufferTarget.ReadFramebuffer);
GLDefaultFramebuffer.Bind(FramebufferTarget.DrawFramebuffer);
if (MainFramebuffer != GLDefaultFramebuffer)
{
MainFramebuffer.Bind(FramebufferTarget.ReadFramebuffer);
GLDefaultFramebuffer.Bind(FramebufferTarget.DrawFramebuffer);

FramebufferBlit(MainFramebuffer, GLDefaultFramebuffer);
FramebufferBlit(MainFramebuffer, GLDefaultFramebuffer);
}

if (Settings.Config.DisplayFps != 0)
{
Expand Down
17 changes: 8 additions & 9 deletions GUI/Types/Renderer/GLTextureViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ protected override SKBitmap ReadPixelsToBitmap()
}
finally
{
FinalFramebuffer.Bind(FramebufferTarget.Framebuffer);
MainFramebuffer.Bind(FramebufferTarget.Framebuffer);
bitmap?.Dispose();
}
}
Expand Down Expand Up @@ -835,18 +835,17 @@ private void OnLoad(object sender, EventArgs e)
GL.CreateVertexArrays(1, out vao);

// Use non-msaa framebuffer for texture viewer
if (FinalFramebuffer != GLDefaultFramebuffer)
if (MainFramebuffer != GLDefaultFramebuffer)
{
FinalFramebuffer.Dispose();
FinalFramebuffer = GLDefaultFramebuffer;
MainFramebuffer.Dispose();
MainFramebuffer = GLDefaultFramebuffer;
}

FinalFramebuffer.ClearColor = OpenTK.Graphics.Color4.Green;
FinalFramebuffer.ClearMask = ClearBufferMask.ColorBufferBit;
MainFramebuffer.ClearColor = OpenTK.Graphics.Color4.Green;
MainFramebuffer.ClearMask = ClearBufferMask.ColorBufferBit;

GL.DepthMask(false);
GL.Disable(EnableCap.DepthTest);
GL.Disable(EnableCap.CullFace);

GLLoad -= OnLoad;

Expand Down Expand Up @@ -903,8 +902,8 @@ private void OnPaint(object sender, RenderEventArgs e)
TextureScaleChangeTime += e.FrameTime;

GL.Viewport(0, 0, GLControl.Width, GLControl.Height);
FinalFramebuffer.Clear();
Draw(FinalFramebuffer);
MainFramebuffer.Clear();
Draw(MainFramebuffer);
}

private void Draw(Framebuffer fbo, bool captureFullSizeImage = false)
Expand Down

0 comments on commit 36ccb34

Please sign in to comment.