Missing commit
This commit is contained in:
parent
71a22df8bd
commit
324eb76930
3 changed files with 22 additions and 5 deletions
|
|
@ -13,6 +13,7 @@ using SM.Base.Shaders.Extensions;
|
|||
using SM.Base.Time;
|
||||
using SM.Base.Utility;
|
||||
using SM.OGL;
|
||||
using SM.OGL.Framebuffer;
|
||||
using Keyboard = SM.Base.Controls.Keyboard;
|
||||
using Mouse = SM.Base.Controls.Mouse;
|
||||
|
||||
|
|
@ -26,6 +27,7 @@ namespace SM.Base.Window
|
|||
{
|
||||
GLSystem.INIT_SYSTEM();
|
||||
GLSettings.ShaderPreProcessing = true;
|
||||
Framebuffer.ScreenWindow = window;
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
if (args.Contains("--advDebugging"))
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
|
|
@ -16,6 +17,8 @@ namespace SM.OGL.Framebuffer
|
|||
{
|
||||
protected override bool AutoCompile { get; set; } = true;
|
||||
|
||||
public static IFramebufferWindow ScreenWindow;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the screen buffer.
|
||||
/// </summary>
|
||||
|
|
@ -23,6 +26,8 @@ namespace SM.OGL.Framebuffer
|
|||
{
|
||||
_id = 0,
|
||||
CanCompile = false,
|
||||
_window = ScreenWindow,
|
||||
_windowScale = 1,
|
||||
};
|
||||
|
||||
private IFramebufferWindow _window;
|
||||
|
|
@ -42,7 +47,7 @@ namespace SM.OGL.Framebuffer
|
|||
public Dictionary<string, ColorAttachment> ColorAttachments { get; private set; } =
|
||||
new Dictionary<string, ColorAttachment>();
|
||||
|
||||
public List<RenderbufferAttachment> RenderbufferAttachments { get; } = new List<RenderbufferAttachment>();
|
||||
public Dictionary<RenderbufferAttachment, int> RenderbufferAttachments { get; } = new Dictionary<RenderbufferAttachment, int>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a buffer without any options.
|
||||
|
|
@ -75,6 +80,7 @@ namespace SM.OGL.Framebuffer
|
|||
/// <inheritdoc />
|
||||
public override void Compile()
|
||||
{
|
||||
if (_id == 0) _window = ScreenWindow;
|
||||
if (_window != null) Size = new Vector2(_window.Width * _windowScale, _window.Height * _windowScale);
|
||||
|
||||
base.Compile();
|
||||
|
|
@ -95,10 +101,11 @@ namespace SM.OGL.Framebuffer
|
|||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, pair.Value.FramebufferAttachment, pair.Value.Target, pair.Value.ID,
|
||||
0);
|
||||
|
||||
foreach (RenderbufferAttachment attachment in RenderbufferAttachments)
|
||||
foreach (RenderbufferAttachment attachment in RenderbufferAttachments.Keys.ToArray())
|
||||
{
|
||||
int att = attachment.Generate(this);
|
||||
GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, attachment.FramebufferAttachment, RenderbufferTarget.Renderbuffer, att);
|
||||
RenderbufferAttachments[attachment] = att;
|
||||
}
|
||||
|
||||
var err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
|
||||
|
|
@ -114,6 +121,11 @@ namespace SM.OGL.Framebuffer
|
|||
{
|
||||
|
||||
foreach (var attachment in ColorAttachments.Values) attachment.Dispose();
|
||||
foreach (KeyValuePair<RenderbufferAttachment, int> pair in RenderbufferAttachments.ToArray())
|
||||
{
|
||||
GL.DeleteRenderbuffer(pair.Value);
|
||||
RenderbufferAttachments[pair.Key] = -1;
|
||||
}
|
||||
GL.DeleteFramebuffer(this);
|
||||
base.Dispose();
|
||||
|
||||
|
|
@ -133,7 +145,7 @@ namespace SM.OGL.Framebuffer
|
|||
|
||||
public void AppendRenderbuffer(RenderbufferAttachment attachment)
|
||||
{
|
||||
RenderbufferAttachments.Add(attachment);
|
||||
RenderbufferAttachments.Add(attachment, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using SM.Base.PostEffects;
|
||||
using SM.Base.Window;
|
||||
using SM.OGL.Framebuffer;
|
||||
using SM.OGL.Texture;
|
||||
|
||||
namespace SM_TEST
|
||||
{
|
||||
|
|
@ -13,9 +14,9 @@ namespace SM_TEST
|
|||
public override void Initialization()
|
||||
{
|
||||
|
||||
MainFramebuffer = CreateWindowFramebuffer(16);
|
||||
MainFramebuffer = CreateWindowFramebuffer(0, true, PixelInformation.RGBA_HDR);
|
||||
|
||||
_postBuffer = CreateWindowFramebuffer();
|
||||
_postBuffer = CreateWindowFramebuffer(0, false, PixelInformation.RGBA_HDR);
|
||||
Framebuffers.Add(_postBuffer);
|
||||
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .5f)
|
||||
{
|
||||
|
|
@ -34,7 +35,9 @@ namespace SM_TEST
|
|||
context.Scene.DrawMainObjects(context);
|
||||
context.Scene.DrawHUD(context);
|
||||
|
||||
|
||||
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
_bloom.Draw(context);
|
||||
|
||||
context.Scene.DrawDebug(context);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue