05.01.2021
+ Bloom effect + PixelInformation + Many Summaries + Add-methods for CVectors + Exposure-Field in GenericCamera for HDR. ~ ColorAttachments now can have PixelInformation ~ Transformed MeshAttributes to a own class ~ Fixed the non-applying of transformations at texts ~ Added more information to the context ~ Improved Pipeline-Process. ~ Changed how Uniform takes arrays - Light system
This commit is contained in:
parent
9b917ac181
commit
4c18127c88
52 changed files with 697 additions and 373 deletions
|
|
@ -9,9 +9,14 @@ using OpenTK.Graphics.OpenGL4;
|
|||
|
||||
namespace SM.OGL.Framebuffer
|
||||
{
|
||||
// TODO: Write summeries for framebuffer-system.
|
||||
/// <summary>
|
||||
/// Represents a OpenGL Framebuffer.
|
||||
/// </summary>
|
||||
public class Framebuffer : GLObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the screen buffer.
|
||||
/// </summary>
|
||||
public static readonly Framebuffer Screen = new Framebuffer
|
||||
{
|
||||
_id = 0,
|
||||
|
|
@ -23,10 +28,18 @@ namespace SM.OGL.Framebuffer
|
|||
private INativeWindow _window;
|
||||
private float _windowScale;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a buffer without any options.
|
||||
/// </summary>
|
||||
public Framebuffer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a buffer, while always respecting the screen.
|
||||
/// </summary>
|
||||
/// <param name="window"></param>
|
||||
/// <param name="scale"></param>
|
||||
public Framebuffer(INativeWindow window, float scale = 1) : this(new Vector2(window.Width * scale,
|
||||
window.Height * scale))
|
||||
{
|
||||
|
|
@ -34,18 +47,30 @@ namespace SM.OGL.Framebuffer
|
|||
_windowScale = scale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a buffer, with a specified size.
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
public Framebuffer(Vector2 size)
|
||||
{
|
||||
Size = size;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Framebuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the size of the framebuffer.
|
||||
/// </summary>
|
||||
public Vector2 Size { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains all color attachments.
|
||||
/// </summary>
|
||||
public Dictionary<string, ColorAttachment> ColorAttachments { get; private set; } =
|
||||
new Dictionary<string, ColorAttachment>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Compile()
|
||||
{
|
||||
if (!_canBeCompiled) return;
|
||||
|
|
@ -78,6 +103,7 @@ namespace SM.OGL.Framebuffer
|
|||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
|
@ -85,32 +111,76 @@ namespace SM.OGL.Framebuffer
|
|||
GL.DeleteFramebuffer(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a color attachment.
|
||||
/// </summary>
|
||||
public void Append(string key, int pos) => Append(key, new ColorAttachment(pos));
|
||||
/// <summary>
|
||||
/// Appends a color attachment.
|
||||
/// </summary>
|
||||
public void Append(string key, ColorAttachment value)
|
||||
{
|
||||
ColorAttachments.Add(key, value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Activates the framebuffer without clearing the buffer.
|
||||
/// </summary>
|
||||
public void Activate()
|
||||
{
|
||||
Activate(FramebufferTarget.Framebuffer, ClearBufferMask.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the framebuffer for the specific target framebuffer and without clearing.
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
public void Activate(FramebufferTarget target)
|
||||
{
|
||||
Activate(target, ClearBufferMask.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the framebuffer while clearing the specified buffer.
|
||||
/// </summary>
|
||||
/// <param name="clearMask"></param>
|
||||
public void Activate(ClearBufferMask clearMask)
|
||||
{
|
||||
Activate(FramebufferTarget.Framebuffer, clearMask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the framebuffer for the specific target and with clearing.
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="clear"></param>
|
||||
public void Activate(FramebufferTarget target, ClearBufferMask clear)
|
||||
{
|
||||
GL.BindFramebuffer(target, this);
|
||||
GL.Clear(clear);
|
||||
}
|
||||
|
||||
public static Framebuffer GetCurrentlyActive(FramebufferTarget target = FramebufferTarget.Framebuffer)
|
||||
{
|
||||
Framebuffer buffer = new Framebuffer()
|
||||
{
|
||||
_canBeCompiled = false,
|
||||
};
|
||||
switch (target)
|
||||
{
|
||||
case FramebufferTarget.ReadFramebuffer:
|
||||
GL.GetInteger(GetPName.ReadFramebufferBinding, out buffer._id);
|
||||
break;
|
||||
case FramebufferTarget.DrawFramebuffer:
|
||||
GL.GetInteger(GetPName.DrawFramebufferBinding, out buffer._id);
|
||||
break;
|
||||
case FramebufferTarget.Framebuffer:
|
||||
GL.GetInteger(GetPName.FramebufferBinding, out buffer._id);
|
||||
break;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue