Merge branch 'master' of https://github.com/IedSoftworks/SMRendererV3
This commit is contained in:
commit
3bc90dd83b
14 changed files with 190 additions and 49 deletions
|
|
@ -15,6 +15,11 @@ namespace SM.Base.Drawing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class DrawingBasis : IShowItem, IModelItem
|
public abstract class DrawingBasis : IShowItem, IModelItem
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The camera, that was used last time the object was rendered.
|
||||||
|
/// </summary>
|
||||||
|
public GenericCamera LastDrawingCamera;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The material it should use.
|
/// The material it should use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -86,6 +91,8 @@ namespace SM.Base.Drawing
|
||||||
context.ForcedType = ForcedMeshType;
|
context.ForcedType = ForcedMeshType;
|
||||||
context.TextureMatrix *= TextureTransform.GetMatrix();
|
context.TextureMatrix *= TextureTransform.GetMatrix();
|
||||||
context.LastObject = this;
|
context.LastObject = this;
|
||||||
|
|
||||||
|
LastDrawingCamera = context.UseCamera;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,12 @@ namespace SM.Base.PostEffects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Power = 1;
|
public float Power = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Radius of the effect
|
||||||
|
/// <para>Default: 2</para>
|
||||||
|
/// </summary>
|
||||||
|
public float Radius = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This can disable the bloom calculation.
|
/// This can disable the bloom calculation.
|
||||||
/// <para>Default: true</para>
|
/// <para>Default: true</para>
|
||||||
|
|
@ -127,7 +133,7 @@ namespace SM.Base.PostEffects
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override void InitProcess()
|
protected override void InitProcess()
|
||||||
{
|
{
|
||||||
_source = Pipeline.MainFramebuffer;
|
_source ??= Pipeline.MainFramebuffer;
|
||||||
|
|
||||||
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
|
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
|
||||||
|
|
||||||
|
|
@ -175,6 +181,8 @@ namespace SM.Base.PostEffects
|
||||||
collection["Weights"].SetUniform1(_weights);
|
collection["Weights"].SetUniform1(_weights);
|
||||||
collection["WeightCount"].SetUniform1(WeightCurvePickAmount);
|
collection["WeightCount"].SetUniform1(WeightCurvePickAmount);
|
||||||
collection["Power"].SetUniform1(Power);
|
collection["Power"].SetUniform1(Power);
|
||||||
|
|
||||||
|
collection["Radius"].SetUniform1(_textureScale * Radius);
|
||||||
});
|
});
|
||||||
|
|
||||||
hoz = !hoz;
|
hoz = !hoz;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ namespace SM.Base.PostEffects
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This resolves a multisampled framebuffer to a non-multisampled renderbuffer.
|
/// This resolves a multisampled framebuffer to a non-multisampled renderbuffer.
|
||||||
|
/// <para>This removes the depth buffer.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="multisampledBuffers"></param>
|
/// <param name="multisampledBuffers"></param>
|
||||||
/// <param name="target"></param>
|
/// <param name="target"></param>
|
||||||
|
|
@ -36,7 +37,7 @@ namespace SM.Base.PostEffects
|
||||||
multisampledBuffers.Activate(FramebufferTarget.ReadFramebuffer);
|
multisampledBuffers.Activate(FramebufferTarget.ReadFramebuffer);
|
||||||
target.Activate(FramebufferTarget.DrawFramebuffer);
|
target.Activate(FramebufferTarget.DrawFramebuffer);
|
||||||
GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0,
|
GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0,
|
||||||
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit,
|
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit,
|
||||||
BlitFramebufferFilter.Nearest);
|
BlitFramebufferFilter.Nearest);
|
||||||
|
|
||||||
target.Activate();
|
target.Activate();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ uniform float[32] Weights;
|
||||||
uniform int WeightCount;
|
uniform int WeightCount;
|
||||||
uniform float Power;
|
uniform float Power;
|
||||||
|
|
||||||
|
uniform float Radius;
|
||||||
|
|
||||||
layout(location = 0) out vec4 color;
|
layout(location = 0) out vec4 color;
|
||||||
|
|
||||||
vec4 GetRenderColorOffset(vec2 offset);
|
vec4 GetRenderColorOffset(vec2 offset);
|
||||||
|
|
@ -33,12 +35,13 @@ void main() {
|
||||||
|
|
||||||
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
|
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
|
||||||
|
|
||||||
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1);
|
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1) * GetWeight(0);
|
||||||
result *= GetWeight(0);
|
|
||||||
|
float radi = Radius + (length(result));
|
||||||
|
|
||||||
for(int i = 1; i < WeightCount; i++) {
|
for(int i = 1; i < WeightCount; i++) {
|
||||||
result += max(GetRenderColorOffset(tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
result += max(GetRenderColorOffset(tex_offset * i * radi).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||||
result += max(GetRenderColorOffset(-tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
result += max(GetRenderColorOffset(-tex_offset * i * radi).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
color = vec4(result, 1);
|
color = vec4(result, 1);
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@
|
||||||
<Name>SM.OGL</Name>
|
<Name>SM.OGL</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" />
|
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -75,29 +75,57 @@ namespace SM.Base.Window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Resize()
|
public virtual void Resize()
|
||||||
{
|
{
|
||||||
if (Framebuffers == null) return;
|
Recompile();
|
||||||
foreach (var framebuffer in Framebuffers)
|
}
|
||||||
framebuffer.Dispose();
|
|
||||||
|
|
||||||
Thread.Sleep(50);
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compiles the framebuffers.
|
||||||
|
/// </summary>
|
||||||
|
public void Compile()
|
||||||
|
{
|
||||||
foreach (var framebuffer in Framebuffers)
|
foreach (var framebuffer in Framebuffers)
|
||||||
framebuffer.Compile();
|
framebuffer.Compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recompiles the pipeline.
|
||||||
|
/// </summary>
|
||||||
|
public void Recompile()
|
||||||
|
{
|
||||||
|
if (Framebuffers == null) return;
|
||||||
|
Dispose();
|
||||||
|
|
||||||
|
Thread.Sleep(100);
|
||||||
|
|
||||||
|
Compile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes unmanaged resources like Framebuffers.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
foreach (var framebuffer in Framebuffers)
|
||||||
|
framebuffer.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This creates a finished setup for a framebuffer.
|
/// This creates a finished setup for a framebuffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="multisamples"></param>
|
/// <param name="multisamples"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Framebuffer CreateWindowFramebuffer(int multisamples = 0)
|
public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true)
|
||||||
{
|
{
|
||||||
Framebuffer framebuffer = new Framebuffer(ConnectedWindow);
|
Framebuffer framebuffer = new Framebuffer(ConnectedWindow);
|
||||||
framebuffer.Append("color", new ColorAttachment(0, PixelInformation.RGBA_LDR, multisamples));
|
framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples));
|
||||||
|
|
||||||
|
if (depth)
|
||||||
|
{
|
||||||
RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth;
|
RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth;
|
||||||
depthAttach.Multisample = multisamples;
|
depthAttach.Multisample = multisamples;
|
||||||
framebuffer.AppendRenderbuffer(depthAttach);
|
framebuffer.AppendRenderbuffer(depthAttach);
|
||||||
|
}
|
||||||
|
|
||||||
return framebuffer;
|
return framebuffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ using SM.Base.Shaders.Extensions;
|
||||||
using SM.Base.Time;
|
using SM.Base.Time;
|
||||||
using SM.Base.Utility;
|
using SM.Base.Utility;
|
||||||
using SM.OGL;
|
using SM.OGL;
|
||||||
|
using SM.OGL.Framebuffer;
|
||||||
using Keyboard = SM.Base.Controls.Keyboard;
|
using Keyboard = SM.Base.Controls.Keyboard;
|
||||||
using Mouse = SM.Base.Controls.Mouse;
|
using Mouse = SM.Base.Controls.Mouse;
|
||||||
|
|
||||||
|
|
@ -26,6 +27,7 @@ namespace SM.Base.Window
|
||||||
{
|
{
|
||||||
GLSystem.INIT_SYSTEM();
|
GLSystem.INIT_SYSTEM();
|
||||||
GLSettings.ShaderPreProcessing = true;
|
GLSettings.ShaderPreProcessing = true;
|
||||||
|
Framebuffer.ScreenWindow = window;
|
||||||
|
|
||||||
var args = Environment.GetCommandLineArgs();
|
var args = Environment.GetCommandLineArgs();
|
||||||
if (args.Contains("--advDebugging"))
|
if (args.Contains("--advDebugging"))
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,11 @@ namespace SM.OGL.Framebuffer
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool AutoCompile { get; set; } = true;
|
protected override bool AutoCompile { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The window for the screen
|
||||||
|
/// </summary>
|
||||||
|
public static IFramebufferWindow ScreenWindow;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the screen buffer.
|
/// Represents the screen buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -24,10 +30,12 @@ namespace SM.OGL.Framebuffer
|
||||||
{
|
{
|
||||||
_id = 0,
|
_id = 0,
|
||||||
CanCompile = false,
|
CanCompile = false,
|
||||||
|
_window = ScreenWindow,
|
||||||
|
_windowScale = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly IFramebufferWindow _window;
|
private IFramebufferWindow _window;
|
||||||
private readonly float _windowScale;
|
private float _windowScale;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Framebuffer;
|
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Framebuffer;
|
||||||
|
|
@ -42,11 +50,12 @@ namespace SM.OGL.Framebuffer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, ColorAttachment> ColorAttachments { get; private set; } =
|
public Dictionary<string, ColorAttachment> ColorAttachments { get; private set; } =
|
||||||
new Dictionary<string, ColorAttachment>();
|
new Dictionary<string, ColorAttachment>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains the current renderbuffer attachments of the framebuffer.
|
/// Contains the current renderbuffer attachments of the framebuffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<RenderbufferAttachment> RenderbufferAttachments { get; } = new List<RenderbufferAttachment>();
|
public Dictionary<RenderbufferAttachment, int> RenderbufferAttachments { get; } = new Dictionary<RenderbufferAttachment, int>();
|
||||||
|
|
||||||
|
public ColorAttachment this[string colorName] => ColorAttachments[colorName];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a buffer without any options.
|
/// Creates a buffer without any options.
|
||||||
|
|
@ -79,6 +88,7 @@ namespace SM.OGL.Framebuffer
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Compile()
|
public override void Compile()
|
||||||
{
|
{
|
||||||
|
if (_id == 0) _window = ScreenWindow;
|
||||||
if (_window != null) Size = new Vector2(_window.Width * _windowScale, _window.Height * _windowScale);
|
if (_window != null) Size = new Vector2(_window.Width * _windowScale, _window.Height * _windowScale);
|
||||||
|
|
||||||
base.Compile();
|
base.Compile();
|
||||||
|
|
@ -99,10 +109,11 @@ namespace SM.OGL.Framebuffer
|
||||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, pair.Value.FramebufferAttachment, pair.Value.Target, pair.Value.ID,
|
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, pair.Value.FramebufferAttachment, pair.Value.Target, pair.Value.ID,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
foreach (RenderbufferAttachment attachment in RenderbufferAttachments)
|
foreach (RenderbufferAttachment attachment in RenderbufferAttachments.Keys.ToArray())
|
||||||
{
|
{
|
||||||
int att = attachment.Generate(this);
|
int att = attachment.Generate(this);
|
||||||
GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, attachment.FramebufferAttachment, RenderbufferTarget.Renderbuffer, att);
|
GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, attachment.FramebufferAttachment, RenderbufferTarget.Renderbuffer, att);
|
||||||
|
RenderbufferAttachments[attachment] = att;
|
||||||
}
|
}
|
||||||
|
|
||||||
var err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
|
var err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
|
||||||
|
|
@ -118,6 +129,11 @@ namespace SM.OGL.Framebuffer
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var attachment in ColorAttachments.Values) attachment.Dispose();
|
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);
|
GL.DeleteFramebuffer(this);
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
|
||||||
|
|
@ -141,7 +157,7 @@ namespace SM.OGL.Framebuffer
|
||||||
/// <param name="attachment"></param>
|
/// <param name="attachment"></param>
|
||||||
public void AppendRenderbuffer(RenderbufferAttachment attachment)
|
public void AppendRenderbuffer(RenderbufferAttachment attachment)
|
||||||
{
|
{
|
||||||
RenderbufferAttachments.Add(attachment);
|
RenderbufferAttachments.Add(attachment, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,29 @@ namespace SM.OGL.Mesh
|
||||||
GL.BindVertexArray(0);
|
GL.BindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This updates the parts of the mesh, that needs updating.
|
||||||
|
/// </summary>
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (!WasCompiled)
|
||||||
|
{
|
||||||
|
Compile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL.BindVertexArray(_id);
|
||||||
|
|
||||||
|
UpdateBoundingBox();
|
||||||
|
|
||||||
|
foreach(var attrib in Attributes)
|
||||||
|
{
|
||||||
|
if (attrib.ConnectedVBO == null || !attrib.ConnectedVBO.Active || !attrib.ConnectedVBO.CanBeUpdated) continue;
|
||||||
|
attrib.ConnectedVBO.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#region usings
|
#region usings
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
@ -14,6 +15,11 @@ namespace SM.OGL.Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class VBO : List<float>
|
public class VBO : List<float>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The ID for the buffer.
|
||||||
|
/// </summary>
|
||||||
|
public int BufferID { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the expected usage pattern of the data store.
|
/// Specifies the expected usage pattern of the data store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -51,6 +57,11 @@ namespace SM.OGL.Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public VertexAttribPointerType PointerType;
|
public VertexAttribPointerType PointerType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true it can be updated, otherwise it will get ignored, when the mesh gets updated.
|
||||||
|
/// </summary>
|
||||||
|
public bool CanBeUpdated = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a VBO for inserting mesh data.
|
/// Generates a VBO for inserting mesh data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -91,12 +102,18 @@ namespace SM.OGL.Mesh
|
||||||
Normalised = normalised;
|
Normalised = normalised;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Add(float x)
|
||||||
|
{
|
||||||
|
CanBeUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds two values to the VBO.
|
/// Adds two values to the VBO.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Add(float x, float y)
|
public void Add(float x, float y)
|
||||||
{
|
{
|
||||||
AddRange(new[] {x, y});
|
AddRange(new[] {x, y});
|
||||||
|
CanBeUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -105,6 +122,7 @@ namespace SM.OGL.Mesh
|
||||||
public void Add(float x, float y, float z)
|
public void Add(float x, float y, float z)
|
||||||
{
|
{
|
||||||
AddRange(new[] {x, y, z});
|
AddRange(new[] {x, y, z});
|
||||||
|
CanBeUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -113,6 +131,7 @@ namespace SM.OGL.Mesh
|
||||||
public void Add(float x, float y, float z, float w)
|
public void Add(float x, float y, float z, float w)
|
||||||
{
|
{
|
||||||
AddRange(new[] {x, y, z, w});
|
AddRange(new[] {x, y, z, w});
|
||||||
|
CanBeUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -205,13 +224,23 @@ namespace SM.OGL.Mesh
|
||||||
|
|
||||||
var data = ToArray();
|
var data = ToArray();
|
||||||
|
|
||||||
var buffer = GL.GenBuffer();
|
BufferID = GL.GenBuffer();
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
|
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferID);
|
||||||
GL.BufferData(BufferTarget.ArrayBuffer, data.Length * sizeof(float), data, BufferUsageHint);
|
GL.BufferData(BufferTarget.ArrayBuffer, data.Length * sizeof(float), data, BufferUsageHint);
|
||||||
|
|
||||||
GL.VertexAttribPointer(attribID, PointerSize, PointerType, Normalised, PointerStride, PointerOffset);
|
GL.VertexAttribPointer(attribID, PointerSize, PointerType, Normalised, PointerStride, PointerOffset);
|
||||||
GL.EnableVertexAttribArray(attribID);
|
GL.EnableVertexAttribArray(attribID);
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||||
|
|
||||||
|
CanBeUpdated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Update()
|
||||||
|
{
|
||||||
|
var data = ToArray();
|
||||||
|
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferID);
|
||||||
|
GL.BufferSubData(BufferTarget.ArrayBuffer, IntPtr.Zero, data.Length * sizeof(float), data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,6 +53,14 @@
|
||||||
<Compile Include="Types\Transformation.cs" />
|
<Compile Include="Types\Transformation.cs" />
|
||||||
<Compile Include="Window\Window2DSetup.cs" />
|
<Compile Include="Window\Window2DSetup.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenTK">
|
||||||
|
<Version>3.3.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Shader\ShaderFiles\basic.glsl" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SM.Base\SM.Base.csproj">
|
<ProjectReference Include="..\SM.Base\SM.Base.csproj">
|
||||||
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
||||||
|
|
@ -63,14 +71,5 @@
|
||||||
<Name>SM.OGL</Name>
|
<Name>SM.OGL</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="OpenTK">
|
|
||||||
<Version>3.3.1</Version>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Shader\ShaderFiles\basic.glsl" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup />
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -4,9 +4,12 @@ using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using SM.Base;
|
using SM.Base;
|
||||||
|
using SM.Base.Time;
|
||||||
using SM.Base.Window;
|
using SM.Base.Window;
|
||||||
using SM2D;
|
using SM2D;
|
||||||
|
using SM2D.Controls;
|
||||||
using SM2D.Drawing;
|
using SM2D.Drawing;
|
||||||
|
using SM2D.Object;
|
||||||
using SM2D.Pipelines;
|
using SM2D.Pipelines;
|
||||||
using SM2D.Scene;
|
using SM2D.Scene;
|
||||||
using Font = SM.Base.Drawing.Text.Font;
|
using Font = SM.Base.Drawing.Text.Font;
|
||||||
|
|
@ -19,27 +22,42 @@ namespace SM_TEST
|
||||||
static Scene scene;
|
static Scene scene;
|
||||||
private static Font font;
|
private static Font font;
|
||||||
private static GLWindow window;
|
private static GLWindow window;
|
||||||
|
private static PolyLine line;
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
window = new GLWindow();
|
window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off);
|
||||||
window.ApplySetup(new Window2DSetup());
|
window.ApplySetup(new Window2DSetup());
|
||||||
|
window.SetRenderPipeline(new TestRenderPipeline());
|
||||||
|
|
||||||
window.SetScene(scene = new Scene());
|
window.SetScene(scene = new Scene());
|
||||||
scene.Objects.Add(new DrawObject2D());
|
|
||||||
|
line = new PolyLine(new Vector2[] { Vector2.Zero, Vector2.One }, PolyLineType.Connected);
|
||||||
|
var display = new DrawObject2D()
|
||||||
|
{
|
||||||
|
Mesh = line
|
||||||
|
};
|
||||||
|
display.Transform.Size.Set(1);
|
||||||
|
scene.Objects.Add(display);
|
||||||
|
|
||||||
window.UpdateFrame += WindowOnUpdateFrame;
|
window.UpdateFrame += WindowOnUpdateFrame;
|
||||||
|
window.RenderFrame += Window_RenderFrame;
|
||||||
window.Run();
|
window.Run();
|
||||||
|
|
||||||
Debug.WriteLine("Window Closed");
|
Debug.WriteLine("Window Closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Window_RenderFrame(object sender, FrameEventArgs e)
|
||||||
|
{
|
||||||
|
window.Title = Math.Floor(e.Time * 1000) + "ms";
|
||||||
|
}
|
||||||
|
|
||||||
private static void WindowOnUpdateFrame(object sender, FrameEventArgs e)
|
private static void WindowOnUpdateFrame(object sender, FrameEventArgs e)
|
||||||
{
|
{
|
||||||
if (SM.Base.Controls.Keyboard.IsDown(Key.F, true))
|
|
||||||
{
|
line.Vertex.RemoveRange(3, 3);
|
||||||
window.WindowFlags = WindowFlags.ExclusiveFullscreen;
|
line.Vertex.Add(Mouse2D.InWorld(window.ViewportCamera as Camera), 0);
|
||||||
window.ChangeFullscreenResolution(DisplayDevice.Default.SelectResolution(1280,720, DisplayDevice.Default.BitsPerPixel, DisplayDevice.Default.RefreshRate));
|
line.Update();
|
||||||
}
|
|
||||||
if (SM.Base.Controls.Keyboard.IsDown(Key.W, true)) window.WindowFlags = WindowFlags.Window;
|
|
||||||
if (SM.Base.Controls.Keyboard.IsDown(Key.B, true)) window.WindowFlags = WindowFlags.BorderlessWindow;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}</ProjectGuid>
|
<ProjectGuid>{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>SM_TEST</RootNamespace>
|
<RootNamespace>SM_TEST</RootNamespace>
|
||||||
<AssemblyName>SM_TEST</AssemblyName>
|
<AssemblyName>SM_TEST</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
|
@ -32,6 +32,9 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
<HintPath>..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using SM.Base.PostEffects;
|
using SM.Base.PostEffects;
|
||||||
using SM.Base.Window;
|
using SM.Base.Window;
|
||||||
using SM.OGL.Framebuffer;
|
using SM.OGL.Framebuffer;
|
||||||
|
using SM.OGL.Texture;
|
||||||
|
|
||||||
namespace SM_TEST
|
namespace SM_TEST
|
||||||
{
|
{
|
||||||
|
|
@ -13,11 +14,11 @@ namespace SM_TEST
|
||||||
public override void Initialization()
|
public override void Initialization()
|
||||||
{
|
{
|
||||||
|
|
||||||
MainFramebuffer = CreateWindowFramebuffer(0);
|
MainFramebuffer = CreateWindowFramebuffer(16, PixelInformation.RGBA_HDR);
|
||||||
|
|
||||||
_postBuffer = CreateWindowFramebuffer();
|
_postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGBA_HDR, depth: false);
|
||||||
Framebuffers.Add(_postBuffer);
|
Framebuffers.Add(_postBuffer);
|
||||||
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .75f)
|
_bloom = new BloomEffect(_postBuffer, hdr: true, .5f)
|
||||||
{
|
{
|
||||||
Threshold = .5f,
|
Threshold = .5f,
|
||||||
};
|
};
|
||||||
|
|
@ -34,8 +35,12 @@ namespace SM_TEST
|
||||||
context.Scene.DrawMainObjects(context);
|
context.Scene.DrawMainObjects(context);
|
||||||
context.Scene.DrawHUD(context);
|
context.Scene.DrawHUD(context);
|
||||||
|
|
||||||
|
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
|
||||||
|
|
||||||
|
//_bloom.Draw(context);
|
||||||
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||||
_bloom.Draw(context);
|
|
||||||
|
PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f);
|
||||||
|
|
||||||
context.Scene.DrawDebug(context);
|
context.Scene.DrawDebug(context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue