diff --git a/SMCode/SM.Base/Log.cs b/SMCode/SM.Base/Log.cs
index ac21108..8477937 100644
--- a/SMCode/SM.Base/Log.cs
+++ b/SMCode/SM.Base/Log.cs
@@ -82,14 +82,14 @@ namespace SM.Base
///
/// Presets for the log targets.
///
- public static Dictionary Preset = new Dictionary
+ public static Dictionary Preset = new()
{
{LogTarget.Console, "[%type%] %msg%"},
{LogTarget.Debugger, "[%type%] %msg%"},
{LogTarget.File, "<%date%, %time%> [%type%] %msg%"}
};
- private static readonly Dictionary Colors = new Dictionary
+ private static readonly Dictionary Colors = new()
{
{LogType.Info, ConsoleColor.Green},
{LogType.Warning, ConsoleColor.Yellow},
diff --git a/SMCode/SM.Base/Window/RenderPipeline.cs b/SMCode/SM.Base/Window/RenderPipeline.cs
index a02ab36..b9f89dd 100644
--- a/SMCode/SM.Base/Window/RenderPipeline.cs
+++ b/SMCode/SM.Base/Window/RenderPipeline.cs
@@ -113,11 +113,9 @@ namespace SM.Base.Window
///
/// This creates a finished setup for a framebuffer.
///
- ///
- ///
public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true)
{
- Framebuffer framebuffer = new Framebuffer(ConnectedWindow);
+ Framebuffer framebuffer = new(ConnectedWindow);
framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples));
if (depth)
diff --git a/SMCode/SM.OGL/Framebuffer/Framebuffer.cs b/SMCode/SM.OGL/Framebuffer/Framebuffer.cs
index 8ffc5f1..32cd1b0 100644
--- a/SMCode/SM.OGL/Framebuffer/Framebuffer.cs
+++ b/SMCode/SM.OGL/Framebuffer/Framebuffer.cs
@@ -26,7 +26,7 @@ namespace SM.OGL.Framebuffer
///
/// Represents the screen buffer.
///
- public static readonly Framebuffer Screen = new Framebuffer
+ public static readonly Framebuffer Screen = new()
{
_id = 0,
CanCompile = false,
@@ -55,6 +55,11 @@ namespace SM.OGL.Framebuffer
///
public Dictionary RenderbufferAttachments { get; } = new Dictionary();
+ ///
+ /// Gets the color attachment with the specified color name.
+ ///
+ ///
+ ///
public ColorAttachment this[string colorName] => ColorAttachments[colorName];
///
@@ -204,7 +209,7 @@ namespace SM.OGL.Framebuffer
///
public static Framebuffer GetCurrentlyActive(FramebufferTarget target = FramebufferTarget.Framebuffer)
{
- Framebuffer buffer = new Framebuffer()
+ Framebuffer buffer = new()
{
CanCompile = false,
ReportAsNotCompiled = true
diff --git a/SMCode/SM.OGL/GLObject.cs b/SMCode/SM.OGL/GLObject.cs
index 5458abe..89b0fbe 100644
--- a/SMCode/SM.OGL/GLObject.cs
+++ b/SMCode/SM.OGL/GLObject.cs
@@ -14,7 +14,7 @@ namespace SM.OGL
///
public abstract class GLObject
{
- private static readonly List _disposableObjects = new List();
+ private static readonly List _disposableObjects = new();
private string _name = "";
diff --git a/SMCode/SM.OGL/Mesh/VBO.cs b/SMCode/SM.OGL/Mesh/VBO.cs
index 6dd9e66..b82d36a 100644
--- a/SMCode/SM.OGL/Mesh/VBO.cs
+++ b/SMCode/SM.OGL/Mesh/VBO.cs
@@ -10,26 +10,76 @@ using System.Threading.Tasks;
namespace SM.OGL.Mesh
{
+ ///
+ /// Represents a vertex buffer object in C#.
+ ///
public abstract class VBO : GLObject
{
private float[] _floatArray;
+ ///
protected override bool AutoCompile { get => false; set { return; } }
+ ///
public override ObjectLabelIdentifier TypeIdentifier => ObjectLabelIdentifier.Buffer;
+ ///
+ /// If false, it will not compile the vertex buffer.
+ /// Default: true
+ ///
public bool Active { get; set; } = true;
+ ///
+ /// This determents if the object can be updated.
+ ///
public bool CanBeUpdated { get; set; } = true;
+ ///
+ /// Specifies whether fixed-point data values should be normalized (true) or converted directly as fixed-point values (false) when they are accessed.
+ ///
public bool Normalized { get; protected set; }
+ ///
+ /// Specifies a offset of the first component of the first generic vertex attribute in the array in the data store of the buffer currently bound to the GL_ARRAY_BUFFER target. The initial value is 0.
+ ///
public int PointerOffset { get; protected set; }
+ ///
+ /// Specifies the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in the array. The initial value is 0.
+ ///
public int PointerStride { get; protected set; }
+ ///
+ /// Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4. Additionally, the symbolic constant GL_BGRA is accepted by glVertexAttribPointer.
+ /// This value gets usually set by the data type.
+ ///
public int PointerSize { get; protected set; }
+ ///
+ /// Specifies the expected usage pattern of the data store.
+ ///
public BufferUsageHint UsageHint { get; protected set; }
+ ///
+ /// Specifies the data type of each component in the array.
+ /// This value gets usually set by the data type of the class.
+ ///
public VertexAttribPointerType PointerType { get; protected set; }
+ ///
+ /// The shader id for the mesh.
+ ///
public int AttributeID { get; internal set; }
+ ///
+ /// The amount of data.
+ ///
public abstract int Count { get; }
+ ///
+ /// The amount of data, when the mesh was compiled.
+ ///
+ public int CompiledCount { get; private set; }
+
+ ///
+ /// Creates a vertex buffer object.
+ ///
+ /// Specifies the expected usage pattern of the data store.
+ /// Specifies the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in the array. The initial value is 0.
+ /// Specifies a offset of the first component of the first generic vertex attribute in the array in the data store of the buffer currently bound to the GL_ARRAY_BUFFER target. The initial value is 0.
+ /// Specifies whether fixed-point data values should be normalized (true) or converted directly as fixed-point values (false) when they are accessed.
public VBO(BufferUsageHint bufferUsageHint = BufferUsageHint.StaticDraw,
int pointerStride = 0, int pointerOffset = 0, bool normalised = false)
@@ -40,6 +90,7 @@ namespace SM.OGL.Mesh
Normalized = normalised;
}
+ ///
public override void Compile()
{
base.Compile();
@@ -47,6 +98,7 @@ namespace SM.OGL.Mesh
if (!Active) return;
float[] data = ToFloat();
+ CompiledCount = data.Length;
_id = GL.GenBuffer();
GL.BindBuffer(BufferTarget.ArrayBuffer, _id);
@@ -58,9 +110,14 @@ namespace SM.OGL.Mesh
CanBeUpdated = false;
}
+ ///
+ /// Updates the buffer object.
+ ///
public void Update()
{
float[] data = GetFloats();
+ if (data.Length > CompiledCount)
+ throw new NotSupportedException("Updating the amount of data is not yet supported.");
GL.BindBuffer(BufferTarget.ArrayBuffer, _id);
GL.BufferSubData(BufferTarget.ArrayBuffer, IntPtr.Zero, data.Length * sizeof(float), data);
@@ -68,12 +125,17 @@ namespace SM.OGL.Mesh
CanBeUpdated = false;
}
+ ///
public override void Dispose()
{
GL.DeleteBuffer(_id);
base.Dispose();
}
+ ///
+ /// Gets the data stored, in a float array.
+ ///
+ ///
public float[] GetFloats()
{
if (_floatArray == null || CanBeUpdated)
@@ -84,13 +146,18 @@ namespace SM.OGL.Mesh
return _floatArray;
}
+ ///
+ /// Calculates the data stored in a float array.
+ ///
+ ///
protected abstract float[] ToFloat();
}
+ ///
public class VBO : VBO, IEnumerable
where TType : struct
{
- static Dictionary> _pointerSizes = new Dictionary>()
+ static readonly Dictionary> _pointerSizes = new()
{
{ typeof(float), new Tuple(1, VertexAttribPointerType.Float) },
{ typeof(Vector2), new Tuple(2, VertexAttribPointerType.Float) },
@@ -98,10 +165,21 @@ namespace SM.OGL.Mesh
{ typeof(Vector4), new Tuple(4, VertexAttribPointerType.Float) },
{ typeof(Color4), new Tuple(4, VertexAttribPointerType.Float) },
};
- private List _values = new List();
+ private readonly List _values = new();
+ ///
public override int Count => _values.Count;
+ ///
+ /// Exposes the indexer of the list to the public.
+ ///
+ public TType this[int index]
+ {
+ get => _values[index];
+ set { _values[index] = value; CanBeUpdated = true; }
+ }
+
+ ///
public VBO(BufferUsageHint bufferUsageHint = BufferUsageHint.StaticDraw,
int pointerStride = 0, int pointerOffset = 0, bool normalised = false) : base(bufferUsageHint, pointerStride, pointerOffset, normalised)
{
@@ -112,26 +190,36 @@ namespace SM.OGL.Mesh
PointerType = _pointerSizes[typeof(TType)].Item2;
}
+ ///
+ /// Adds a new value to the list.
+ ///
+ ///
public void Add(TType value)
{
_values.Add(value);
CanBeUpdated = true;
}
+ ///
+ /// Removes the object at that position.
+ ///
+ ///
public void RemoveAt(int pos)
{
_values.RemoveAt(pos);
CanBeUpdated = true;
}
+ ///
public IEnumerator GetEnumerator()
{
return _values.GetEnumerator();
}
+ ///
protected override float[] ToFloat()
{
- List floats = new List();
+ List floats = new();
foreach (TType value in _values)
{
diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs
index a4dd181..24c5c53 100644
--- a/SM_TEST/Program.cs
+++ b/SM_TEST/Program.cs
@@ -20,7 +20,6 @@ namespace SM_TEST
class Program
{
static Scene scene;
- private static Font font;
private static GLWindow window;
private static PolyLine line;
static void Main(string[] args)
@@ -56,14 +55,10 @@ namespace SM_TEST
if (SM.Base.Controls.Mouse.LeftClick)
line.Vertex.Add(Vector3.Zero);
- line.Vertex.RemoveAt(1);
- line.Vertex.Add(new Vector3(Mouse2D.InWorld(window.ViewportCamera as Camera)));
+ line.Vertex[1] = new Vector3(Mouse2D.InWorld(window.ViewportCamera as Camera));
line.Update();
}
-
- private static void WindowOnLoad(IGenericWindow window)
- { }
}
}
\ No newline at end of file
diff --git a/SM_TEST/TestRenderPipeline.cs b/SM_TEST/TestRenderPipeline.cs
index 7191e71..5c4edfb 100644
--- a/SM_TEST/TestRenderPipeline.cs
+++ b/SM_TEST/TestRenderPipeline.cs
@@ -37,7 +37,7 @@ namespace SM_TEST
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
- //_bloom.Draw(context);
+ // _bloom.Draw(context);
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f);