2021-15-03

+ GenericTransformation.InWorldSpace (Merges the object transformation and the last master transformation)
+ Ray class for Raycasting (may not work correctly)
+ Util.CallGarbageCollector() can call the garbage collector.
+ GLWindow.WindowFlags allow to easly switch between Window <-> Borderless Window (this will cause the window to fill the entire screen) <-> Exclusive Fullscreen.

~ Made the bloom-texture scale a constructor-parameter.

SM.OGL:
+ OpenGL-GarbageCollector integration.
+ BoundingBox.GetBounds(Matrix4, out Vector3,out Vector3) allows for easy transformation of the bounding box.
+ GLObjects can now marked as not compiled. Where it always returns false at WasCompiled.

SM2D:
~ Improved the Mouse2D.MouseOver Algorithm.
This commit is contained in:
Michel Fedde 2021-03-15 18:11:58 +01:00
parent 4efc47d75a
commit 5bb690e45f
18 changed files with 224 additions and 20 deletions

View file

@ -116,9 +116,11 @@ namespace SM.OGL.Framebuffer
/// <inheritdoc />
public override void Dispose()
{
base.Dispose();
foreach (var attachment in ColorAttachments.Values) attachment.Dispose();
GL.DeleteFramebuffer(this);
base.Dispose();
}
/// <summary>
@ -180,6 +182,7 @@ namespace SM.OGL.Framebuffer
Framebuffer buffer = new Framebuffer()
{
_canBeCompiled = false,
ReportAsNotCompiled = true
};
switch (target)
{

View file

@ -1,6 +1,9 @@
#region usings
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using OpenTK.Graphics.OpenGL4;
#endregion
@ -12,11 +15,15 @@ namespace SM.OGL
/// </summary>
public abstract class GLObject
{
private static List<GLObject> _disposableObjects = new List<GLObject>();
protected bool ReportAsNotCompiled;
/// <summary>
/// Contains the OpenGL ID
/// </summary>
protected int _id = -1;
/// <summary>
/// If true, the system will call "Compile()", when "ID" is tried to get, but the id is still -1.
/// </summary>
@ -25,7 +32,7 @@ namespace SM.OGL
/// <summary>
/// Checks if the object was compiled.
/// </summary>
public bool WasCompiled => _id > 0;
public bool WasCompiled => _id > 0 && !ReportAsNotCompiled;
/// <summary>
/// Returns the id for this object.
@ -64,7 +71,7 @@ namespace SM.OGL
/// </summary>
public virtual void Dispose()
{
_id = -1;
}
/// <summary>
@ -87,6 +94,15 @@ namespace SM.OGL
if (GLSystem.Debugging) GL.ObjectLabel(TypeIdentifier, _id, name.Length, name);
}
public static void DisposeMarkedObjects()
{
foreach (GLObject o in _disposableObjects)
{
o.Dispose();
}
_disposableObjects.Clear();
}
/// <summary>
/// Returns the ID for the object.
/// </summary>
@ -95,5 +111,10 @@ namespace SM.OGL
{
return glo.ID;
}
~GLObject()
{
if (WasCompiled) _disposableObjects.Add(this);
}
}
}

View file

@ -65,6 +65,21 @@ namespace SM.OGL.Mesh
public Vector3 Get(Matrix4 transformation, bool xyz) => Get(transformation, xyz, xyz, xyz);
public void GetBounds(Matrix4 transformation, out Vector3 min, out Vector3 max)
{
min = Get(transformation, false);
max = Get(transformation, true);
for (int i = 0; i < 3; i++)
{
float newmin = Math.Min(min[i], max[i]);
float newmax = Math.Max(min[i], max[i]);
min[i] = newmin;
max[i] = newmax;
}
}
public void Update(GenericMesh mesh)
{
int pos = 0;

View file

@ -99,5 +99,11 @@ namespace SM.OGL.Mesh
GL.BindVertexArray(0);
}
public override void Dispose()
{
GL.DeleteVertexArray(_id);
base.Dispose();
}
}
}

View file

@ -119,7 +119,8 @@ namespace SM.OGL.Shaders
public override void Dispose()
{
GL.DeleteShader(this);
GL.DeleteProgram(this);
base.Dispose();
}
/// <summary>

View file

@ -79,5 +79,12 @@ namespace SM.OGL.Shaders
for (var i = 0; i < GLSLExtensions.Count; i++) GLSLExtensions[i].Compile(shader, type);
}
public override void Dispose()
{
GL.DeleteShader(this);
base.Dispose();
}
}
}

View file

@ -46,8 +46,8 @@ namespace SM.OGL.Texture
public override void Dispose()
{
base.Dispose();
GL.DeleteTexture(_id);
base.Dispose();
}
}
}