#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; #endregion namespace SM.Base.Window { /// /// The draw context contains (more or less) important information for drawing a object. /// public struct DrawContext { /// /// The window, the context came origionally. /// public IGenericWindow Window { get; internal set; } /// /// The scene, the context was send to. /// public GenericScene Scene { get; internal set; } /// /// The render pipeline, the context is using. /// public RenderPipeline RenderPipeline { get; internal set; } /// /// The last object it came though. /// Debugging pourpose. /// public object LastObject { get; internal set; } /// /// The camera the context is using. /// public GenericCamera UseCamera { get; internal set; } /// /// The world matrix. /// public Matrix4 World => UseCamera.World; /// /// The view matrix. /// public Matrix4 View => UseCamera.View; /// /// The mesh, that is rendered. /// public GenericMesh Mesh { get; set; } /// /// If set, it will force the mesh to render with that primitive type. /// public PrimitiveType? ForcedType { get; set; } /// /// The material the mesh is going to use. /// public Material Material { get; set; } /// /// The shader the mesh is going to use. /// public MaterialShader Shader => Material.CustomShader ?? RenderPipeline.DefaultShader; /// /// The master model matrix. /// public Matrix4 ModelMatrix; /// /// The master texture matrix. /// public Matrix3 TextureMatrix; /// /// Instances /// public IList Instances; /// /// This sets the camera of the context. /// /// public void SetCamera(GenericCamera camera) { UseCamera = camera; camera.CalculateViewMatrix(Window); } } }