-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix texture disposing. Handle srgb correction
- Loading branch information
1 parent
967c0cd
commit 0897e94
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Fushigi.gl.Shaders; | ||
using Silk.NET.OpenGL; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Fushigi.gl | ||
{ | ||
public class HDRScreenBuffer | ||
{ | ||
public GLTexture2D GetOutput() => (GLTexture2D)Framebuffer.Attachments[0]; | ||
|
||
private GLFramebuffer Framebuffer; | ||
|
||
private ScreenQuad ScreenQuad; | ||
Check failure on line 18 in Fushigi/gl/HDRScreenBuffer.cs GitHub Actions / build
|
||
|
||
public void Render(GL gl, int width, int height, GLTexture2D input) | ||
{ | ||
if (Framebuffer == null) | ||
Framebuffer = new GLFramebuffer(gl, FramebufferTarget.Framebuffer, (uint)width, (uint)height, InternalFormat.Rgba); | ||
|
||
//Resize if needed | ||
if (Framebuffer.Width != (uint)width || Framebuffer.Height != (uint)height) | ||
Framebuffer.Resize((uint)width, (uint)height); | ||
|
||
Framebuffer.Bind(); | ||
|
||
gl.ClearColor(0, 0, 0, 0); | ||
gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); | ||
gl.Viewport(0, 0, Framebuffer.Width, Framebuffer.Height); | ||
|
||
var shader = GLShaderCache.GetShader(gl, "PostEffect", | ||
Path.Combine("res", "shaders", "screen.vert"), | ||
Path.Combine("res", "shaders", "screen.frag")); | ||
|
||
shader.Use(); | ||
shader.SetTexture("screenTexture", input, 1); | ||
|
||
if (ScreenQuad == null) ScreenQuad = new ScreenQuad(gl, 1f); | ||
|
||
ScreenQuad.Draw(shader); | ||
|
||
gl.BindFramebuffer(FramebufferTarget.Framebuffer, 0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters