diff --git a/SMCode/SM.Base/Controls/Keyboard.cs b/SMCode/SM.Base/Controls/Keyboard.cs
index 77ba027..c002692 100644
--- a/SMCode/SM.Base/Controls/Keyboard.cs
+++ b/SMCode/SM.Base/Controls/Keyboard.cs
@@ -1,18 +1,24 @@
-using System;
+#region usings
+
+using System;
using System.Collections.Generic;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Windows.Documents;
-using System.Windows.Forms;
using OpenTK.Input;
-using SharpDX.Win32;
+
+#endregion
namespace SM.Base.Controls
{
- public class Keyboard
+ ///
+ /// A static class to get keyboard inputs.
+ ///
+ public static class Keyboard
{
internal static KeyboardState? _keyboardState;
internal static List _lastPressedKeys = new List();
+ ///
+ /// True, when ANY key pressed.
+ ///
public static bool IsAnyKeyPressed => _keyboardState?.IsAnyKeyDown == true;
@@ -23,18 +29,53 @@ namespace SM.Base.Controls
_lastPressedKeys = new List();
foreach (object o in Enum.GetValues(typeof(Key)))
- {
- if (_keyboardState.Value[(Key)o]) _lastPressedKeys.Add((Key)o);
- }
+ if (_keyboardState.Value[(Key) o])
+ _lastPressedKeys.Add((Key) o);
}
_keyboardState = OpenTK.Input.Keyboard.GetState();
}
- public static bool IsDown(Key key, bool once = false) => _keyboardState?[key] == true && !(once && _lastPressedKeys.Contains(key));
- public static bool WasDown(Key key) => _keyboardState?[key] == false && _lastPressedKeys.Contains(key);
- public static bool IsUp(Key key, bool once = false) => _keyboardState?[key] == false && !(once && !_lastPressedKeys.Contains(key));
+ ///
+ /// Checks if a key is down.
+ ///
+ /// The key
+ /// If true, the method doesn't return true, when it was pressed one stage before.
+ ///
+ public static bool IsDown(Key key, bool once = false)
+ {
+ return _keyboardState?[key] == true && !(once && _lastPressedKeys.Contains(key));
+ }
+ ///
+ /// Checks if a key was down but not anymore.
+ ///
+ ///
+ ///
+ public static bool WasDown(Key key)
+ {
+ return _keyboardState?[key] == false && _lastPressedKeys.Contains(key);
+ }
+
+ ///
+ /// Check if a is up.
+ ///
+ ///
+ /// If true, the method doesn't return true, when it was up one stage before.
+ ///
+ public static bool IsUp(Key key, bool once = false)
+ {
+ return _keyboardState?[key] == false && !(once && !_lastPressedKeys.Contains(key));
+ }
+
+ ///
+ /// Checks if specific keys are down.
+ ///
+ /// Startindex
+ /// Endindex
+ /// If true, it ignores keys that were down a state before.
+ /// True if any of the specific keys where found down.
+ /// The start index can't be greater then the end index.
public static bool AreSpecificKeysPressed(int startIndex, int endIndex, bool once = false)
{
if (startIndex > endIndex)
@@ -51,19 +92,42 @@ namespace SM.Base.Controls
return false;
}
- public static bool AreSpecificKeysPressed(params Key[] keys) => AreSpecificKeysPressed(false, keys);
+ ///
+ /// Checks if any of the specific keys are pressed.
+ ///
+ ///
+ ///
+ public static bool AreSpecificKeysPressed(params Key[] keys)
+ {
+ return AreSpecificKeysPressed(false, keys);
+ }
+ ///
+ /// Checks if any of the specific keys are pressed.
+ ///
+ /// If true, it ignores keys that were down a state before.
+ ///
+ ///
public static bool AreSpecificKeysPressed(bool once, params Key[] keys)
{
foreach (Key key in keys)
- {
- if (IsDown(key, once)) return true;
- }
+ if (IsDown(key, once))
+ return true;
return false;
}
- public static bool AreSpecificKeysPressed(int startIndex, int endIndex, out Key[] pressedKeys, bool once = false)
+ ///
+ /// Checks if specific keys are down and returns the pressed keys.
+ ///
+ /// Startindex
+ /// Endindex
+ ///
+ /// If true, it ignores keys that were down a state before.
+ ///
+ ///
+ public static bool AreSpecificKeysPressed(int startIndex, int endIndex, out Key[] pressedKeys,
+ bool once = false)
{
if (startIndex > endIndex)
throw new ArgumentException("The startIndex is greater than the endIndex.", nameof(startIndex));
@@ -75,34 +139,47 @@ namespace SM.Base.Controls
for (int i = 0; i < length; i++)
{
int actualIndex = i + startIndex;
- Key key = (Key)actualIndex;
+ Key key = (Key) actualIndex;
if (IsDown(key, once))
{
keys.Add(key);
success = true;
}
-
}
pressedKeys = keys.ToArray();
return success;
}
- public static bool AreSpecificKeysPressed(out Key[] pressedKey, params Key[] keys) => AreSpecificKeysPressed(false, out pressedKey, keys);
-
+ ///
+ /// Checks if any of the specific keys are pressed and returns them.
+ ///
+ ///
+ ///
+ ///
+ public static bool AreSpecificKeysPressed(out Key[] pressedKey, params Key[] keys)
+ {
+ return AreSpecificKeysPressed(false, out pressedKey, keys);
+ }
+
+ ///
+ /// Checks if any of the specific keys are pressed and returns them.
+ ///
+ /// If true, it ignores keys that were down a state before.
+ ///
+ ///
+ ///
public static bool AreSpecificKeysPressed(bool once, out Key[] pressedKeys, params Key[] keys)
{
List pressedKey = new List();
bool success = false;
foreach (Key key in keys)
- {
if (IsDown(key, once))
{
pressedKey.Add(key);
success = true;
}
- }
pressedKeys = pressedKey.ToArray();
return success;
diff --git a/SMCode/SM.Base/Controls/Mouse.cs b/SMCode/SM.Base/Controls/Mouse.cs
index a77dd4e..ed60f9e 100644
--- a/SMCode/SM.Base/Controls/Mouse.cs
+++ b/SMCode/SM.Base/Controls/Mouse.cs
@@ -2,10 +2,9 @@
using System;
using System.Collections.Generic;
-using System.Windows.Documents;
using OpenTK;
using OpenTK.Input;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -14,7 +13,6 @@ namespace SM.Base.Controls
///
/// Mouse controller
///
- /// The type of window this controller is connected to.
public class Mouse
{
internal static MouseState? _mouseState;
@@ -37,7 +35,7 @@ namespace SM.Base.Controls
internal static void MouseMoveEvent(MouseMoveEventArgs mmea, IGenericWindow window)
{
InScreen = new Vector2(mmea.X, mmea.Y);
- InScreenNormalized = new Vector2(mmea.X / (float)window.Width, mmea.Y / (float)window.Height);
+ InScreenNormalized = new Vector2(mmea.X / (float) window.Width, mmea.Y / (float) window.Height);
}
internal static void SetState()
@@ -47,19 +45,21 @@ namespace SM.Base.Controls
_lastButtonsPressed = new List();
foreach (object o in Enum.GetValues(typeof(MouseButton)))
- {
- if (_mouseState.Value[(MouseButton)o]) _lastButtonsPressed.Add((MouseButton)o);
- }
+ if (_mouseState.Value[(MouseButton) o])
+ _lastButtonsPressed.Add((MouseButton) o);
}
_mouseState = OpenTK.Input.Mouse.GetState();
-
}
- public static bool IsDown(MouseButton button, bool once = false) => _mouseState?[button] == true && !(once && _lastButtonsPressed.Contains(button));
-
- public static bool IsUp(MouseButton button, bool once = false) =>
- _mouseState?[button] == false && !(once && !_lastButtonsPressed.Contains(button));
+ public static bool IsDown(MouseButton button, bool once = false)
+ {
+ return _mouseState?[button] == true && !(once && _lastButtonsPressed.Contains(button));
+ }
+ public static bool IsUp(MouseButton button, bool once = false)
+ {
+ return _mouseState?[button] == false && !(once && !_lastButtonsPressed.Contains(button));
+ }
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Drawing/DrawingBasis.cs b/SMCode/SM.Base/Drawing/DrawingBasis.cs
index a0f0ced..e7716b0 100644
--- a/SMCode/SM.Base/Drawing/DrawingBasis.cs
+++ b/SMCode/SM.Base/Drawing/DrawingBasis.cs
@@ -1,12 +1,10 @@
#region usings
using System.Collections.Generic;
-using OpenTK.Graphics.ES11;
-using SM.Base;
+using OpenTK.Graphics.OpenGL4;
using SM.Base.Scene;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM.OGL.Mesh;
-using PrimitiveType = OpenTK.Graphics.OpenGL4.PrimitiveType;
#endregion
@@ -22,15 +20,27 @@ namespace SM.Base.Drawing
///
public Material Material = new Material();
+ ///
+ /// Transformation for the textures.
+ ///
+ public TextureTransformation TextureTransform = new TextureTransformation();
+
+ ///
+ /// This allows custom shaders to add own arguments.
+ ///
+ public ShaderArguments ShaderArguments => Material.ShaderArguments;
+
+ ///
+ /// This can force a shader to render the object with the specified mesh type.
+ ///
+ public PrimitiveType? ForcedMeshType { get; set; }
+
///
/// The mesh it should use.
///
public GenericMesh Mesh { get; set; } = SMRenderer.DefaultMesh;
- public ShaderArguments ShaderArguments => Material.ShaderArguments;
- public TextureTransformation TextureTransform = new TextureTransformation();
-
///
public object Parent { get; set; }
@@ -40,12 +50,11 @@ namespace SM.Base.Drawing
///
public ICollection Flags { get; set; }
- public PrimitiveType? ForcedMeshType { get; set; }
-
///
/// This value determents if the object should draw something.
///
public bool Active { get; set; } = true;
+
public bool RenderActive { get; set; } = true;
///
diff --git a/SMCode/SM.Base/Drawing/GenericTransformation.cs b/SMCode/SM.Base/Drawing/GenericTransformation.cs
index 13a047b..64d4e3b 100644
--- a/SMCode/SM.Base/Drawing/GenericTransformation.cs
+++ b/SMCode/SM.Base/Drawing/GenericTransformation.cs
@@ -12,12 +12,18 @@ namespace SM.Base.Drawing
public abstract class GenericTransformation
{
///
- /// If true, ignores the transformation and sends , when requested.
+ /// If true, ignores the transformation and sends , when requested.
///
public bool Ignore = false;
+ ///
+ /// The last matrix that was used to calculate the real world matrix.
+ ///
public Matrix4 LastMaster { get; internal set; }
+ ///
+ /// The transformation in world space.
+ ///
public Matrix4 InWorldSpace => MergeMatrix(LastMaster);
///
diff --git a/SMCode/SM.Base/Drawing/Instance.cs b/SMCode/SM.Base/Drawing/Instance.cs
index 7ef88c8..732efb1 100644
--- a/SMCode/SM.Base/Drawing/Instance.cs
+++ b/SMCode/SM.Base/Drawing/Instance.cs
@@ -16,6 +16,9 @@ namespace SM.Base.Drawing
///
public Matrix4 ModelMatrix = Matrix4.Identity;
+ ///
+ /// The Texture matrix
+ ///
public Matrix3 TextureMatrix = Matrix3.Identity;
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Drawing/Material.cs b/SMCode/SM.Base/Drawing/Material.cs
index 6a4b0a2..8b1d993 100644
--- a/SMCode/SM.Base/Drawing/Material.cs
+++ b/SMCode/SM.Base/Drawing/Material.cs
@@ -1,7 +1,7 @@
#region usings
-using System.Collections.Generic;
using OpenTK.Graphics;
+using SM.Base.Shaders;
using SM.OGL.Texture;
#endregion
@@ -13,6 +13,8 @@ namespace SM.Base.Drawing
///
public class Material
{
+ public bool Blending = false;
+
///
/// A custom shader, that is used to draw this material.
///
@@ -28,8 +30,9 @@ namespace SM.Base.Drawing
///
public Color4 Tint = Color4.White;
+ ///
+ /// This allows custom shaders to use own shader arguments.
+ ///
public ShaderArguments ShaderArguments { get; internal set; } = new ShaderArguments();
-
- public bool Blending = false;
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs b/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs
index 79ca40e..67f6e47 100644
--- a/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs
+++ b/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs
@@ -1,4 +1,8 @@
-using SM.Base.Time;
+#region usings
+
+using SM.Base.Time;
+
+#endregion
namespace SM.Base.Drawing.Particles
{
@@ -8,11 +12,12 @@ namespace SM.Base.Drawing.Particles
public struct ParticleContext
{
///
- /// The Timer of the particles
+ /// The Timer of the particles
///
public Timer Timer;
+
///
- /// The current speed of the particles.
+ /// The current speed of the particles.
///
public float Speed;
}
diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
index 31da040..29219f4 100644
--- a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
+++ b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
@@ -1,31 +1,42 @@
-using System;
+#region usings
+
+using System;
using System.Collections.Generic;
using OpenTK;
-using SM.Base;
using SM.Base.Scene;
using SM.Base.Time;
-using SM.Base.Types;
-using SM.Base.Windows;
-using SM.OGL.Shaders;
+using SM.Base.Window;
+
+#endregion
namespace SM.Base.Drawing.Particles
{
///
- /// The (drawing) basis for particles
+ /// The (drawing) basis for particles
///
public abstract class ParticleDrawingBasis : DrawingBasis, IScriptable
where TTransform : GenericTransformation, new()
where TDirection : struct
{
+ ///
+ /// The amount of particles
+ ///
+ public int Amount = 32;
+
+ ///
+ /// This contains the different instances for the particles.
+ ///
+ protected List instances;
+
+ ///
+ /// The maximum speed of the particles
+ ///
+ public float MaxSpeed = 1;
///
/// This contains all important information for each particle.
///
protected ParticleStruct[] particleStructs;
- ///
- /// This contains the different instances for the particles.
- ///
- protected List instances;
///
/// The stopwatch of the particles.
@@ -33,13 +44,13 @@ namespace SM.Base.Drawing.Particles
protected Timer timer;
///
- /// The amount of particles
+ /// Sets up the timer.
///
- public int Amount = 32;
- ///
- /// The maximum speed of the particles
- ///
- public float MaxSpeed = 1;
+ /// Duration how long the particles should live
+ protected ParticleDrawingBasis(TimeSpan duration)
+ {
+ timer = new Timer(duration);
+ }
///
/// Get/Sets the state of pausing.
@@ -55,13 +66,25 @@ namespace SM.Base.Drawing.Particles
///
public abstract Func MovementCalculation { get; set; }
- ///
- /// Sets up the timer.
- ///
- /// Duration how long the particles should live
- protected ParticleDrawingBasis(TimeSpan duration)
+ ///
+ public bool UpdateActive { get; set; }
+
+ ///
+ public void Update(UpdateContext context)
{
- timer = new Timer(duration);
+ if (!timer.Running) return;
+
+ ParticleContext particleContext = new ParticleContext
+ {
+ Timer = timer
+ };
+
+ for (int i = 0; i < Amount; i++)
+ {
+ particleContext.Speed = particleStructs[i].Speed;
+ instances[i].ModelMatrix = CreateMatrix(particleStructs[i],
+ MovementCalculation(particleStructs[i].Direction, particleContext));
+ }
}
///
@@ -74,30 +97,11 @@ namespace SM.Base.Drawing.Particles
CreateParticles();
}
- public bool UpdateActive { get; set; }
-
- ///
- public void Update(UpdateContext context)
- {
- if (!timer.Running) return;
-
- ParticleContext particleContext = new ParticleContext()
- {
- Timer = timer,
- };
-
- for (int i = 0; i < Amount; i++)
- {
- particleContext.Speed = particleStructs[i].Speed;
- instances[i].ModelMatrix = CreateMatrix(particleStructs[i], MovementCalculation(particleStructs[i].Direction, particleContext));
- }
- }
-
///
protected override void DrawContext(ref DrawContext context)
{
if (!timer.Active) return;
-
+
base.DrawContext(ref context);
context.Instances = instances;
@@ -124,7 +128,7 @@ namespace SM.Base.Drawing.Particles
/// Creates a particle.
///
protected abstract ParticleStruct CreateObject(int index);
-
+
///
/// Generates the desired matrix for drawing.
///
diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs b/SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs
index a989898..6fdad6a 100644
--- a/SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs
+++ b/SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs
@@ -1,4 +1,8 @@
-using OpenTK;
+#region usings
+
+using OpenTK;
+
+#endregion
namespace SM.Base.Drawing.Particles
{
@@ -10,10 +14,17 @@ namespace SM.Base.Drawing.Particles
///
/// Default movement for 2D.
///
- public static Vector2 Default2D(Vector2 direction, ParticleContext context) => direction * (context.Timer.Elapsed * context.Speed);
+ public static Vector2 Default2D(Vector2 direction, ParticleContext context)
+ {
+ return direction * (context.Timer.Elapsed * context.Speed);
+ }
+
///
/// Default movement for 3D.
///
- public static Vector3 Default3D(Vector3 direction, ParticleContext context) => direction * (context.Timer.Elapsed * context.Speed);
+ public static Vector3 Default3D(Vector3 direction, ParticleContext context)
+ {
+ return direction * (context.Timer.Elapsed * context.Speed);
+ }
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs b/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs
index 52660e8..eef2b53 100644
--- a/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs
+++ b/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs
@@ -1,5 +1,8 @@
-using OpenTK;
-using SM.Base.Types;
+#region usings
+
+using OpenTK;
+
+#endregion
namespace SM.Base.Drawing.Particles
{
@@ -13,10 +16,12 @@ namespace SM.Base.Drawing.Particles
/// A direction, that the particle should travel.
///
public TDirection Direction;
+
///
/// A matrix to store rotation and scale.
///
public Matrix4 Matrix;
+
///
/// Speeeeeeeeeed
///
diff --git a/SMCode/SM.Base/Drawing/ShaderArguments.cs b/SMCode/SM.Base/Drawing/ShaderArguments.cs
index 07a5222..b339bb8 100644
--- a/SMCode/SM.Base/Drawing/ShaderArguments.cs
+++ b/SMCode/SM.Base/Drawing/ShaderArguments.cs
@@ -1,13 +1,26 @@
-using System;
+#region usings
+
using System.Collections.Generic;
+#endregion
+
namespace SM.Base.Drawing
{
+ ///
+ /// A custom dictionary, with a few useful methods.
+ ///
public class ShaderArguments : Dictionary
{
+ ///
+ /// Returns the stored value or the default value if the name doesn't exist.
+ ///
+ ///
+ ///
+ ///
+ ///
public TType Get(string name, TType defaultValue = default)
{
- return ContainsKey(name) ? (TType)this[name] : defaultValue;
+ return ContainsKey(name) ? (TType) this[name] : defaultValue;
}
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Drawing/Text/Font.cs b/SMCode/SM.Base/Drawing/Text/Font.cs
index 737036b..f763f1c 100644
--- a/SMCode/SM.Base/Drawing/Text/Font.cs
+++ b/SMCode/SM.Base/Drawing/Text/Font.cs
@@ -32,8 +32,6 @@ namespace SM.Base.Drawing.Text
///
public float FontSize = 12;
- public float Spacing = 1;
-
///
/// The font style.
/// Default:
@@ -45,6 +43,11 @@ namespace SM.Base.Drawing.Text
///
public Dictionary Positions = new Dictionary();
+ ///
+ /// Allows a font wide spacing option.
+ ///
+ public float Spacing = 1;
+
///
/// Generates a font from a font family from the specified path.
///
diff --git a/SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs b/SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs
index 1cd3c85..ab886e7 100644
--- a/SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs
+++ b/SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs
@@ -3,8 +3,7 @@
using System;
using OpenTK;
using OpenTK.Graphics;
-using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -27,33 +26,34 @@ namespace SM.Base.Drawing.Text
///
protected string _text;
+ ///
+ /// The width of the text object.
+ ///
+ public float Width;
+
+ ///
+ /// The height of the text object.
+ ///
+ public float Height;
+
///
/// The spacing between numbers.
/// Default: 1
///
public float Spacing = 1;
- public float ActualSpacing => Spacing * Font.Spacing;
-
- public float Width;
- public float Height;
///
- /// Creates a text object with a font.
+ /// Calculates the actual spacing for the object.
///
- /// The font.
- protected TextDrawingBasis(Font font)
- {
- Material.Texture = font;
- Material.Blending = true;
- }
+ public float ActualSpacing => Spacing * Font.Spacing;
///
/// The font.
///
public Font Font
{
- get => (Font) Material.Texture;
+ get => (Font)Material.Texture;
set
{
Material.Texture = value;
@@ -83,6 +83,16 @@ namespace SM.Base.Drawing.Text
set => Material.Tint = value;
}
+ ///
+ /// Creates a text object with a font.
+ ///
+ /// The font.
+ protected TextDrawingBasis(Font font)
+ {
+ Material.Texture = font;
+ Material.Blending = true;
+ }
+
///
protected override void DrawContext(ref DrawContext context)
@@ -137,7 +147,8 @@ namespace SM.Base.Drawing.Text
_instances[i] = new Instance
{
ModelMatrix = matrix,
- TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(parameter.NormalizedX, 0), new Vector2(parameter.NormalizedWidth, 1), 0),
+ TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(parameter.NormalizedX, 0),
+ new Vector2(parameter.NormalizedWidth, 1), 0)
};
x += parameter.Width * ActualSpacing;
diff --git a/SMCode/SM.Base/Drawing/TextureTransformation.cs b/SMCode/SM.Base/Drawing/TextureTransformation.cs
index 78ac108..d20d6de 100644
--- a/SMCode/SM.Base/Drawing/TextureTransformation.cs
+++ b/SMCode/SM.Base/Drawing/TextureTransformation.cs
@@ -1,20 +1,46 @@
-using System;
+#region usings
+
using OpenTK;
using SM.Base.Types;
+#endregion
+
namespace SM.Base.Drawing
{
+ ///
+ /// Stores transformations for the textures.
+ ///
public class TextureTransformation
{
+ ///
+ /// The offset from the origin.
+ ///
public CVector2 Offset = new CVector2(0);
- public CVector2 Scale = new CVector2(1);
+ ///
+ /// The rotation of the texture.
+ ///
public CVector1 Rotation = new CVector1(0);
+ ///
+ /// The scale of the texture.
+ ///
+ public CVector2 Scale = new CVector2(1);
+ ///
+ /// Get the texture matrix.
+ ///
+ ///
public Matrix3 GetMatrix()
{
return CalculateMatrix(Offset, Scale, Rotation);
}
+ ///
+ /// Calculates a texture matrix.
+ ///
+ ///
+ ///
+ ///
+ ///
public static Matrix3 CalculateMatrix(Vector2 offset, Vector2 scale, float rotation)
{
float radians = MathHelper.DegreesToRadians(rotation);
diff --git a/SMCode/SM.Base/Objects/InstancedMesh.cs b/SMCode/SM.Base/Objects/InstancedMesh.cs
index eddbbab..90147f4 100644
--- a/SMCode/SM.Base/Objects/InstancedMesh.cs
+++ b/SMCode/SM.Base/Objects/InstancedMesh.cs
@@ -1,17 +1,22 @@
-using System;
+#region usings
+
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Mesh;
+#endregion
+
namespace SM.Base.Objects
{
- public class InstancedMesh : Mesh, ILineMesh
+ ///
+ /// This class allows for fast mesh creation.
+ ///
+ public class InstancedMesh : Mesh
{
public InstancedMesh(PrimitiveType type, string[] enabledAttibute) : base(type)
{
Attributes["vertex"] = Vertex = new VBO();
foreach (string attribute in enabledAttibute)
- {
switch (attribute)
{
case "uv":
@@ -24,9 +29,6 @@ namespace SM.Base.Objects
Attributes["color"] = Color = new VBO(pointerSize: 4);
break;
}
- }
}
-
- public float LineWidth { get; set; } = 1;
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Objects/Mesh.cs b/SMCode/SM.Base/Objects/Mesh.cs
index ccdf31b..90468d2 100644
--- a/SMCode/SM.Base/Objects/Mesh.cs
+++ b/SMCode/SM.Base/Objects/Mesh.cs
@@ -7,16 +7,13 @@ using SM.OGL.Mesh;
namespace SM.Base.Objects
{
- ///
+ ///
public class Mesh : GenericMesh, ILineMesh
{
-
- public float LineWidth { get; set; } = 1;
-
///
/// While initializing, it will add the to the data index.
///
- public Mesh(PrimitiveType type) : base()
+ public Mesh(PrimitiveType type)
{
PrimitiveType = type;
Attributes.Add(3, "color", Color);
@@ -27,5 +24,7 @@ namespace SM.Base.Objects
///
public virtual VBO Color { get; protected set; }
+ ///
+ public float LineWidth { get; set; } = 1;
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Objects/Static/AxisHelper.cs b/SMCode/SM.Base/Objects/Static/AxisHelper.cs
index 02b902f..6c85802 100644
--- a/SMCode/SM.Base/Objects/Static/AxisHelper.cs
+++ b/SMCode/SM.Base/Objects/Static/AxisHelper.cs
@@ -1,15 +1,19 @@
-using OpenTK.Graphics;
+#region usings
+
+using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Mesh;
+#endregion
+
namespace SM.Base.Objects.Static
{
///
/// An AxisHelper-Model
- /// White: -X, -Y, -Z
- /// Red: +X
- /// Green: +Y
- /// Blue: +Z
+ /// White: -X, -Y, -Z
+ /// Red: +X
+ /// Green: +Y
+ /// Blue: +Z
///
public class AxisHelper : Mesh
{
@@ -18,28 +22,30 @@ namespace SM.Base.Objects.Static
///
public static AxisHelper Object = new AxisHelper();
- private AxisHelper() : base(PrimitiveType.Lines) {}
+ private AxisHelper() : base(PrimitiveType.Lines)
+ {
+ }
///
- public override VBO Vertex { get; protected set; } = new VBO()
+ public override VBO Vertex { get; protected set; } = new VBO
{
{0, 0, 0},
{.5f, 0, 0},
{0, 0, 0},
{0, .5f, 0},
{0, 0, -.5f},
- {0, 0, .5f},
+ {0, 0, .5f}
};
///
- public override VBO Color { get; protected set; } = new VBO(pointerSize:4)
+ public override VBO Color { get; protected set; } = new VBO(pointerSize: 4)
{
- {Color4.White},
- {Color4.Red},
- {Color4.White},
- {Color4.Green},
- {Color4.White},
- {Color4.DarkBlue},
+ Color4.White,
+ Color4.Red,
+ Color4.White,
+ Color4.Green,
+ Color4.White,
+ Color4.DarkBlue
};
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/PostEffects/BloomEffect.cs b/SMCode/SM.Base/PostEffects/BloomEffect.cs
index 1b1aa16..f2d108f 100644
--- a/SMCode/SM.Base/PostEffects/BloomEffect.cs
+++ b/SMCode/SM.Base/PostEffects/BloomEffect.cs
@@ -1,60 +1,58 @@
-using System.ComponentModel;
+#region usings
+
using OpenTK;
using OpenTK.Graphics.OpenGL4;
-using SM.Base;
using SM.Base.Drawing;
using SM.Base.PostProcess;
-using SM.Base.Windows;
+using SM.Base.Utility;
+using SM.Base.Window;
using SM.OGL.Framebuffer;
using SM.OGL.Texture;
-using SM.Utility;
+
+#endregion
namespace SM.Base.PostEffects
{
public class BloomEffect : PostProcessEffect
{
- private static BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, new Vector2(0.32f, 1), new Vector2(0.432f, 0), new Vector2(1,0));
-
private const float _defaultTextureScale = .75f;
- private float _textureScale = .75f;
+ private static readonly BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, new Vector2(0.32f, 1),
+ new Vector2(0.432f, 0), new Vector2(1, 0));
private Framebuffer _bloomBuffer1;
private Framebuffer _bloomBuffer2;
- private ColorAttachment _xBuffer;
- private ColorAttachment _yBuffer;
+ private readonly bool _hdr;
- private PostProcessShader _shader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath+".bloom_blur.glsl"));
- private PostProcessShader _mergeShader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath+".bloom_merge_vert.glsl"), AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath+".bloom_merge.glsl"));
+ private readonly PostProcessShader _mergeShader = new PostProcessShader(
+ AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge_vert.glsl"),
+ AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge.glsl"));
+
+ private readonly PostProcessShader _shader =
+ new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_blur.glsl"));
- private bool _hdr;
private Framebuffer _source;
- private BezierCurve _weightCurve ;
+ private readonly float _textureScale = .75f;
+
+ private BezierCurve _weightCurve;
private float[] _weights;
- public int Iterations = 1;
- public float Threshold = .8f;
- public float Power = 1;
-
- public bool Enable = true;
-
- public float MinAmount = 0;
- public float MaxAmount = 1;
+ private ColorAttachment _xBuffer;
+ private ColorAttachment _yBuffer;
public TextureBase AmountMap;
public TextureTransformation AmountTransform = new TextureTransformation();
- public BezierCurve WeightCurve
- {
- get => _weightCurve;
- set
- {
- _weightCurve = value;
- UpdateWeights();
- }
- }
-
+ public bool Enable = true;
+
+ public int Iterations = 1;
+ public float MaxAmount = 1;
+
+ public float MinAmount = 0;
+ public float Power = 1;
+ public float Threshold = .8f;
+
public int WeightCurvePickAmount = 4;
@@ -67,18 +65,25 @@ namespace SM.Base.PostEffects
WeightCurve = _defaultCurve;
}
+ public BezierCurve WeightCurve
+ {
+ get => _weightCurve;
+ set
+ {
+ _weightCurve = value;
+ UpdateWeights();
+ }
+ }
+
private void UpdateWeights()
{
_weights = new float[WeightCurvePickAmount];
for (int i = 0; i < WeightCurvePickAmount; i++)
- {
- _weights[i] = _weightCurve.CalculatePoint((float)(i + 1) / (WeightCurvePickAmount + 1)).Y;
- }
+ _weights[i] = _weightCurve.CalculatePoint((float) (i + 1) / (WeightCurvePickAmount + 1)).Y;
}
-
protected override void InitProcess()
{
@@ -86,10 +91,16 @@ namespace SM.Base.PostEffects
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
- _bloomBuffer1 = new Framebuffer(Pipeline.ConnectedWindow, _textureScale);
+ _bloomBuffer1 = new Framebuffer(Pipeline.ConnectedWindow, _textureScale)
+ {
+ Name = "BloomX"
+ };
_bloomBuffer1.Append("xBuffer", _xBuffer = new ColorAttachment(0, PixelInformation.RGBA_HDR));
_bloomBuffer1.Compile();
- _bloomBuffer2 = new Framebuffer(Pipeline.ConnectedWindow, _textureScale);
+ _bloomBuffer2 = new Framebuffer(Pipeline.ConnectedWindow, _textureScale)
+ {
+ Name = "BloomY"
+ };
_bloomBuffer2.Append("yBuffer", _yBuffer = new ColorAttachment(0, PixelInformation.RGBA_HDR));
_bloomBuffer2.Compile();
@@ -101,34 +112,36 @@ namespace SM.Base.PostEffects
{
if (Enable)
{
- GL.Viewport(0,0, (int)(Pipeline.ConnectedWindow.Width * _textureScale), (int)(Pipeline.ConnectedWindow.Height * _textureScale));
-
+ GL.Viewport(0, 0, (int) (Pipeline.ConnectedWindow.Width * _textureScale),
+ (int) (Pipeline.ConnectedWindow.Height * _textureScale));
+
Framebuffer target = Framebuffer.GetCurrentlyActive();
bool first = true, hoz = true;
int iter = Iterations * 2;
for (int i = 0; i < iter; i++)
{
(hoz ? _bloomBuffer1 : _bloomBuffer2).Activate();
-
+
_shader.Draw(collection =>
{
- collection["renderedTexture"].SetTexture(first ? _source.ColorAttachments["color"] : (hoz ? _yBuffer : _xBuffer));
+ collection["renderedTexture"]
+ .SetTexture(first ? _source.ColorAttachments["color"] : hoz ? _yBuffer : _xBuffer);
collection["RenderScale"].SetUniform1(_textureScale);
collection["First"].SetUniform1(first);
collection["Threshold"].SetUniform1(Threshold);
-
+
collection["Horizontal"].SetUniform1(hoz);
-
+
collection["Weights"].SetUniform1(_weights);
collection["WeightCount"].SetUniform1(WeightCurvePickAmount);
collection["Power"].SetUniform1(Power);
});
-
+
hoz = !hoz;
if (first) first = false;
}
-
+
GL.Viewport(Pipeline.ConnectedWindow.ClientRectangle);
target.Activate();
}
diff --git a/SMCode/SM.Base/PostEffects/PostProcessFinals.cs b/SMCode/SM.Base/PostEffects/PostProcessFinals.cs
index 30b6546..0cfd160 100644
--- a/SMCode/SM.Base/PostEffects/PostProcessFinals.cs
+++ b/SMCode/SM.Base/PostEffects/PostProcessFinals.cs
@@ -1,31 +1,54 @@
-using System.Windows.Controls;
+#region usings
+
using OpenTK.Graphics.OpenGL4;
using SM.Base.PostProcess;
-using SM.Base.Windows;
+using SM.Base.Utility;
using SM.OGL.Framebuffer;
-using SM.Utility;
+
+#endregion
namespace SM.Base.PostEffects
{
- public class PostProcessFinals
+ ///
+ /// This class has some utility for render pipelines
+ ///
+ public static class PostProcessFinals
{
- static PostProcessShader _hdrExposureShader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath+".finalize_hdr.glsl"));
- static PostProcessShader _gammaShader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_gamma.glsl"));
+ private static readonly PostProcessShader _hdrExposureShader =
+ new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl"));
+ private static readonly PostProcessShader _gammaShader =
+ new PostProcessShader(
+ AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_gamma.glsl"));
+
+ ///
+ /// The gamma that is used for and .
+ ///
public static float Gamma = 2.2f;
+ ///
+ /// This resolves a multisampled framebuffer to a non-multisampled renderbuffer.
+ ///
+ ///
+ ///
public static void ResolveMultisampledBuffers(Framebuffer multisampledBuffers, Framebuffer target)
{
multisampledBuffers.Activate(FramebufferTarget.ReadFramebuffer);
target.Activate(FramebufferTarget.DrawFramebuffer);
- GL.BlitFramebuffer(0, 0, (int)multisampledBuffers.Size.X, (int)multisampledBuffers.Size.Y, 0, 0, (int)target.Size.X, (int)target.Size.Y, ClearBufferMask.ColorBufferBit, BlitFramebufferFilter.Nearest);
+ 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,
+ BlitFramebufferFilter.Nearest);
target.Activate();
}
+ ///
+ /// This converts HDR to LDR and applys gamma.
+ ///
+ ///
+ ///
public static void FinalizeHDR(ColorAttachment attachment, float exposure)
{
-
_hdrExposureShader.Draw(u =>
{
u["Gamma"].SetUniform1(Gamma);
@@ -34,6 +57,10 @@ namespace SM.Base.PostEffects
});
}
+ ///
+ /// This applys gamma
+ ///
+ ///
public static void FinalizeGamma(ColorAttachment attachment)
{
_gammaShader.Draw(u =>
diff --git a/SMCode/SM.Base/PostProcess/PostProcessEffect.cs b/SMCode/SM.Base/PostProcess/PostProcessEffect.cs
index cd70945..cb6f750 100644
--- a/SMCode/SM.Base/PostProcess/PostProcessEffect.cs
+++ b/SMCode/SM.Base/PostProcess/PostProcessEffect.cs
@@ -1,19 +1,15 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
+#region usings
+
using OpenTK;
-using OpenTK.Graphics.OpenGL4;
-using SM.Base;
-using SM.Base.Objects.Static;
using SM.Base.Scene;
-using SM.Base.Windows;
-using SM.OGL.Framebuffer;
-using SM.OGL.Shaders;
+using SM.Base.Window;
+
+#endregion
namespace SM.Base.PostProcess
{
///
- /// Basis for a post process effect
+ /// Basis for a post process effect
///
public abstract class PostProcessEffect
{
@@ -22,7 +18,7 @@ namespace SM.Base.PostProcess
protected RenderPipeline Pipeline;
///
- /// Initialize the effect.
+ /// Initialize the effect.
///
///
public void Initilize(RenderPipeline pipeline)
@@ -30,24 +26,25 @@ namespace SM.Base.PostProcess
Pipeline = pipeline;
InitProcess();
}
-
- ///
- /// Method, to initialize the shader.
- ///
- protected virtual void InitProcess() {}
-
///
- /// Method to draw the actual effect.
+ /// Method, to initialize the shader.
+ ///
+ protected virtual void InitProcess()
+ {
+ }
+
+
+ ///
+ /// Method to draw the actual effect.
///
public abstract void Draw(DrawContext context);
///
- /// Event, when the scene changed.
+ /// Event, when the scene changed.
///
public virtual void SceneChanged(GenericScene scene)
{
-
}
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/PostProcess/PostProcessShader.cs b/SMCode/SM.Base/PostProcess/PostProcessShader.cs
index 3ac88c5..5b92c19 100644
--- a/SMCode/SM.Base/PostProcess/PostProcessShader.cs
+++ b/SMCode/SM.Base/PostProcess/PostProcessShader.cs
@@ -1,10 +1,13 @@
-using System;
+#region usings
+
+using System;
using System.Collections.Generic;
using OpenTK.Graphics.OpenGL4;
using SM.Base.Objects.Static;
-using SM.OGL.Framebuffer;
+using SM.Base.Utility;
using SM.OGL.Shaders;
-using SM.Utility;
+
+#endregion
namespace SM.Base.PostProcess
{
@@ -13,8 +16,12 @@ namespace SM.Base.PostProcess
///
public class PostProcessShader : GenericShader
{
- private static readonly ShaderFile _fragExtensions = new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.extensions.frag"));
- private static readonly ShaderFile _normalVertex = new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexFile.vert"));
+ private static readonly ShaderFile _fragExtensions =
+ new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.extensions.frag"));
+
+ private static readonly ShaderFile _normalVertex =
+ new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexFile.vert"));
+
private static readonly string _normalVertexWithExt =
AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexWithExt.vert");
@@ -22,8 +29,9 @@ namespace SM.Base.PostProcess
/// Creates the shader with the default vertex shader and custom fragment.
///
public PostProcessShader(string fragment) : this(_normalVertex,
- new ShaderFile(fragment))
- { }
+ new ShaderFile(fragment))
+ {
+ }
///
/// Creates the shader with an vertex extension and custom fragment.
@@ -32,9 +40,10 @@ namespace SM.Base.PostProcess
///
public PostProcessShader(string vertexExt, string fragment) : this(new ShaderFile(_normalVertexWithExt)
{
- GLSLExtensions = new List() { new ShaderFile(vertexExt) }
- }, new ShaderFile(fragment))
- { }
+ GLSLExtensions = new List {new ShaderFile(vertexExt)}
+ }, new ShaderFile(fragment))
+ {
+ }
private PostProcessShader(ShaderFile vertex, ShaderFile fragment) : base(
new ShaderFileCollection(vertex, fragment))
@@ -43,7 +52,7 @@ namespace SM.Base.PostProcess
}
///
- /// Draws the shader with special uniforms.
+ /// Draws the shader with special uniforms.
///
///
///
diff --git a/SMCode/SM.Base/SM.Base.csproj b/SMCode/SM.Base/SM.Base.csproj
index 6faa593..99268ba 100644
--- a/SMCode/SM.Base/SM.Base.csproj
+++ b/SMCode/SM.Base/SM.Base.csproj
@@ -41,7 +41,6 @@
..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll
-
..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll
diff --git a/SMCode/SM.Base/SMRenderer.cs b/SMCode/SM.Base/SMRenderer.cs
index b6f6df2..204a508 100644
--- a/SMCode/SM.Base/SMRenderer.cs
+++ b/SMCode/SM.Base/SMRenderer.cs
@@ -1,13 +1,11 @@
#region usings
-using SM.Base.Drawing;
using SM.Base.Drawing.Text;
using SM.Base.Objects.Static;
-using SM.Base.Scene;
-using SM.Base.Windows;
+using SM.Base.Shaders;
+using SM.Base.Utility;
+using SM.Base.Window;
using SM.OGL.Mesh;
-using SM.OGL.Shaders;
-using SM.Utility;
#endregion
diff --git a/SMCode/SM.Base/Scene/GenericCamera.cs b/SMCode/SM.Base/Scene/GenericCamera.cs
index b207567..fd88ca7 100644
--- a/SMCode/SM.Base/Scene/GenericCamera.cs
+++ b/SMCode/SM.Base/Scene/GenericCamera.cs
@@ -1,7 +1,7 @@
#region usings
using OpenTK;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -12,6 +12,11 @@ namespace SM.Base.Scene
///
public abstract class GenericCamera
{
+ ///
+ /// Exposure defines the exposure to the Scene.
+ ///
+ public float Exposure = 1;
+
///
/// This defines what is up. (Normalized)
/// Default:
@@ -34,11 +39,6 @@ namespace SM.Base.Scene
///
public abstract bool Orthographic { get; }
- ///
- /// Exposure defines the exposure to the Scene.
- ///
- public float Exposure = 1;
-
///
/// Calculates the view matrix.
///
@@ -46,10 +46,7 @@ namespace SM.Base.Scene
internal void CalculateViewMatrix(IGenericWindow window)
{
View = ViewCalculation(window);
- if (WorldCalculation(window, out Matrix4 world))
- {
- World = world;
- }
+ if (WorldCalculation(window, out Matrix4 world)) World = world;
}
///
@@ -61,6 +58,12 @@ namespace SM.Base.Scene
///
protected abstract Matrix4 ViewCalculation(IGenericWindow window);
+ ///
+ /// This calculates the world.
+ ///
+ ///
+ ///
+ ///
protected abstract bool WorldCalculation(IGenericWindow window, out Matrix4 world);
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Scene/GenericItemCollection.cs b/SMCode/SM.Base/Scene/GenericItemCollection.cs
index bc23520..2468914 100644
--- a/SMCode/SM.Base/Scene/GenericItemCollection.cs
+++ b/SMCode/SM.Base/Scene/GenericItemCollection.cs
@@ -2,10 +2,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using OpenTK;
-using SM.Base;
using SM.Base.Drawing;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -16,12 +14,17 @@ namespace SM.Base.Scene
///
public abstract class GenericItemCollection : List, IShowItem, IShowCollection, IScriptable
{
- private List _scriptableObjects = new List();
+ private readonly List _scriptableObjects = new List();
///
/// Currently active script objects.
///
- public ReadOnlyCollection ScriptableObjects => new ReadOnlyCollection(_scriptableObjects);
+ public ReadOnlyCollection ScriptableObjects =>
+ new ReadOnlyCollection(_scriptableObjects);
+
+ ///
+ public bool UpdateActive { get; set; } = true;
+
///
public List Objects => this;
@@ -32,23 +35,13 @@ namespace SM.Base.Scene
public string Name { get; set; } = "Unnamed Item Collection";
///
- public ICollection Flags { get; set; } = new List() {"collection"};
+ public ICollection Flags { get; set; } = new List {"collection"};
+ ///
public bool Active { get; set; } = true;
- public bool UpdateActive { get; set; } = true;
- public bool RenderActive { get; set; } = true;
-
- ///
- public virtual void Update(UpdateContext context)
- {
- if (!Active || !UpdateActive) return;
- for (var i = 0; i < _scriptableObjects.Count; i++)
- {
- if (!_scriptableObjects[i].Active || !_scriptableObjects[i].UpdateActive) continue;
- _scriptableObjects[i].Update(context);
- }
- }
+ ///
+ public bool RenderActive { get; set; } = true;
///
public virtual void Draw(DrawContext context)
@@ -62,6 +55,18 @@ namespace SM.Base.Scene
}
}
+ ///
+ public virtual void Update(UpdateContext context)
+ {
+ if (!Active || !UpdateActive) return;
+
+ for (var i = 0; i < _scriptableObjects.Count; i++)
+ {
+ if (!_scriptableObjects[i].Active || !_scriptableObjects[i].UpdateActive) continue;
+ _scriptableObjects[i].Update(context);
+ }
+ }
+
///
public virtual void OnAdded(object sender)
{
@@ -75,7 +80,7 @@ namespace SM.Base.Scene
///
/// Adds a item to the draw and the script collection, when applicable.
///
- public new void Add(params IShowItem[] items)
+ public void Add(params IShowItem[] items)
{
foreach (var item in items)
{
@@ -87,7 +92,7 @@ namespace SM.Base.Scene
}
///
- /// Adds the object to the collection.
+ /// Adds the object to the collection.
///
///
public void AddObject(IShowItem item)
@@ -96,8 +101,9 @@ namespace SM.Base.Scene
item.Parent = this;
item.OnAdded(this);
}
+
///
- /// Adds the script to the collection.
+ /// Adds the script to the collection.
///
///
public void AddScript(IScriptable item)
@@ -105,7 +111,7 @@ namespace SM.Base.Scene
_scriptableObjects.Add(item);
}
- public new void Remove(params IShowItem[] items)
+ public void Remove(params IShowItem[] items)
{
foreach (var item in items)
{
@@ -117,7 +123,7 @@ namespace SM.Base.Scene
}
///
- /// Remove the object from the draw collection.
+ /// Remove the object from the draw collection.
///
///
public void RemoveObject(IShowItem item)
@@ -128,7 +134,7 @@ namespace SM.Base.Scene
}
///
- /// Remove the object from the script collection.
+ /// Remove the object from the script collection.
///
///
public void RemoveScript(IScriptable item)
@@ -139,7 +145,7 @@ namespace SM.Base.Scene
public ICollection GetAllItems(bool includeCollections = false)
{
List items = new List();
- for (var i = 0; i < this.Count; i++)
+ for (var i = 0; i < Count; i++)
{
if (!includeCollections && this[i] is IShowCollection) continue;
items.Add(this[i]);
@@ -201,7 +207,8 @@ namespace SM.Base.Scene
///
/// The type of show items.
/// The type of transformation.
- public abstract class GenericItemCollection : GenericItemCollection, IShowTransformItem
+ public abstract class GenericItemCollection : GenericItemCollection,
+ IShowTransformItem
where TTransformation : GenericTransformation, new()
{
///
diff --git a/SMCode/SM.Base/Scene/GenericScene.cs b/SMCode/SM.Base/Scene/GenericScene.cs
index 8c2796b..57e7da6 100644
--- a/SMCode/SM.Base/Scene/GenericScene.cs
+++ b/SMCode/SM.Base/Scene/GenericScene.cs
@@ -2,12 +2,8 @@
using System;
using System.Collections.Generic;
-using System.Dynamic;
-using System.Windows.Controls;
-using SM.Base;
-using SM.Base.Drawing;
-using SM.Base.Windows;
-using SM.Utility;
+using SM.Base.Utility;
+using SM.Base.Window;
#endregion
@@ -18,12 +14,17 @@ namespace SM.Base.Scene
///
public abstract class GenericScene : IInitializable
{
+ private IBackgroundItem _background;
+ private readonly Dictionary _extensions = new Dictionary();
private GenericItemCollection _hud;
private GenericItemCollection _objectCollection;
- private IBackgroundItem _background;
- private Dictionary _extensions = new Dictionary();
-
+
+ ///
+ /// A collection for cameras to switch easier to different cameras.
+ ///
+ public Dictionary Cameras = new Dictionary();
+
///
/// This contains the background.
///
@@ -63,16 +64,6 @@ namespace SM.Base.Scene
}
}
- ///
- /// A collection for cameras to switch easier to different cameras.
- ///
- public Dictionary Cameras = new Dictionary();
-
- ///
- /// If true, the scene was already initialized.
- ///
- public bool IsInitialized { get; set; }
-
///
/// If true, shows a axis helper at (0,0,0)
@@ -95,6 +86,20 @@ namespace SM.Base.Scene
///
public GenericCamera HUDCamera { get; set; }
+ ///
+ /// If true, the scene was already initialized.
+ ///
+ public bool IsInitialized { get; set; }
+
+
+ public virtual void Activate()
+ {
+ }
+
+ public virtual void Initialization()
+ {
+ }
+
///
/// Updates this scene.
///
@@ -155,7 +160,6 @@ namespace SM.Base.Scene
///
public virtual void DrawDebug(DrawContext context)
{
-
}
///
@@ -178,25 +182,20 @@ namespace SM.Base.Scene
object ext = _extensions[typeof(T)];
if (ext == null)
{
- Log.Write(LogType.Warning, $"Tried to get the extension '{typeof(T).Name}', that doesn't exist in the scene.");
+ Log.Write(LogType.Warning,
+ $"Tried to get the extension '{typeof(T).Name}', that doesn't exist in the scene.");
return null;
}
- return (T)ext;
+ return (T) ext;
}
-
- public virtual void Activate()
+ ///
+ /// This is triggered when the scene gets deactivated.
+ ///
+ public virtual void Deactivate()
{
-
}
-
- public virtual void Initialization()
- {
-
- }
-
- public virtual void Deactivate() {}
}
///
@@ -242,6 +241,5 @@ namespace SM.Base.Scene
get => (TCamera) base.BackgroundCamera;
set => base.BackgroundCamera = value;
}
-
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Scene/IScriptable.cs b/SMCode/SM.Base/Scene/IScriptable.cs
index cedc974..ea7abc9 100644
--- a/SMCode/SM.Base/Scene/IScriptable.cs
+++ b/SMCode/SM.Base/Scene/IScriptable.cs
@@ -1,14 +1,24 @@
-using SM.Base;
-using SM.Base.Windows;
+#region usings
+
+using SM.Base.Window;
+
+#endregion
namespace SM.Base.Scene
{
///
- /// Defines a object as script.
+ /// Defines a object as script.
///
public interface IScriptable
{
+ ///
+ /// If not active, ItemCollections will ignore them.
+ ///
bool Active { get; set; }
+
+ ///
+ /// If not active, ItemCollections will ignore them.
+ ///
bool UpdateActive { get; set; }
///
diff --git a/SMCode/SM.Base/Scene/IShowCollection.cs b/SMCode/SM.Base/Scene/IShowCollection.cs
index aac9a3f..f350139 100644
--- a/SMCode/SM.Base/Scene/IShowCollection.cs
+++ b/SMCode/SM.Base/Scene/IShowCollection.cs
@@ -1,8 +1,7 @@
#region usings
using System.Collections.Generic;
-using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -11,7 +10,6 @@ namespace SM.Base.Scene
///
/// Adds functions, that is required for a collection.
///
- /// The type of show item.
public interface IShowCollection
{
///
diff --git a/SMCode/SM.Base/Scene/IShowItem.cs b/SMCode/SM.Base/Scene/IShowItem.cs
index 04046ce..748534e 100644
--- a/SMCode/SM.Base/Scene/IShowItem.cs
+++ b/SMCode/SM.Base/Scene/IShowItem.cs
@@ -1,9 +1,8 @@
#region usings
using System.Collections.Generic;
-using SM.Base;
using SM.Base.Drawing;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM.OGL.Mesh;
#endregion
@@ -50,7 +49,7 @@ namespace SM.Base.Scene
void OnRemoved(object sender);
}
- public interface ITransformItem
+ public interface ITransformItem
where TTransform : GenericTransformation
{
TTransform Transform { get; set; }
@@ -58,7 +57,8 @@ namespace SM.Base.Scene
public interface IShowTransformItem : IShowItem, ITransformItem
where TTransform : GenericTransformation
- {}
+ {
+ }
public interface IModelItem
{
diff --git a/SMCode/SM.Base/Shaders/Extensions/ExtensionManager.cs b/SMCode/SM.Base/Shaders/Extensions/ExtensionManager.cs
index c538b49..522a26e 100644
--- a/SMCode/SM.Base/Shaders/Extensions/ExtensionManager.cs
+++ b/SMCode/SM.Base/Shaders/Extensions/ExtensionManager.cs
@@ -4,7 +4,7 @@ using SM.OGL.Shaders;
#endregion
-namespace SM.Base.ShaderExtension
+namespace SM.Base.Shaders.Extensions
{
internal class ExtensionManager
{
diff --git a/SMCode/SM.Base/Shaders/MaterialShader.cs b/SMCode/SM.Base/Shaders/MaterialShader.cs
index 504aea6..93e6323 100644
--- a/SMCode/SM.Base/Shaders/MaterialShader.cs
+++ b/SMCode/SM.Base/Shaders/MaterialShader.cs
@@ -1,14 +1,13 @@
#region usings
using OpenTK.Graphics.OpenGL4;
-using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM.OGL.Mesh;
using SM.OGL.Shaders;
#endregion
-namespace SM.Base.Drawing
+namespace SM.Base.Shaders
{
///
/// A general class to work with material shaders properly.
@@ -17,7 +16,8 @@ namespace SM.Base.Drawing
{
///
protected MaterialShader(string combinedData) : base(combinedData)
- {}
+ {
+ }
///
protected MaterialShader(string vertex, string fragment) : base(vertex, fragment)
@@ -39,16 +39,20 @@ namespace SM.Base.Drawing
context.Mesh.Activate();
- if (context.Mesh is ILineMesh lineMesh)
- GL.LineWidth(context.Material.ShaderArguments.Get("LineWidth", lineMesh.LineWidth));
+ if (context.Mesh is ILineMesh lineMesh)
+ GL.LineWidth(context.Material.ShaderArguments.Get("LineWidth", lineMesh.LineWidth));
else if (context.Material.ShaderArguments.ContainsKey("LineWidth"))
- GL.LineWidth((float)context.Material.ShaderArguments["LineWidth"]);
+ GL.LineWidth((float) context.Material.ShaderArguments["LineWidth"]);
if (context.Material.Blending)
{
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
- } else GL.Disable(EnableCap.Blend);
+ }
+ else
+ {
+ GL.Disable(EnableCap.Blend);
+ }
DrawProcess(context);
diff --git a/SMCode/SM.Base/Shaders/SimpleShader.cs b/SMCode/SM.Base/Shaders/SimpleShader.cs
index 1a6d2e6..e068e12 100644
--- a/SMCode/SM.Base/Shaders/SimpleShader.cs
+++ b/SMCode/SM.Base/Shaders/SimpleShader.cs
@@ -1,30 +1,46 @@
-using System;
-using System.Collections.Generic;
-using System.Dynamic;
-using SM.Base.Windows;
-using SM.OGL.Shaders;
-using SM.Utility;
+#region usings
-namespace SM.Base.Drawing
+using System;
+using System.Collections.Generic;
+using SM.Base.Utility;
+using SM.Base.Window;
+using SM.OGL.Shaders;
+
+#endregion
+
+namespace SM.Base.Shaders
{
+ ///
+ /// Allows for simple creation of shaders.
+ ///
public class SimpleShader : MaterialShader
{
+ ///
+ /// Vertex files that are stored in this dictionary can be used as vertex presets.
+ ///
public static Dictionary>> VertexFiles =
new Dictionary>>();
+
+ private readonly string _vertexPreset;
- static ShaderFile _extensionDefineFile = new ShaderFile("#define SM_SIMPLE_EXTENSION");
+ ///
+ /// Stores the function that sets the uniforms.
+ ///
+ public Action SetUniform;
static SimpleShader()
{
VertexFiles.Add("basic", new Tuple>(
- new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.Shaders.SimpleShaderPresets.basic_vertex.glsl"))
+ new ShaderFile(
+ AssemblyUtility.ReadAssemblyFile("SM.Base.Shaders.SimpleShaderPresets.basic_vertex.glsl"))
{
StringOverrides = {["extension"] = "0"}
},
BasicSetUniforms
));
VertexFiles.Add("E_basic", new Tuple>(
- new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.Shaders.SimpleShaderPresets.basic_vertex.glsl"))
+ new ShaderFile(
+ AssemblyUtility.ReadAssemblyFile("SM.Base.Shaders.SimpleShaderPresets.basic_vertex.glsl"))
{
StringOverrides = {["extension"] = "1"}
},
@@ -35,7 +51,7 @@ namespace SM.Base.Drawing
new ShaderFile(
AssemblyUtility.ReadAssemblyFile("SM.Base.Shaders.SimpleShaderPresets.instanced_vertex.glsl"))
{
- StringOverrides = { ["instanceMax"] = SMRenderer.MaxInstances.ToString(), ["extension"] = "0" }
+ StringOverrides = {["instanceMax"] = SMRenderer.MaxInstances.ToString(), ["extension"] = "0"}
},
InstancedSetUniforms
));
@@ -43,16 +59,46 @@ namespace SM.Base.Drawing
new ShaderFile(
AssemblyUtility.ReadAssemblyFile("SM.Base.Shaders.SimpleShaderPresets.instanced_vertex.glsl"))
{
- StringOverrides = { ["instanceMax"] = SMRenderer.MaxInstances.ToString(), ["extension"] = "0" }
+ StringOverrides = {["instanceMax"] = SMRenderer.MaxInstances.ToString(), ["extension"] = "0"}
},
InstancedSetUniforms
));
}
- static void BasicSetUniforms(UniformCollection uniforms, DrawContext context)
+ ///
+ /// Creates a simple shader.
+ ///
+ /// The vertex preset.
+ /// The fragment shader
+ /// The uniform function.
+ public SimpleShader(string vertexPreset, string fragment, Action setUniform) :
+ base(new ShaderFileCollection(VertexFiles[vertexPreset].Item1, new ShaderFile(fragment)))
+ {
+ _vertexPreset = vertexPreset;
+ SetUniform = setUniform;
+ }
+
+ ///
+ /// Creates a simple shader with a extension.
+ ///
+ /// The vertex preset.
+ /// The vertex extension shader
+ /// The fragment shader
+ /// The uniform function.
+ public SimpleShader(string vertexPreset, string vertexExtension, string fragment,
+ Action setUniform) : base(new ShaderFileCollection(
+ new[] {VertexFiles["E_" + vertexPreset].Item1, new ShaderFile(vertexExtension)},
+ new[] {new ShaderFile(fragment)}))
+ {
+ _vertexPreset = vertexPreset;
+ SetUniform = setUniform;
+ }
+
+ private static void BasicSetUniforms(UniformCollection uniforms, DrawContext context)
{
// Vertex Uniforms
- uniforms["MVP"].SetMatrix4(context.Instances[0].ModelMatrix * context.ModelMatrix * context.View * context.World);
+ uniforms["MVP"]
+ .SetMatrix4(context.Instances[0].ModelMatrix * context.ModelMatrix * context.View * context.World);
uniforms["MasterTextureMatrix"].SetMatrix3(context.Instances[0].TextureMatrix * context.TextureMatrix);
uniforms["HasVColor"]
.SetUniform1(context.Mesh.Attributes.Has("color"));
@@ -60,7 +106,7 @@ namespace SM.Base.Drawing
DrawObject(context.ForcedType.GetValueOrDefault(context.Mesh.PrimitiveType), context.Mesh);
}
- static void InstancedSetUniforms(UniformCollection uniforms, DrawContext context)
+ private static void InstancedSetUniforms(UniformCollection uniforms, DrawContext context)
{
uniforms["MVP"].SetMatrix4(context.ModelMatrix * context.View * context.World);
uniforms["MasterTextureMatrix"].SetMatrix3(context.TextureMatrix);
@@ -86,28 +132,11 @@ namespace SM.Base.Drawing
shaderInstanceI++;
}
+
DrawObject(context.ForcedType.GetValueOrDefault(context.Mesh.PrimitiveType), context.Mesh, shaderInstanceI);
}
- private string _vertexPreset;
-
- public Action SetUniform;
-
- public SimpleShader(string vertexPreset, string fragment, Action setUniform) : base(new ShaderFileCollection(VertexFiles[vertexPreset].Item1, new ShaderFile(fragment)))
- {
- _vertexPreset = vertexPreset;
- SetUniform = setUniform;
- }
-
- public SimpleShader(string vertexPreset, string vertexExtension, string fragment,
- Action setUniform) : base(new ShaderFileCollection(
- new[] {VertexFiles["E_"+vertexPreset].Item1, new ShaderFile(vertexExtension)},
- new[] {new ShaderFile(fragment),}))
- {
- _vertexPreset = vertexPreset;
- SetUniform = setUniform;
- }
-
+ ///
protected override void DrawProcess(DrawContext context)
{
SetUniform?.Invoke(Uniforms, context);
diff --git a/SMCode/SM.Base/Textures/Texture.cs b/SMCode/SM.Base/Textures/Texture.cs
index 5833d87..0e140f0 100644
--- a/SMCode/SM.Base/Textures/Texture.cs
+++ b/SMCode/SM.Base/Textures/Texture.cs
@@ -15,8 +15,8 @@ namespace SM.Base.Textures
///
public class Texture : TextureBase
{
- private int? _width;
private int? _height;
+ private int? _width;
///
/// Decides if the bitmap will automatically dispose itself.
@@ -28,24 +28,6 @@ namespace SM.Base.Textures
///
public Bitmap Map;
- ///
- public override int Width
- {
- get => _width ?? Map.Width;
- protected set => _width = value;
- }
-
- ///
- public override int Height
- {
- get => _height ?? Map.Height;
- protected set => _height = value;
- }
- ///
- /// Aspect ratio of Width and Height of the texture
- ///
- public float Aspect { get; private set; }
-
///
/// Empty constructor
///
@@ -72,12 +54,31 @@ namespace SM.Base.Textures
{
Map = map;
- Aspect = (float)map.Width / map.Height;
+ Aspect = (float) map.Width / map.Height;
Filter = filter;
WrapMode = wrapMode;
}
+ ///
+ public override int Width
+ {
+ get => _width ?? Map.Width;
+ protected set => _width = value;
+ }
+
+ ///
+ public override int Height
+ {
+ get => _height ?? Map.Height;
+ protected set => _height = value;
+ }
+
+ ///
+ /// Aspect ratio of Width and Height of the texture
+ ///
+ public float Aspect { get; }
+
///
public override void Compile()
diff --git a/SMCode/SM.Base/Time/Interval.cs b/SMCode/SM.Base/Time/Interval.cs
index ea24f1f..a81fab5 100644
--- a/SMCode/SM.Base/Time/Interval.cs
+++ b/SMCode/SM.Base/Time/Interval.cs
@@ -1,8 +1,7 @@
#region usings
using System;
-using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
diff --git a/SMCode/SM.Base/Time/Stopwatch.cs b/SMCode/SM.Base/Time/Stopwatch.cs
index 1eb8525..b6ada15 100644
--- a/SMCode/SM.Base/Time/Stopwatch.cs
+++ b/SMCode/SM.Base/Time/Stopwatch.cs
@@ -2,8 +2,7 @@
using System;
using System.Collections.Generic;
-using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -14,17 +13,17 @@ namespace SM.Base.Time
///
public class Stopwatch
{
- private static List _activeStopwatches = new List();
- private bool _paused = false;
+ private static readonly List _activeStopwatches = new List();
+ private bool _paused;
///
- /// If true, the stopwatch was started.
- /// This doesn't changed when paused.
+ /// If true, the stopwatch was started.
+ /// This doesn't changed when paused.
///
- public bool Active { get; private set; } = false;
+ public bool Active { get; private set; }
///
- /// Gets/Sets if the stopwatch is paused.
+ /// Gets/Sets if the stopwatch is paused.
///
public bool Paused
{
@@ -39,7 +38,7 @@ namespace SM.Base.Time
}
///
- /// If true, the stopwatch is active and not paused... (who would have guessed...)
+ /// If true, the stopwatch is active and not paused... (who would have guessed...)
///
public bool Running => Active && !Paused;
@@ -53,6 +52,9 @@ namespace SM.Base.Time
///
public TimeSpan ElapsedSpan { get; protected set; }
+ ///
+ /// This event gets triggered every tick.
+ ///
public event Action Tick;
///
@@ -66,7 +68,6 @@ namespace SM.Base.Time
Active = true;
}
-
///
/// Performs a tick.
@@ -81,15 +82,15 @@ namespace SM.Base.Time
}
///
- /// Resumes the timer.
+ /// Resumes the timer.
///
protected virtual void Resume()
{
_paused = false;
}
-
+
///
- /// Pauses the timer.
+ /// Pauses the timer.
///
protected virtual void Pause()
{
diff --git a/SMCode/SM.Base/Time/Timer.cs b/SMCode/SM.Base/Time/Timer.cs
index 9d73bbc..649eea3 100644
--- a/SMCode/SM.Base/Time/Timer.cs
+++ b/SMCode/SM.Base/Time/Timer.cs
@@ -1,9 +1,7 @@
#region usings
using System;
-using System.Diagnostics.Eventing.Reader;
-using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
@@ -35,7 +33,7 @@ namespace SM.Base.Time
///
/// The target time in seconds.
///
- public float Target { get; private set; }
+ public float Target { get; }
///
/// The already elapsed time but normalized to the target.
diff --git a/SMCode/SM.Base/Types/CVector1.cs b/SMCode/SM.Base/Types/CVector1.cs
index 0e8b19e..a5d2642 100644
--- a/SMCode/SM.Base/Types/CVector1.cs
+++ b/SMCode/SM.Base/Types/CVector1.cs
@@ -1,39 +1,18 @@
-using System;
-using OpenTK;
+#region usings
+
+using System;
+
+#endregion
namespace SM.Base.Types
{
///
- /// A One-dimensional Vector (also known as ), in a class.
+ /// A One-dimensional Vector (also known as ), in a class.
///
public class CVector1
{
///
- /// X - Component
- ///
- public float X
- {
- get;
- set;
- }
-
- ///
- /// The length/magnitute of the vector.
- ///
- public float Length => GetLength();
- ///
- /// Gets the square of the vector length (magnitude).
- ///
- ///
- /// This property avoids the costly square root operation required by the Length property. This makes it more suitable
- /// for comparisons.
- ///
- public float LengthSquared => GetLength(true);
-
- public event Action Changed;
-
- ///
- /// Creates a class vector
+ /// Creates a class vector
///
/// X-Component
public CVector1(float x)
@@ -41,10 +20,33 @@ namespace SM.Base.Types
X = x;
}
-
+ ///
+ /// X - Component
+ ///
+ public float X { get; set; }
///
- /// Get the length of the vector.
+ /// The length/magnitute of the vector.
+ ///
+ public float Length => GetLength();
+
+ ///
+ /// Gets the square of the vector length (magnitude).
+ ///
+ ///
+ /// This property avoids the costly square root operation required by the Length property. This makes it more suitable
+ /// for comparisons.
+ ///
+ public float LengthSquared => GetLength(true);
+
+ ///
+ /// This event triggers when a component changed.
+ ///
+ public event Action Changed;
+
+
+ ///
+ /// Get the length of the vector.
///
/// If true, it will return the squared product.
///
@@ -57,7 +59,7 @@ namespace SM.Base.Types
///
- /// Normalizes the vector.
+ /// Normalizes the vector.
///
public void Normalize()
{
@@ -66,7 +68,7 @@ namespace SM.Base.Types
}
///
- /// Sets the X-Component.
+ /// Sets the X-Component.
///
/// X-Component
public virtual void Set(float uniform, bool triggerChanged = true)
@@ -75,6 +77,11 @@ namespace SM.Base.Types
if (triggerChanged) TriggerChanged();
}
+ ///
+ /// Adds the value to the components.
+ ///
+ ///
+ ///
public virtual void Add(float uniform, bool triggerChanged = true)
{
X += uniform;
@@ -82,20 +89,24 @@ namespace SM.Base.Types
}
///
- /// Conversion into
+ /// Conversion into
///
- public static implicit operator float(CVector1 vector1) => vector1.X;
+ public static implicit operator float(CVector1 vector1)
+ {
+ return vector1.X;
+ }
+
///
- /// Conversion from to One-dimensional Vector.
+ /// Conversion from to One-dimensional Vector.
///
///
///
//public static implicit operator CVector1(float f) => new CVector1(f);
-
protected virtual float GetLengthProcess()
{
return X * X;
}
+
protected virtual void NormalizationProcess(float length)
{
X *= length;
diff --git a/SMCode/SM.Base/Types/CVector2.cs b/SMCode/SM.Base/Types/CVector2.cs
index a670c88..8d4627b 100644
--- a/SMCode/SM.Base/Types/CVector2.cs
+++ b/SMCode/SM.Base/Types/CVector2.cs
@@ -1,19 +1,18 @@
-using OpenTK;
+#region usings
+
+using OpenTK;
+
+#endregion
namespace SM.Base.Types
{
///
- /// A two-dimensional vector.
+ /// A two-dimensional vector.
///
public class CVector2 : CVector1
{
///
- /// Y-component
- ///
- public float Y { get; set; }
-
- ///
- /// Creates a vector, where each component is the same value.
+ /// Creates a vector, where each component is the same value.
///
/// The Value
public CVector2(float uniform) : base(uniform)
@@ -22,18 +21,25 @@ namespace SM.Base.Types
}
///
- /// Creates a vector
+ /// Creates a vector
///
public CVector2(float x, float y) : base(x)
{
Y = y;
}
+ ///
+ /// Y-component
+ ///
+ public float Y { get; set; }
+
+ ///
protected override float GetLengthProcess()
{
return base.GetLengthProcess() + Y * Y;
}
+ ///
protected override void NormalizationProcess(float length)
{
base.NormalizationProcess(length);
@@ -41,7 +47,7 @@ namespace SM.Base.Types
}
///
- /// Sets each component to the same value
+ /// Sets each component to the same value
///
///
public override void Set(float uniform, bool triggerChanged = true)
@@ -51,7 +57,7 @@ namespace SM.Base.Types
}
///
- /// Sets each component to the counter-part.
+ /// Sets each component to the counter-part.
///
///
public void Set(Vector2 vector, bool triggerChanged = true)
@@ -60,7 +66,7 @@ namespace SM.Base.Types
}
///
- /// Sets the a own value to each component.
+ /// Sets the a own value to each component.
///
///
///
@@ -70,17 +76,29 @@ namespace SM.Base.Types
base.Set(x, triggerChanged);
}
+ ///
public override void Add(float uniform, bool triggerChanged = true)
{
Y += uniform;
base.Add(uniform, triggerChanged);
}
+ ///
+ /// Adds to the CVector.
+ ///
+ ///
+ /// If false, the event Changed doesn't gets triggered
public void Add(Vector2 vector, bool triggerChanged = true)
{
Add(vector.X, vector.Y, triggerChanged);
}
+ ///
+ /// Adds the values to the CVector.
+ ///
+ ///
+ ///
+ /// If false, the event Changed doesn't gets triggered
public void Add(float x, float y, bool triggerChanged = true)
{
Y += y;
@@ -88,12 +106,19 @@ namespace SM.Base.Types
}
///
- /// Converts to
+ /// Converts to
///
- public static implicit operator Vector2(CVector2 vector2) => new Vector2(vector2.X, vector2.Y);
+ public static implicit operator Vector2(CVector2 vector2)
+ {
+ return new Vector2(vector2.X, vector2.Y);
+ }
+
///
- /// Converts from to .
+ /// Converts from to .
///
- public static implicit operator CVector2(Vector2 vector2) => new CVector2(vector2.X, vector2.Y);
+ public static implicit operator CVector2(Vector2 vector2)
+ {
+ return new CVector2(vector2.X, vector2.Y);
+ }
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Types/CVector3.cs b/SMCode/SM.Base/Types/CVector3.cs
index 6510bcd..fb42916 100644
--- a/SMCode/SM.Base/Types/CVector3.cs
+++ b/SMCode/SM.Base/Types/CVector3.cs
@@ -1,38 +1,45 @@
-using OpenTK;
+#region usings
+
+using OpenTK;
+
+#endregion
namespace SM.Base.Types
{
///
- /// A three-dimensional vector.
+ /// A three-dimensional vector.
///
public class CVector3 : CVector2
{
///
- /// Z-component
- ///
- public float Z { get; set; }
-
- ///
- /// Creates a vector, where each component is the same value.
+ /// Creates a vector, where each component is the same value.
///
/// The Value
public CVector3(float uniform) : base(uniform)
{
Z = uniform;
}
+
///
- /// Creates a vector
+ /// Creates a vector
///
public CVector3(float x, float y, float z) : base(x, y)
{
Z = z;
}
+ ///
+ /// Z-component
+ ///
+ public float Z { get; set; }
+
+ ///
protected override float GetLengthProcess()
{
return base.GetLengthProcess() + Z * Z;
}
+ ///
protected override void NormalizationProcess(float length)
{
base.NormalizationProcess(length);
@@ -47,15 +54,16 @@ namespace SM.Base.Types
}
///
- /// Sets the a own value to each component.
+ /// Sets the a own value to each component.
///
public void Set(float x, float y, float z, bool triggerChanged = true)
{
Z = z;
- base.Set(x,y, triggerChanged);
+ base.Set(x, y, triggerChanged);
}
+
///
- /// Sets each component to the counter-part.
+ /// Sets each component to the counter-part.
///
///
public void Set(Vector3 vector, bool triggerChanged = true)
@@ -63,30 +71,50 @@ namespace SM.Base.Types
Set(vector.X, vector.Y, vector.Z, triggerChanged);
}
+ ///
public override void Add(float uniform, bool triggerChanged = true)
{
Z += uniform;
base.Add(uniform, triggerChanged);
}
+ ///
+ /// Adds a to the CVector.
+ ///
+ ///
+ /// If false, the event Changed doesn't gets triggered
public void Add(Vector3 vector, bool triggerChanged = true)
{
Add(vector.X, vector.Y, vector.Z, triggerChanged);
}
+ ///
+ /// Adds the values to the CVector.
+ ///
+ ///
+ ///
+ ///
+ /// If false, the event Changed doesn't gets triggered
public void Add(float x, float y, float z, bool triggerChanged = true)
{
Z += z;
- base.Add(x,y, triggerChanged);
+ base.Add(x, y, triggerChanged);
}
///
- /// Converts to
+ /// Converts to
///
- public static implicit operator Vector3(CVector3 vector) => new Vector3(vector.X, vector.Y, vector.Z);
+ public static implicit operator Vector3(CVector3 vector)
+ {
+ return new Vector3(vector.X, vector.Y, vector.Z);
+ }
+
///
- /// Converts from to .
+ /// Converts from to .
///
- public static implicit operator CVector3(Vector3 vector) => new CVector3(vector.X, vector.Y, vector.Z);
+ public static implicit operator CVector3(Vector3 vector)
+ {
+ return new CVector3(vector.X, vector.Y, vector.Z);
+ }
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Utility/Assembly.cs b/SMCode/SM.Base/Utility/Assembly.cs
index 5f93981..e60c199 100644
--- a/SMCode/SM.Base/Utility/Assembly.cs
+++ b/SMCode/SM.Base/Utility/Assembly.cs
@@ -6,7 +6,7 @@ using System.Reflection;
#endregion
-namespace SM.Utility
+namespace SM.Base.Utility
{
///
/// Contains utility functions for handling with assemblies.
diff --git a/SMCode/SM.Base/Utility/Deltatime.cs b/SMCode/SM.Base/Utility/Deltatime.cs
index 125ab79..3e9248f 100644
--- a/SMCode/SM.Base/Utility/Deltatime.cs
+++ b/SMCode/SM.Base/Utility/Deltatime.cs
@@ -1,4 +1,4 @@
-namespace SM.Utility
+namespace SM.Base.Utility
{
///
/// A assistant to control the delta time.
diff --git a/SMCode/SM.Base/Utility/IInitializable.cs b/SMCode/SM.Base/Utility/IInitializable.cs
index 325222a..f5e0ce4 100644
--- a/SMCode/SM.Base/Utility/IInitializable.cs
+++ b/SMCode/SM.Base/Utility/IInitializable.cs
@@ -1,5 +1,8 @@
-namespace SM.Utility
+namespace SM.Base.Utility
{
+ ///
+ ///
+ ///
public interface IInitializable
{
bool IsInitialized { get; set; }
diff --git a/SMCode/SM.Base/Utility/Randomize.cs b/SMCode/SM.Base/Utility/Randomize.cs
index e0f2c81..e9c8c64 100644
--- a/SMCode/SM.Base/Utility/Randomize.cs
+++ b/SMCode/SM.Base/Utility/Randomize.cs
@@ -1,13 +1,11 @@
#region usings
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics;
#endregion
-namespace SM.Utility
+namespace SM.Base.Utility
{
///
/// A global helper class for randomization.
@@ -85,7 +83,7 @@ namespace SM.Utility
}
///
- /// Gets a random item from the provided list.
+ /// Gets a random item from the provided list.
///
public static TSource GetRandomItem(this IList list)
{
diff --git a/SMCode/SM.Base/Utility/Ray.cs b/SMCode/SM.Base/Utility/Ray.cs
index de3568c..eedd076 100644
--- a/SMCode/SM.Base/Utility/Ray.cs
+++ b/SMCode/SM.Base/Utility/Ray.cs
@@ -1,11 +1,12 @@
-using System;
-using System.Windows;
+#region usings
+
+using System;
using OpenTK;
-using SM.Base.Drawing;
-using SM.Base.Scene;
using SM.OGL.Mesh;
-namespace SM.Utility
+#endregion
+
+namespace SM.Base.Utility
{
public struct Ray
{
@@ -23,9 +24,9 @@ namespace SM.Utility
distance = 0.0f;
float tMin = 0.0f;
float tMax = 100000.0f;
-
+
Vector3 delta = modelMatrix.Row3.Xyz - Position;
-
+
for (int i = 0; i < 3; i++)
{
Vector3 axis = new Vector3(modelMatrix[i, 0], modelMatrix[i, 1], modelMatrix[i, 2]);
@@ -35,7 +36,6 @@ namespace SM.Utility
if (Math.Abs(f) > 0.001f)
{
-
float t1 = (e + box.Min[i]) / f;
float t2 = (e + box.Max[i]) / f;
@@ -54,7 +54,7 @@ namespace SM.Utility
}
else
{
- if (-e + box.Min[i] > 0.0f || -e + box.Max[i] < 0.0f)
+ if (-e + box.Min[i] > 0.0f || -e + box.Max[i] < 0.0f)
return false;
}
}
diff --git a/SMCode/SM.Base/Utility/RotationUtility.cs b/SMCode/SM.Base/Utility/RotationUtility.cs
index 719b779..6bc7698 100644
--- a/SMCode/SM.Base/Utility/RotationUtility.cs
+++ b/SMCode/SM.Base/Utility/RotationUtility.cs
@@ -5,7 +5,7 @@ using OpenTK;
#endregion
-namespace SM.Utility
+namespace SM.Base.Utility
{
///
/// Utilitys for rotations
diff --git a/SMCode/SM.Base/Utility/ShaderUtility.cs b/SMCode/SM.Base/Utility/ShaderUtility.cs
index b51eb32..e64826f 100644
--- a/SMCode/SM.Base/Utility/ShaderUtility.cs
+++ b/SMCode/SM.Base/Utility/ShaderUtility.cs
@@ -1,7 +1,6 @@
-namespace SM.Utility
+namespace SM.Base.Utility
{
public class ShaderUtility
{
-
}
}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Utility/Util.cs b/SMCode/SM.Base/Utility/Util.cs
index f36121e..a205074 100644
--- a/SMCode/SM.Base/Utility/Util.cs
+++ b/SMCode/SM.Base/Utility/Util.cs
@@ -1,6 +1,10 @@
-using System;
+#region usings
-namespace SM.Utility
+using System;
+
+#endregion
+
+namespace SM.Base.Utility
{
public class Util
{
@@ -11,6 +15,7 @@ namespace SM.Utility
obj.Initialization();
obj.IsInitialized = true;
}
+
obj.Activate();
}
diff --git a/SMCode/SM.Base/Window/Contexts/DrawContext.cs b/SMCode/SM.Base/Window/Contexts/DrawContext.cs
index 7f32c6a..5b3a5b4 100644
--- a/SMCode/SM.Base/Window/Contexts/DrawContext.cs
+++ b/SMCode/SM.Base/Window/Contexts/DrawContext.cs
@@ -1,11 +1,16 @@
-using System.Collections.Generic;
+#region usings
+
+using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using SM.Base.Drawing;
using SM.Base.Scene;
+using SM.Base.Shaders;
using SM.OGL.Mesh;
-namespace SM.Base.Windows
+#endregion
+
+namespace SM.Base.Window
{
public struct DrawContext
{
diff --git a/SMCode/SM.Base/Window/Contexts/UpdateContext.cs b/SMCode/SM.Base/Window/Contexts/UpdateContext.cs
index be0e7a6..39d9084 100644
--- a/SMCode/SM.Base/Window/Contexts/UpdateContext.cs
+++ b/SMCode/SM.Base/Window/Contexts/UpdateContext.cs
@@ -1,7 +1,10 @@
-using OpenTK.Input;
+#region usings
+
using SM.Base.Scene;
-namespace SM.Base.Windows
+#endregion
+
+namespace SM.Base.Window
{
public struct UpdateContext
{
diff --git a/SMCode/SM.Base/Window/GLWindow.cs b/SMCode/SM.Base/Window/GLWindow.cs
index 6f2521a..2df6521 100644
--- a/SMCode/SM.Base/Window/GLWindow.cs
+++ b/SMCode/SM.Base/Window/GLWindow.cs
@@ -1,20 +1,39 @@
-using System;
-using System.Windows;
+#region usings
+
+using System;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
-using SM.Base.Controls;
using SM.Base.Scene;
using SM.OGL;
using Mouse = SM.Base.Controls.Mouse;
-namespace SM.Base.Windows
+#endregion
+
+namespace SM.Base.Window
{
public class GLWindow : GameWindow, IGenericWindow
{
private Vector2 _flagWindowSize;
+ public WindowFlags WindowFlags;
+
+ public GLWindow() : this(1280, 720, "Generic OpenGL Title", WindowFlags.Window)
+ {
+ }
+
+ public GLWindow(int width, int height, string title, WindowFlags flags, VSyncMode vSync = VSyncMode.On) :
+ base(width, height, default, title, (GameWindowFlags) flags, DisplayDevice.Default,
+ GLSettings.ForcedVersion.MajorVersion, GLSettings.ForcedVersion.MinorVersion,
+ GraphicsContextFlags.Default)
+ {
+ VSync = vSync;
+ _flagWindowSize = new Vector2(width, height);
+
+ ChangeWindowFlag(flags);
+ }
+
public bool Loading { get; private set; } = true;
public float AspectRatio { get; set; }
@@ -29,78 +48,12 @@ namespace SM.Base.Windows
public ISetup AppliedSetup { get; private set; }
public event Action Resize;
public event Action Load;
- public event Action Loaded;
public GenericScene CurrentScene { get; private set; }
public RenderPipeline CurrentRenderPipeline { get; private set; }
- public WindowFlags WindowFlags;
-
- public GLWindow() : this(1280, 720, "Generic OpenGL Title", WindowFlags.Window) {}
-
- public GLWindow(int width, int height, string title, WindowFlags flags, VSyncMode vSync = VSyncMode.On) :
- base(width, height, default, title, (GameWindowFlags)flags, DisplayDevice.Default, GLSettings.ForcedVersion.MajorVersion, GLSettings.ForcedVersion.MinorVersion, GraphicsContextFlags.Default)
- {
- VSync = vSync;
- _flagWindowSize = new Vector2(width, height);
-
- ChangeWindowFlag(flags);
- }
-
- protected override void OnLoad(EventArgs e)
- {
- WindowCode.Load(this);
- SMRenderer.CurrentWindow = this;
-
- base.OnLoad(e);
- }
-
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
-
- WindowCode.Resize(this);
-
- if (WindowFlags == WindowFlags.Window) _flagWindowSize = WindowSize;
-
- if (Loading)
- {
- Loading = false;
- Loaded?.Invoke(this);
- AppliedSetup?.Loaded(this);
- }
- }
-
- protected override void OnUpdateFrame(FrameEventArgs e)
- {
- if (!Focused && !UpdateWhileUnfocused) return;
-
- base.OnUpdateFrame(e);
-
- WindowCode.Update(this, (float)e.Time);
- }
-
-
- protected override void OnRenderFrame(FrameEventArgs e)
- {
- base.OnRenderFrame(e);
-
- WindowCode.Render(this, (float)e.Time);
-
- SwapBuffers();
-
- GLDebugging.CheckGLErrors();
- }
-
- protected override void OnMouseMove(MouseMoveEventArgs e)
- {
- base.OnMouseMove(e);
- Mouse.MouseMoveEvent(e, this);
- }
-
public void Update(UpdateContext context)
{
-
}
public void ApplySetup(ISetup setup)
@@ -133,9 +86,68 @@ namespace SM.Base.Windows
CurrentRenderPipeline = renderPipeline;
}
- public void TriggerLoad() => Load?.Invoke(this);
+ public void TriggerLoad()
+ {
+ Load?.Invoke(this);
+ }
- public void TriggerResize() => Resize?.Invoke(this);
+ public void TriggerResize()
+ {
+ Resize?.Invoke(this);
+ }
+
+ public event Action Loaded;
+
+ protected override void OnLoad(EventArgs e)
+ {
+ WindowCode.Load(this);
+ SMRenderer.CurrentWindow = this;
+
+ base.OnLoad(e);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+
+ WindowCode.Resize(this);
+
+ if (WindowFlags == WindowFlags.Window) _flagWindowSize = WindowSize;
+
+ if (Loading)
+ {
+ Loading = false;
+ Loaded?.Invoke(this);
+ AppliedSetup?.Loaded(this);
+ }
+ }
+
+ protected override void OnUpdateFrame(FrameEventArgs e)
+ {
+ if (!Focused && !UpdateWhileUnfocused) return;
+
+ base.OnUpdateFrame(e);
+
+ WindowCode.Update(this, (float) e.Time);
+ }
+
+
+ protected override void OnRenderFrame(FrameEventArgs e)
+ {
+ base.OnRenderFrame(e);
+
+ WindowCode.Render(this, (float) e.Time);
+
+ SwapBuffers();
+
+ GLDebugging.CheckGLErrors();
+ }
+
+ protected override void OnMouseMove(MouseMoveEventArgs e)
+ {
+ base.OnMouseMove(e);
+ Mouse.MouseMoveEvent(e, this);
+ }
public void ChangeWindowFlag(WindowFlags newFlag)
{
@@ -144,14 +156,14 @@ namespace SM.Base.Windows
switch (newFlag)
{
case WindowFlags.Window:
- Width = (int)_flagWindowSize.X;
- Height = (int)_flagWindowSize.Y;
+ Width = (int) _flagWindowSize.X;
+ Height = (int) _flagWindowSize.Y;
WindowBorder = WindowBorder.Resizable;
break;
case WindowFlags.BorderlessWindow:
WindowBorder = WindowBorder.Hidden;
-
+
X = Screen.PrimaryScreen.Bounds.Left;
Y = Screen.PrimaryScreen.Bounds.Top;
Width = Screen.PrimaryScreen.Bounds.Width;
diff --git a/SMCode/SM.Base/Window/IGenericWindow.cs b/SMCode/SM.Base/Window/IGenericWindow.cs
index 7d653ea..a6b0f3a 100644
--- a/SMCode/SM.Base/Window/IGenericWindow.cs
+++ b/SMCode/SM.Base/Window/IGenericWindow.cs
@@ -1,11 +1,14 @@
-using System;
+#region usings
+
+using System;
using System.Drawing;
using OpenTK;
-using SM.Base.Controls;
using SM.Base.Scene;
using SM.OGL.Framebuffer;
-namespace SM.Base.Windows
+#endregion
+
+namespace SM.Base.Window
{
public interface IGenericWindow : IFramebufferWindow
{
@@ -26,12 +29,12 @@ namespace SM.Base.Windows
ISetup AppliedSetup { get; }
- event Action Resize;
- event Action Load;
-
GenericScene CurrentScene { get; }
RenderPipeline CurrentRenderPipeline { get; }
+ event Action Resize;
+ event Action Load;
+
void Update(UpdateContext context);
void ApplySetup(ISetup setup);
diff --git a/SMCode/SM.Base/Window/ISetup.cs b/SMCode/SM.Base/Window/ISetup.cs
index 9b10c0c..2756f58 100644
--- a/SMCode/SM.Base/Window/ISetup.cs
+++ b/SMCode/SM.Base/Window/ISetup.cs
@@ -1,4 +1,4 @@
-namespace SM.Base.Windows
+namespace SM.Base.Window
{
public interface ISetup
{
diff --git a/SMCode/SM.Base/Window/RenderPipeline.cs b/SMCode/SM.Base/Window/RenderPipeline.cs
index f209cba..9c68143 100644
--- a/SMCode/SM.Base/Window/RenderPipeline.cs
+++ b/SMCode/SM.Base/Window/RenderPipeline.cs
@@ -1,11 +1,16 @@
-using System.Collections.Generic;
+#region usings
+
+using System.Collections.Generic;
using System.Threading;
using SM.Base.Drawing;
+using SM.Base.Shaders;
+using SM.Base.Utility;
using SM.OGL.Framebuffer;
using SM.OGL.Texture;
-using SM.Utility;
-namespace SM.Base.Windows
+#endregion
+
+namespace SM.Base.Window
{
public abstract class RenderPipeline : IInitializable
{
@@ -20,25 +25,8 @@ namespace SM.Base.Windows
public bool IsInitialized { get; set; }
- internal void Render(ref DrawContext context) => RenderProcess(ref context);
-
- protected abstract void RenderProcess(ref DrawContext context);
-
- public virtual void Resize()
- {
- if (Framebuffers == null) return;
- foreach(var framebuffer in Framebuffers)
- framebuffer.Dispose();
-
- Thread.Sleep(50);
-
- foreach(var framebuffer in Framebuffers)
- framebuffer.Compile();
- }
-
public virtual void Activate()
{
-
}
public virtual void Initialization()
@@ -47,13 +35,34 @@ namespace SM.Base.Windows
DefaultShader ??= SMRenderer.DefaultMaterialShader;
}
+ internal void Render(ref DrawContext context)
+ {
+ RenderProcess(ref context);
+ }
+
+ protected abstract void RenderProcess(ref DrawContext context);
+
+ public virtual void Resize()
+ {
+ if (Framebuffers == null) return;
+ foreach (var framebuffer in Framebuffers)
+ framebuffer.Dispose();
+
+ Thread.Sleep(50);
+
+ foreach (var framebuffer in Framebuffers)
+ framebuffer.Compile();
+ }
+
public Framebuffer CreateWindowFramebuffer(int multisamples = 0)
{
- Framebuffer framebuffer = new Framebuffer(window: ConnectedWindow);
+ Framebuffer framebuffer = new Framebuffer(ConnectedWindow);
framebuffer.Append("color", new ColorAttachment(0, PixelInformation.RGBA_LDR, multisamples));
+
RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth;
depthAttach.Multisample = multisamples;
framebuffer.AppendRenderbuffer(depthAttach);
+
return framebuffer;
}
}
diff --git a/SMCode/SM.Base/Window/WindowCode.cs b/SMCode/SM.Base/Window/WindowCode.cs
index a232672..0389b09 100644
--- a/SMCode/SM.Base/Window/WindowCode.cs
+++ b/SMCode/SM.Base/Window/WindowCode.cs
@@ -1,7 +1,7 @@
-using System;
-using System.Collections.Generic;
+#region usings
+
+using System;
using System.Linq;
-using System.Runtime.CompilerServices;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Input;
@@ -9,13 +9,16 @@ using SM.Base.Drawing;
using SM.Base.Objects.Static;
using SM.Base.PostProcess;
using SM.Base.Scene;
-using SM.Base.ShaderExtension;
+using SM.Base.Shaders.Extensions;
using SM.Base.Time;
+using SM.Base.Utility;
using SM.OGL;
-using SM.Utility;
using Keyboard = SM.Base.Controls.Keyboard;
+using Mouse = SM.Base.Controls.Mouse;
-namespace SM.Base.Windows
+#endregion
+
+namespace SM.Base.Window
{
internal class WindowCode
{
@@ -69,19 +72,16 @@ namespace SM.Base.Windows
internal static void Update(IGenericWindow window, float deltatime)
{
Deltatime.UpdateDelta = deltatime;
- SM.Base.Controls.Mouse.SetState();
- Controls.Keyboard.SetStage();
- var context = new UpdateContext()
+ Mouse.SetState();
+ Keyboard.SetStage();
+ var context = new UpdateContext
{
Window = window,
Scene = window.CurrentScene
};
- if (Keyboard.IsDown(Key.AltLeft) && Keyboard.IsDown(Key.F4))
- {
- window.Close();
- }
+ if (Keyboard.IsDown(Key.AltLeft) && Keyboard.IsDown(Key.F4)) window.Close();
Stopwatch.PerformTicks(context);
window.CurrentScene?.Update(context);
@@ -97,7 +97,7 @@ namespace SM.Base.Windows
GLObject.DisposeMarkedObjects();
Deltatime.RenderDelta = deltatime;
- var drawContext = new DrawContext()
+ var drawContext = new DrawContext
{
Window = window,
Scene = window.CurrentScene,
@@ -110,7 +110,7 @@ namespace SM.Base.Windows
TextureMatrix = Matrix3.Identity,
Instances = new Instance[1]
{
- new Instance() {ModelMatrix = Matrix4.Identity, TextureMatrix = Matrix3.Identity}
+ new Instance {ModelMatrix = Matrix4.Identity, TextureMatrix = Matrix3.Identity}
}
};
drawContext.SetCamera(window.ViewportCamera);
diff --git a/SMCode/SM.Base/Window/WindowFlags.cs b/SMCode/SM.Base/Window/WindowFlags.cs
index 93cf62a..5be3d2f 100644
--- a/SMCode/SM.Base/Window/WindowFlags.cs
+++ b/SMCode/SM.Base/Window/WindowFlags.cs
@@ -1,4 +1,4 @@
-namespace SM.Base.Windows
+namespace SM.Base.Window
{
public enum WindowFlags
{
diff --git a/SMCode/SM.Base/packages.config b/SMCode/SM.Base/packages.config
index 87df345..bf47353 100644
--- a/SMCode/SM.Base/packages.config
+++ b/SMCode/SM.Base/packages.config
@@ -1,7 +1,8 @@
+
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/SMCode/SM.OGL/Framebuffer/ColorAttachment.cs b/SMCode/SM.OGL/Framebuffer/ColorAttachment.cs
index 3ef152b..0d8d749 100644
--- a/SMCode/SM.OGL/Framebuffer/ColorAttachment.cs
+++ b/SMCode/SM.OGL/Framebuffer/ColorAttachment.cs
@@ -38,6 +38,9 @@ namespace SM.OGL.Framebuffer
///
public DrawBuffersEnum DrawBuffersEnum => DrawBuffersEnum.ColorAttachment0 + AttachmentID;
+ ///
+ /// Returns true, if multisamples are above 0.
+ ///
public bool IsMultisampled => _multisamples > 0;
///
diff --git a/SMCode/SM.OGL/Framebuffer/Framebuffer.cs b/SMCode/SM.OGL/Framebuffer/Framebuffer.cs
index 0c7e364..cbf5eae 100644
--- a/SMCode/SM.OGL/Framebuffer/Framebuffer.cs
+++ b/SMCode/SM.OGL/Framebuffer/Framebuffer.cs
@@ -14,7 +14,7 @@ namespace SM.OGL.Framebuffer
///
public class Framebuffer : GLObject
{
- protected override bool AutoCompile { get; } = true;
+ protected override bool AutoCompile { get; set; } = true;
///
/// Represents the screen buffer.
@@ -22,11 +22,9 @@ namespace SM.OGL.Framebuffer
public static readonly Framebuffer Screen = new Framebuffer
{
_id = 0,
- _canBeCompiled = false
+ CanCompile = false,
};
-
- private bool _canBeCompiled = true;
-
+
private IFramebufferWindow _window;
private float _windowScale;
@@ -77,8 +75,6 @@ namespace SM.OGL.Framebuffer
///
public override void Compile()
{
- if (!_canBeCompiled) return;
-
if (_window != null) Size = new Vector2(_window.Width * _windowScale, _window.Height * _windowScale);
base.Compile();
@@ -181,7 +177,7 @@ namespace SM.OGL.Framebuffer
{
Framebuffer buffer = new Framebuffer()
{
- _canBeCompiled = false,
+ CanCompile = false,
ReportAsNotCompiled = true
};
switch (target)
diff --git a/SMCode/SM.OGL/Framebuffer/IFramebufferWindow.cs b/SMCode/SM.OGL/Framebuffer/IFramebufferWindow.cs
index 43ce0b5..a6278b5 100644
--- a/SMCode/SM.OGL/Framebuffer/IFramebufferWindow.cs
+++ b/SMCode/SM.OGL/Framebuffer/IFramebufferWindow.cs
@@ -1,5 +1,8 @@
namespace SM.OGL.Framebuffer
{
+ ///
+ /// A interface, so the framebuffer system can react to changes of windows.
+ ///
public interface IFramebufferWindow
{
int Width { get; }
diff --git a/SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs b/SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs
index e7cf6bf..3988bb4 100644
--- a/SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs
+++ b/SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs
@@ -2,15 +2,33 @@
namespace SM.OGL.Framebuffer
{
+ ///
+ /// Describes a renderbuffer attachment.
+ ///
public struct RenderbufferAttachment
{
+ ///
+ /// Preset for the depthbuffer attachment.
+ ///
public static readonly RenderbufferAttachment Depth = new RenderbufferAttachment(RenderbufferStorage.Depth24Stencil8, FramebufferAttachment.DepthStencilAttachment);
-
+
+ ///
+ /// Storage describes the internal format for the renderbuffer.
+ ///
public RenderbufferStorage Storage;
+ ///
+ /// FramebufferAttachment describes the attachment for the framebuffer.
+ ///
public FramebufferAttachment FramebufferAttachment;
+ ///
+ /// This contains the amount of multisampling for the attachment.
+ ///
public int Multisample;
+ ///
+ /// Constructor
+ ///
public RenderbufferAttachment(RenderbufferStorage storage, FramebufferAttachment framebufferAttachment, int multisample = 0)
{
Storage = storage;
@@ -18,18 +36,23 @@ namespace SM.OGL.Framebuffer
Multisample = multisample;
}
+ ///
+ /// This generates the renderbuffer for the framebuffer to add.
+ ///
+ /// The framebuffer
+ /// The ID of the renderbuffer.
public int Generate(Framebuffer f)
{
- int rbo = GL.GenRenderbuffer();
+ int rb = GL.GenRenderbuffer();
- GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, rbo);
+ GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, rb);
if (Multisample != 0)
GL.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, Multisample, Storage, (int)f.Size.X, (int)f.Size.Y);
else
GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, Storage, (int)f.Size.X, (int)f.Size.Y);
GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0);
- return rbo;
+ return rb;
}
}
}
\ No newline at end of file
diff --git a/SMCode/SM.OGL/GLObject.cs b/SMCode/SM.OGL/GLObject.cs
index 0afaf59..a2a7096 100644
--- a/SMCode/SM.OGL/GLObject.cs
+++ b/SMCode/SM.OGL/GLObject.cs
@@ -1,9 +1,8 @@
#region usings
-using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Runtime.InteropServices;
+using OpenTK.Audio;
using OpenTK.Graphics.OpenGL4;
#endregion
@@ -16,6 +15,7 @@ namespace SM.OGL
public abstract class GLObject
{
private static List _disposableObjects = new List();
+ private string _name = "";
protected bool ReportAsNotCompiled;
@@ -23,17 +23,29 @@ namespace SM.OGL
/// Contains the OpenGL ID
///
protected int _id = -1;
+
+ protected bool CanCompile = true;
///
/// If true, the system will call "Compile()", when "ID" is tried to get, but the id is still -1.
///
- protected virtual bool AutoCompile { get; } = false;
+ protected virtual bool AutoCompile { get; set; } = false;
///
/// Checks if the object was compiled.
///
public bool WasCompiled => _id > 0 && !ReportAsNotCompiled;
+ public string Name
+ {
+ get => _name;
+ set
+ {
+ _name = value;
+ if (GLSystem.Debugging && WasCompiled) GL.ObjectLabel(TypeIdentifier, _id, _name.Length, _name);
+ }
+ }
+
///
/// Returns the id for this object.
/// It will auto compile, if needed and allowed.
@@ -55,7 +67,21 @@ namespace SM.OGL
[DebuggerStepThrough]
private void PerformCompile()
{
+ if (!CanCompile) return;
+
Compile();
+
+ if (GLSystem.Debugging && string.IsNullOrEmpty(_name))
+ {
+ try
+ {
+ GL.ObjectLabel(TypeIdentifier, _id, _name.Length, _name);
+ }
+ catch
+ {
+ // ignore
+ }
+ }
}
///
@@ -85,13 +111,9 @@ namespace SM.OGL
Compile();
}
- ///
- /// Names the object for debugging.
- ///
- ///
- public void Name(string name)
+ public override string ToString()
{
- if (GLSystem.Debugging) GL.ObjectLabel(TypeIdentifier, _id, name.Length, name);
+ return $"{GetType().Name} {(string.IsNullOrEmpty(_name) ? "" : $"\"{_name}\" ")}[{_id}]";
}
public static void DisposeMarkedObjects()
diff --git a/SMCode/SM.OGL/Mesh/BoundingBox.cs b/SMCode/SM.OGL/Mesh/BoundingBox.cs
index 36c9de3..dec59c7 100644
--- a/SMCode/SM.OGL/Mesh/BoundingBox.cs
+++ b/SMCode/SM.OGL/Mesh/BoundingBox.cs
@@ -2,7 +2,6 @@
using System;
using OpenTK;
-using OpenTK.Graphics.OpenGL;
#endregion
diff --git a/SMCode/SM.OGL/Mesh/GenericMesh.cs b/SMCode/SM.OGL/Mesh/GenericMesh.cs
index 6f35434..d8f552a 100644
--- a/SMCode/SM.OGL/Mesh/GenericMesh.cs
+++ b/SMCode/SM.OGL/Mesh/GenericMesh.cs
@@ -1,7 +1,6 @@
#region usings
using System;
-using System.Collections.Generic;
using OpenTK.Graphics.OpenGL4;
#endregion
@@ -17,21 +16,8 @@ namespace SM.OGL.Mesh
public static int LastID { get; internal set; } = -1;
- ///
- /// Generates the AttribDataIndex
- ///
- protected GenericMesh()
- {
- Attributes = new MeshAttributeList()
- {
- {0, "vertex", Vertex},
- {1, "uv", UVs},
- {2, "normal", Normals}
- };
- }
-
///
- protected override bool AutoCompile { get; } = true;
+ protected override bool AutoCompile { get; set; } = true;
///
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.VertexArray;
@@ -72,6 +58,19 @@ namespace SM.OGL.Mesh
///
public virtual int[] Indices { get; set; }
+ ///
+ /// Generates the AttribDataIndex
+ ///
+ protected GenericMesh()
+ {
+ Attributes = new MeshAttributeList()
+ {
+ {0, "vertex", Vertex},
+ {1, "uv", UVs},
+ {2, "normal", Normals}
+ };
+ }
+
public void UpdateBoundingBox()
{
BoundingBox.Update(this);
diff --git a/SMCode/SM.OGL/Mesh/ILineMesh.cs b/SMCode/SM.OGL/Mesh/ILineMesh.cs
index 67d219d..de66a81 100644
--- a/SMCode/SM.OGL/Mesh/ILineMesh.cs
+++ b/SMCode/SM.OGL/Mesh/ILineMesh.cs
@@ -1,7 +1,13 @@
namespace SM.OGL.Mesh
{
+ ///
+ /// Represents a mesh that can be a line object.
+ ///
public interface ILineMesh
{
+ ///
+ /// The width of a line.
+ ///
float LineWidth { get; set; }
}
}
\ No newline at end of file
diff --git a/SMCode/SM.OGL/Mesh/MeshAttributeList.cs b/SMCode/SM.OGL/Mesh/MeshAttributeList.cs
index 0b492e6..5cbeb66 100644
--- a/SMCode/SM.OGL/Mesh/MeshAttributeList.cs
+++ b/SMCode/SM.OGL/Mesh/MeshAttributeList.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using OpenTK.Graphics.OpenGL;
+using System.Collections.Generic;
namespace SM.OGL.Mesh
{
diff --git a/SMCode/SM.OGL/Mesh/VBO.cs b/SMCode/SM.OGL/Mesh/VBO.cs
index 3348271..0bd3ac1 100644
--- a/SMCode/SM.OGL/Mesh/VBO.cs
+++ b/SMCode/SM.OGL/Mesh/VBO.cs
@@ -40,6 +40,10 @@ namespace SM.OGL.Mesh
///
public int PointerStride;
+ ///
+ /// The VBO gets ignored when true.
+ /// Default: true
+ ///
public bool Active = true;
///
diff --git a/SMCode/SM.OGL/Shaders/GenericShader.cs b/SMCode/SM.OGL/Shaders/GenericShader.cs
index 948f630..5ec6067 100644
--- a/SMCode/SM.OGL/Shaders/GenericShader.cs
+++ b/SMCode/SM.OGL/Shaders/GenericShader.cs
@@ -1,7 +1,6 @@
#region usings
using System;
-using System.Linq;
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Mesh;
@@ -15,7 +14,7 @@ namespace SM.OGL.Shaders
public abstract class GenericShader : GLObject
{
///
- protected override bool AutoCompile { get; } = true;
+ protected override bool AutoCompile { get; set; } = true;
///
/// Contains the different files for the shader.
@@ -97,7 +96,6 @@ namespace SM.OGL.Shaders
ShaderFileFiles.Append(this);
GL.LinkProgram(_id);
- Name(GetType().Name);
ShaderFileFiles.Detach(this);
Uniforms = new UniformCollection {ParentShader = this};
diff --git a/SMCode/SM.OGL/Shaders/ShaderFile.cs b/SMCode/SM.OGL/Shaders/ShaderFile.cs
index 6f10cde..5cb23f8 100644
--- a/SMCode/SM.OGL/Shaders/ShaderFile.cs
+++ b/SMCode/SM.OGL/Shaders/ShaderFile.cs
@@ -80,6 +80,7 @@ namespace SM.OGL.Shaders
for (var i = 0; i < GLSLExtensions.Count; i++) GLSLExtensions[i].Compile(shader, type);
}
+ ///
public override void Dispose()
{
GL.DeleteShader(this);
diff --git a/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs b/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs
index cfec97b..51e2c84 100644
--- a/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs
+++ b/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs
@@ -51,6 +51,12 @@ namespace SM.OGL.Shaders
Fragment = new []{fragment};
}
+ ///
+ /// Creates a collection with arrays of shader files.
+ ///
+ ///
+ ///
+ ///
public ShaderFileCollection(ShaderFile[] vertex, ShaderFile[] fragment, ShaderFile[] geometry = default)
{
Vertex = vertex;
diff --git a/SMCode/SM.OGL/Shaders/UniformArray.cs b/SMCode/SM.OGL/Shaders/UniformArray.cs
index 19c882b..2689851 100644
--- a/SMCode/SM.OGL/Shaders/UniformArray.cs
+++ b/SMCode/SM.OGL/Shaders/UniformArray.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using OpenTK.Graphics.OpenGL;
namespace SM.OGL.Shaders
{
diff --git a/SMCode/SM.OGL/Texture/PixelInformation.cs b/SMCode/SM.OGL/Texture/PixelInformation.cs
index ead9d7b..e52e75c 100644
--- a/SMCode/SM.OGL/Texture/PixelInformation.cs
+++ b/SMCode/SM.OGL/Texture/PixelInformation.cs
@@ -2,17 +2,47 @@
namespace SM.OGL.Texture
{
+ ///
+ /// Stores information how pixels are stored in textures.
+ ///
public struct PixelInformation
{
+ ///
+ /// RGB without Alpha channel, Low Dynamic Range (0 - 1)
+ ///
public static PixelInformation RGB_LDR = new PixelInformation(PixelInternalFormat.Rgb, PixelFormat.Rgb, PixelType.UnsignedByte);
+ ///
+ /// RGB without Alpha channel, High Dynamic Range (0 - n)
+ ///
public static PixelInformation RGB_HDR = new PixelInformation(PixelInternalFormat.Rgb16f, PixelFormat.Rgb, PixelType.Float);
+ ///
+ /// RGB with Alpha channel, Low Dynamic Range (0 - 1)
+ ///
public static PixelInformation RGBA_LDR = new PixelInformation(PixelInternalFormat.Rgba, PixelFormat.Rgba, PixelType.UnsignedByte);
+ ///
+ /// RGB with Alpha channel, High Dynamic Range (0 - n)
+ ///
public static PixelInformation RGBA_HDR = new PixelInformation(PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.Float);
+ ///
+ /// The internal format of the pixels.
+ ///
public PixelInternalFormat InternalFormat { get; }
+ ///
+ /// The format of the pixels.
+ ///
public PixelFormat Format { get; }
+ ///
+ /// The data type of the pixels,
+ ///
public PixelType DataType { get; }
+ ///
+ /// The constructor
+ ///
+ ///
+ ///
+ ///
public PixelInformation(PixelInternalFormat internalFormat, PixelFormat format, PixelType dataType)
{
InternalFormat = internalFormat;
diff --git a/SMCode/SM.OGL/Texture/TextureBase.cs b/SMCode/SM.OGL/Texture/TextureBase.cs
index 815b298..495fe74 100644
--- a/SMCode/SM.OGL/Texture/TextureBase.cs
+++ b/SMCode/SM.OGL/Texture/TextureBase.cs
@@ -12,14 +12,20 @@ namespace SM.OGL.Texture
public abstract class TextureBase : GLObject
{
///
- protected override bool AutoCompile { get; } = true;
+ protected override bool AutoCompile { get; set; } = true;
///
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Texture;
+ ///
+ /// Contains the specific information of each pixel.
+ ///
public PixelInformation PixelInformation;
+ ///
+ /// The target of the texture.
+ ///
public TextureTarget Target { get; set; } = TextureTarget.Texture2D;
///
@@ -44,6 +50,7 @@ namespace SM.OGL.Texture
///
public virtual int Height { get; protected set; }
+ ///
public override void Dispose()
{
GL.DeleteTexture(_id);
diff --git a/SMCode/SM2D/Controls/Mouse2D.cs b/SMCode/SM2D/Controls/Mouse2D.cs
index 4af280a..64d37f7 100644
--- a/SMCode/SM2D/Controls/Mouse2D.cs
+++ b/SMCode/SM2D/Controls/Mouse2D.cs
@@ -1,10 +1,7 @@
using System.Collections.Generic;
-using System.Windows.Controls;
using OpenTK;
using SM.Base.Controls;
-using SM.Base.Drawing;
using SM.Base.Scene;
-using SM.Utility;
using SM2D.Scene;
using SM2D.Types;
diff --git a/SMCode/SM2D/Drawing/DrawBackground.cs b/SMCode/SM2D/Drawing/DrawBackground.cs
index f939fb0..280381d 100644
--- a/SMCode/SM2D/Drawing/DrawBackground.cs
+++ b/SMCode/SM2D/Drawing/DrawBackground.cs
@@ -1,15 +1,12 @@
#region usings
-using System.Collections.Generic;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
-using SM.Base;
using SM.Base.Drawing;
-using SM.Base.Objects.Static;
using SM.Base.Scene;
using SM.Base.Textures;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM.OGL.Texture;
using SM2D.Scene;
diff --git a/SMCode/SM2D/Drawing/DrawObject2D.cs b/SMCode/SM2D/Drawing/DrawObject2D.cs
index b5e3121..81b4158 100644
--- a/SMCode/SM2D/Drawing/DrawObject2D.cs
+++ b/SMCode/SM2D/Drawing/DrawObject2D.cs
@@ -1,15 +1,11 @@
using System.Collections.Generic;
-using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
-using SM.Base;
using SM.Base.Drawing;
-using SM.Base.Objects;
+using SM.Base.Shaders;
using SM.Base.Textures;
-using SM.Base.Windows;
-using SM.OGL.Mesh;
+using SM.Base.Window;
using SM2D.Object;
-using SM2D.Scene;
using SM2D.Types;
namespace SM2D.Drawing
diff --git a/SMCode/SM2D/Drawing/DrawParticles.cs b/SMCode/SM2D/Drawing/DrawParticles.cs
index 2c2b135..c2e814e 100644
--- a/SMCode/SM2D/Drawing/DrawParticles.cs
+++ b/SMCode/SM2D/Drawing/DrawParticles.cs
@@ -1,8 +1,7 @@
using System;
using OpenTK;
using SM.Base.Drawing.Particles;
-using SM.Utility;
-using SM2D.Scene;
+using SM.Base.Utility;
using SM2D.Types;
namespace SM2D.Drawing
diff --git a/SMCode/SM2D/Drawing/DrawText.cs b/SMCode/SM2D/Drawing/DrawText.cs
index 79675dd..eba649c 100644
--- a/SMCode/SM2D/Drawing/DrawText.cs
+++ b/SMCode/SM2D/Drawing/DrawText.cs
@@ -1,10 +1,8 @@
#region usings
-using SM.Base;
using SM.Base.Drawing.Text;
using SM.Base.Types;
-using SM.Base.Windows;
-using SM2D.Scene;
+using SM.Base.Window;
using SM2D.Types;
#endregion
diff --git a/SMCode/SM2D/Object/PolyLine.cs b/SMCode/SM2D/Object/PolyLine.cs
index bf9c5d2..0a723ee 100644
--- a/SMCode/SM2D/Object/PolyLine.cs
+++ b/SMCode/SM2D/Object/PolyLine.cs
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using OpenTK;
-using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
-using SM.Base.Objects;
using SM.OGL.Mesh;
namespace SM2D.Object
@@ -16,8 +14,6 @@ namespace SM2D.Object
public class PolyLine : Polygon, ILineMesh
{
- public float LineWidth { get; set; } = 1;
-
public PolyLine(ICollection vertices, PolyLineType lineType = PolyLineType.NotConnected) : base(vertices)
{
UVs.Active = false;
diff --git a/SMCode/SM2D/Object/Polygon.cs b/SMCode/SM2D/Object/Polygon.cs
index 437edd9..85cee64 100644
--- a/SMCode/SM2D/Object/Polygon.cs
+++ b/SMCode/SM2D/Object/Polygon.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using OpenTK;
-using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
using SM.Base.Objects;
using SM.OGL.Mesh;
diff --git a/SMCode/SM2D/Pipelines/Basic2DPipeline.cs b/SMCode/SM2D/Pipelines/Basic2DPipeline.cs
index a6ad7a2..d3573e5 100644
--- a/SMCode/SM2D/Pipelines/Basic2DPipeline.cs
+++ b/SMCode/SM2D/Pipelines/Basic2DPipeline.cs
@@ -1,9 +1,5 @@
-using System;
-using OpenTK.Graphics.OpenGL4;
-using SM.Base;
-using SM.Base.Drawing;
-using SM.Base.Windows;
-using SM.OGL.Framebuffer;
+using SM.Base.Shaders;
+using SM.Base.Window;
using SM2D.Shader;
namespace SM2D.Pipelines
diff --git a/SMCode/SM2D/SM2D.csproj b/SMCode/SM2D/SM2D.csproj
index 1e8c488..96f1749 100644
--- a/SMCode/SM2D/SM2D.csproj
+++ b/SMCode/SM2D/SM2D.csproj
@@ -31,13 +31,9 @@
4
-
-
-
-
diff --git a/SMCode/SM2D/Scene/Camera.cs b/SMCode/SM2D/Scene/Camera.cs
index b66619b..916fd2e 100644
--- a/SMCode/SM2D/Scene/Camera.cs
+++ b/SMCode/SM2D/Scene/Camera.cs
@@ -1,12 +1,10 @@
#region usings
using System;
-using System.Runtime.Serialization.Formatters;
using OpenTK;
-using SM.Base;
using SM.Base.Scene;
using SM.Base.Types;
-using SM.Base.Windows;
+using SM.Base.Window;
#endregion
diff --git a/SMCode/SM2D/Scene/ItemCollection.cs b/SMCode/SM2D/Scene/ItemCollection.cs
index a6796af..bbe47eb 100644
--- a/SMCode/SM2D/Scene/ItemCollection.cs
+++ b/SMCode/SM2D/Scene/ItemCollection.cs
@@ -1,9 +1,8 @@
#region usings
-using SM.Base;
using SM.Base.Scene;
using SM.Base.Types;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM2D.Types;
#endregion
diff --git a/SMCode/SM2D/Scene/Scene.cs b/SMCode/SM2D/Scene/Scene.cs
index 74d3fe3..2fd4663 100644
--- a/SMCode/SM2D/Scene/Scene.cs
+++ b/SMCode/SM2D/Scene/Scene.cs
@@ -1,12 +1,10 @@
#region usings
-using System.Drawing.Drawing2D;
using OpenTK;
using OpenTK.Graphics;
-using SM.Base;
using SM.Base.Objects.Static;
using SM.Base.Scene;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM2D.Drawing;
#endregion
diff --git a/SMCode/SM2D/Shader/ShaderCollection.cs b/SMCode/SM2D/Shader/ShaderCollection.cs
index 92da6fe..a6837ba 100644
--- a/SMCode/SM2D/Shader/ShaderCollection.cs
+++ b/SMCode/SM2D/Shader/ShaderCollection.cs
@@ -1,7 +1,7 @@
-using SM.Base.Drawing;
-using SM.Base.Windows;
+using SM.Base.Shaders;
+using SM.Base.Utility;
+using SM.Base.Window;
using SM.OGL.Shaders;
-using SM.Utility;
namespace SM2D.Shader
{
diff --git a/SMCode/SM2D/Types/Transformation.cs b/SMCode/SM2D/Types/Transformation.cs
index 1930ed9..7fb80ee 100644
--- a/SMCode/SM2D/Types/Transformation.cs
+++ b/SMCode/SM2D/Types/Transformation.cs
@@ -1,13 +1,10 @@
#region usings
-using System;
-using System.Drawing.Drawing2D;
using OpenTK;
using SM.Base.Drawing;
-using SM.Base.Scene;
using SM.Base.Textures;
using SM.Base.Types;
-using SM.Utility;
+using SM.Base.Utility;
#endregion
diff --git a/SMCode/SM2D/Window/I2DSetup.cs b/SMCode/SM2D/Window/I2DSetup.cs
index 13cbd18..64bdf04 100644
--- a/SMCode/SM2D/Window/I2DSetup.cs
+++ b/SMCode/SM2D/Window/I2DSetup.cs
@@ -1,5 +1,5 @@
using OpenTK;
-using SM.Base.Windows;
+using SM.Base.Window;
namespace SM2D
{
diff --git a/SMCode/SM2D/Window/Window2DSetup.cs b/SMCode/SM2D/Window/Window2DSetup.cs
index b44ff93..9bb5360 100644
--- a/SMCode/SM2D/Window/Window2DSetup.cs
+++ b/SMCode/SM2D/Window/Window2DSetup.cs
@@ -1,9 +1,7 @@
-using System.Drawing.Drawing2D;
-using OpenTK;
+using OpenTK;
using OpenTK.Graphics.OpenGL4;
using SM.Base;
-using SM.Base.PostProcess;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM2D.Scene;
using SM2D.Shader;
diff --git a/SMOptionals/SM.Game/Controls/GameKeybind.cs b/SMOptionals/SM.Game/Controls/GameKeybind.cs
index 1b82c63..eb306c8 100644
--- a/SMOptionals/SM.Game/Controls/GameKeybind.cs
+++ b/SMOptionals/SM.Game/Controls/GameKeybind.cs
@@ -1,5 +1,4 @@
using System;
-using OpenTK.Input;
namespace SM.Game.Controls
{
diff --git a/SMOptionals/SM.Game/Controls/GameKeybindActor.cs b/SMOptionals/SM.Game/Controls/GameKeybindActor.cs
index 1f56234..c0527c3 100644
--- a/SMOptionals/SM.Game/Controls/GameKeybindActor.cs
+++ b/SMOptionals/SM.Game/Controls/GameKeybindActor.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using OpenTK.Input;
+using OpenTK.Input;
namespace SM.Game.Controls
{
diff --git a/SMOptionals/SM.Game/Controls/GameKeybindHost.cs b/SMOptionals/SM.Game/Controls/GameKeybindHost.cs
index 404a9bf..c1d57f6 100644
--- a/SMOptionals/SM.Game/Controls/GameKeybindHost.cs
+++ b/SMOptionals/SM.Game/Controls/GameKeybindHost.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using OpenTK.Input;
namespace SM.Game.Controls
{
diff --git a/SMOptionals/SM.Game/Controls/GameKeybindList.cs b/SMOptionals/SM.Game/Controls/GameKeybindList.cs
index 2305d1a..97662e1 100644
--- a/SMOptionals/SM.Game/Controls/GameKeybindList.cs
+++ b/SMOptionals/SM.Game/Controls/GameKeybindList.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using OpenTK.Input;
namespace SM.Game.Controls
{
diff --git a/SMOptionals/SM.Game/Properties/AssemblyInfo.cs b/SMOptionals/SM.Game/Properties/AssemblyInfo.cs
index c7c6aa5..ea53c24 100644
--- a/SMOptionals/SM.Game/Properties/AssemblyInfo.cs
+++ b/SMOptionals/SM.Game/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/SMOptionals/SM.Game/SM.Game.csproj b/SMOptionals/SM.Game/SM.Game.csproj
index 3b175c5..cf248b4 100644
--- a/SMOptionals/SM.Game/SM.Game.csproj
+++ b/SMOptionals/SM.Game/SM.Game.csproj
@@ -42,12 +42,6 @@
-
-
-
-
-
-
diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs
index e006a4b..fcb8015 100644
--- a/SM_TEST/Program.cs
+++ b/SM_TEST/Program.cs
@@ -1,9 +1,7 @@
-using System;
-using OpenTK;
-using OpenTK.Graphics;
+using OpenTK;
using OpenTK.Input;
using SM.Base;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM.Game.Controls;
using SM2D;
using SM2D.Drawing;
diff --git a/SM_TEST/Properties/AssemblyInfo.cs b/SM_TEST/Properties/AssemblyInfo.cs
index 65ced2c..f297dd2 100644
--- a/SM_TEST/Properties/AssemblyInfo.cs
+++ b/SM_TEST/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/SM_TEST/SM_TEST.csproj b/SM_TEST/SM_TEST.csproj
index b70f0eb..8658e18 100644
--- a/SM_TEST/SM_TEST.csproj
+++ b/SM_TEST/SM_TEST.csproj
@@ -45,12 +45,6 @@
-
-
-
-
-
-
diff --git a/SM_TEST/TestRenderPipeline.cs b/SM_TEST/TestRenderPipeline.cs
index 01b96d3..0a4512f 100644
--- a/SM_TEST/TestRenderPipeline.cs
+++ b/SM_TEST/TestRenderPipeline.cs
@@ -1,25 +1,25 @@
-using System.Collections.Generic;
-using OpenTK.Graphics.OpenGL4;
-using SM.Base;
-using SM.Base;
-using SM.Base.Drawing;
+using OpenTK.Graphics.OpenGL4;
using SM.Base.PostEffects;
-using SM.Base.Windows;
+using SM.Base.Window;
using SM.OGL.Framebuffer;
-using SM2D.Scene;
namespace SM_TEST
{
public class TestRenderPipeline : RenderPipeline
{
private BloomEffect _bloom;
+ private Framebuffer _postBuffer;
public override void Initialization()
{
- _bloom = new BloomEffect(hdr: true);
- MainFramebuffer = CreateWindowFramebuffer();
+ MainFramebuffer = CreateWindowFramebuffer(2);
+ _postBuffer = CreateWindowFramebuffer();
+ Framebuffers.Add(_postBuffer);
+
+
+ _bloom = new BloomEffect(_postBuffer, hdr: true);
_bloom.Initilize(this);
base.Initialization();
}
@@ -29,11 +29,13 @@ namespace SM_TEST
MainFramebuffer.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
context.Scene.DrawBackground(context);
context.Scene.DrawMainObjects(context);
+ context.Scene.DrawHUD(context);
+
+ PostProcessFinals.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
_bloom.Draw(context);
- context.Scene.DrawHUD(context);
context.Scene.DrawDebug(context);
}
}
diff --git a/SM_WPF_TEST/App.xaml.cs b/SM_WPF_TEST/App.xaml.cs
index 6a3f3c6..e481a44 100644
--- a/SM_WPF_TEST/App.xaml.cs
+++ b/SM_WPF_TEST/App.xaml.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
+using System.Windows;
namespace SM_WPF_TEST
{
diff --git a/SM_WPF_TEST/MainWindow.xaml.cs b/SM_WPF_TEST/MainWindow.xaml.cs
index ffd04ef..5ee0f90 100644
--- a/SM_WPF_TEST/MainWindow.xaml.cs
+++ b/SM_WPF_TEST/MainWindow.xaml.cs
@@ -1,22 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using OpenTK.Graphics;
-using SM2D;
-using SM2D.Drawing;
-using SM2D.Pipelines;
-using SM2D.Scene;
+using System.Windows;
namespace SM_WPF_TEST
{
diff --git a/SM_WPF_TEST/Properties/AssemblyInfo.cs b/SM_WPF_TEST/Properties/AssemblyInfo.cs
index 8702efa..499ad94 100644
--- a/SM_WPF_TEST/Properties/AssemblyInfo.cs
+++ b/SM_WPF_TEST/Properties/AssemblyInfo.cs
@@ -1,6 +1,4 @@
using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
diff --git a/SM_WPF_TEST/SM_WPF_TEST.csproj b/SM_WPF_TEST/SM_WPF_TEST.csproj
index 27ab8b3..3d7484c 100644
--- a/SM_WPF_TEST/SM_WPF_TEST.csproj
+++ b/SM_WPF_TEST/SM_WPF_TEST.csproj
@@ -35,20 +35,9 @@
4
-
- ..\packages\OpenTK.GLWpfControl.3.2.3\lib\net452\GLWpfControl.dll
-
-
- ..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll
-
-
-
-
-
-
4.0
@@ -109,19 +98,5 @@
-
-
- {8e733844-4204-43e7-b3dc-3913cddabb0d}
- SM.Base
-
-
- {f604d684-bc1d-4819-88b5-8b5d03a17be0}
- SM.OGL
-
-
- {a4565538-625a-42c6-a330-dd4f1abb3986}
- SM2D
-
-
\ No newline at end of file
diff --git a/SM_WPF_TEST/Window1.xaml.cs b/SM_WPF_TEST/Window1.xaml.cs
index 162cfc9..d5d3271 100644
--- a/SM_WPF_TEST/Window1.xaml.cs
+++ b/SM_WPF_TEST/Window1.xaml.cs
@@ -1,21 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-using OpenTK.Graphics;
-using SM2D;
-using SM2D.Drawing;
-using SM2D.Pipelines;
-using SM2D.Scene;
+using System.Windows;
namespace SM_WPF_TEST
{
diff --git a/SM_WPF_TEST/packages.config b/SM_WPF_TEST/packages.config
index c51d6ce..82cdaeb 100644
--- a/SM_WPF_TEST/packages.config
+++ b/SM_WPF_TEST/packages.config
@@ -1,5 +1,4 @@
-
\ No newline at end of file