~ Moved code around in files. SM.Base: + PostProcessing-system + OnInitialization() for Scenes. + Shader-Extensions + Added option to not react while unfocused to the window. + Added Screenshots to the window. + Connected the log system to the SM.OGL-action system. ~ Replaced IShader with abstract MaterialShader. ~ When a log compression folder doesn't exist, it will create one. SM.OGL: + Added support for UniformArrays + Added ShaderPreProcessing + Added Shader Extensions. + Added Debug actions. + SM.OGL settings ~ Framebuffer Size is automaticly changed, when the window and scale is set. SM2D: + Added easy shader drawing.
84 lines
No EOL
2.4 KiB
C#
84 lines
No EOL
2.4 KiB
C#
#region usings
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using OpenTK.Graphics.OpenGL4;
|
|
|
|
#endregion
|
|
|
|
namespace SM.OGL.Mesh
|
|
{
|
|
/// <summary>
|
|
/// Contains information for meshes
|
|
/// </summary>
|
|
public abstract class GenericMesh : GLObject
|
|
{
|
|
/// <summary>
|
|
/// Generates the AttribDataIndex
|
|
/// </summary>
|
|
protected GenericMesh()
|
|
{
|
|
AttribDataIndex = new Dictionary<int, VBO>
|
|
{
|
|
{0, Vertex},
|
|
{1, UVs},
|
|
{2, Normals}
|
|
};
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override bool AutoCompile { get; } = true;
|
|
|
|
/// <inheritdoc />
|
|
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.VertexArray;
|
|
|
|
/// <summary>
|
|
/// The primitive type, that determinants how the mesh is drawn.
|
|
/// <para>Default: Triangles</para>
|
|
/// </summary>
|
|
public virtual PrimitiveType PrimitiveType { get; } = PrimitiveType.Triangles;
|
|
|
|
/// <summary>
|
|
/// Contains the vertices for the mesh.
|
|
/// </summary>
|
|
public virtual VBO Vertex { get; }
|
|
|
|
/// <summary>
|
|
/// Contains the texture coords for the mesh.
|
|
/// </summary>
|
|
public virtual VBO UVs { get; }
|
|
|
|
/// <summary>
|
|
/// Contains the normals for the mesh.
|
|
/// </summary>
|
|
public virtual VBO Normals { get; }
|
|
|
|
/// <summary>
|
|
/// Represents the bounding box.
|
|
/// </summary>
|
|
public virtual BoundingBox BoundingBox { get; } = new BoundingBox();
|
|
|
|
/// <summary>
|
|
/// Connects the different buffer objects with ids.
|
|
/// </summary>
|
|
public Dictionary<int, VBO> AttribDataIndex { get; }
|
|
|
|
/// <summary>
|
|
/// Stores indices for a more performance friendly method to draw objects.
|
|
/// </summary>
|
|
public virtual int[] Indices { get; set; }
|
|
|
|
/// <inheritdoc />
|
|
public override void Compile()
|
|
{
|
|
_id = GL.GenVertexArray();
|
|
GL.BindVertexArray(_id);
|
|
|
|
if (AttribDataIndex == null) throw new Exception("[Critical] The model requires a attribute data index.");
|
|
|
|
foreach (var kvp in AttribDataIndex) kvp.Value?.BindBuffer(kvp.Key);
|
|
|
|
GL.BindVertexArray(0);
|
|
}
|
|
}
|
|
} |