#region usings using OpenTK.Graphics.OpenGL4; using SM.Base; using SM.Base.Windows; using SM.OGL.Mesh; using SM.OGL.Shaders; #endregion namespace SM.Base.Drawing { /// /// A general class to work with material shaders properly. /// public abstract class MaterialShader : GenericShader { /// protected MaterialShader(string combinedData) : base(combinedData) {} /// protected MaterialShader(string vertex, string fragment) : base(vertex, fragment) { } /// protected MaterialShader(ShaderFileCollection shaderFileFiles) : base(shaderFileFiles) { } /// /// Prepares the context for the drawing. /// /// The context public virtual void Draw(DrawContext context) { context.Shader.Activate(); context.Mesh.Activate(); if (context.Mesh is ILineMesh lineMesh) GL.LineWidth(context.Material.ShaderArguments.Get("LineWidth", lineMesh.LineWidth)); if (context.Material.Blending) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); } else GL.Disable(EnableCap.Blend); DrawProcess(context); CleanUp(); } /// /// Draws the context. /// /// protected abstract void DrawProcess(DrawContext context); } }