Ejemplo n.º 1
0
        /// <inheritdoc />
        public void Applied(IGenericWindow window)
        {
            window.ViewportCamera = new Camera();

            SMRenderer.DefaultMaterialShader = ShaderCollection.Instanced;
            SMRenderer.DefaultRenderPipeline = Basic2DPipeline.Pipeline;
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Calculates the view matrix.
 /// </summary>
 /// <returns>The calculated view matrix. Same as <see cref="View" /></returns>
 internal void CalculateViewMatrix(IGenericWindow window)
 {
     View = ViewCalculation(window);
     if (WorldCalculation(window, out Matrix4 world))
     {
         World = world;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// The event when resizing.
        /// </summary>
        public virtual void Resize(IGenericWindow window)
        {
            Recompile();

            foreach (PostProcessEffect effect in PostProcessEffects)
            {
                effect.ScreenSizeChanged(window);
            }
        }
Ejemplo n.º 4
0
        internal static void Resize(IGenericWindow window)
        {
            window.WindowSize  = new Vector2(window.Width, window.Height);
            window.AspectRatio = (float)window.Width / window.Height;

            if (window.WindowSize.LengthSquared == 0)
            {
                return;
            }

            GL.Viewport(window.ClientRectangle);


            PostProcessEffect.Mvp = Matrix4.CreateScale(window.Width, -window.Height, 1) *
                                    Matrix4.LookAt(Vector3.UnitZ, Vector3.Zero, Vector3.UnitY) *
                                    Matrix4.CreateOrthographic(window.Width, window.Height, .1f, 100f);

            window.CurrentRenderPipeline?.Resize(window);
            window.AppliedSetup?.Resize(window);
        }
Ejemplo n.º 5
0
        internal static void Update(IGenericWindow window, float deltatime)
        {
            Deltatime.UpdateDelta = deltatime;
            Mouse.SetState();
            Keyboard.SetStage();
            var context = new UpdateContext
            {
                Window = window,

                Scene = window.CurrentScene
            };

            if (Keyboard.IsDown(Key.AltLeft) && Keyboard.IsDown(Key.F4))
            {
                window.Close();
            }

            Stopwatch.PerformTicks(context);
            window.CurrentScene?.Update(context);
            window.Update(context);
        }
Ejemplo n.º 6
0
        internal static void Render(IGenericWindow window, float deltatime)
        {
            if (window.CurrentScene == null)
            {
                return;
            }
            if (window.CurrentRenderPipeline == null)
            {
                window.SetRenderPipeline(SMRenderer.DefaultRenderPipeline);
            }

            SMRenderer.CurrentFrame++;

            GLObject.DisposeMarkedObjects();

            Deltatime.RenderDelta = deltatime;
            var drawContext = new DrawContext
            {
                Window         = window,
                Scene          = window.CurrentScene,
                RenderPipeline = window.CurrentRenderPipeline,

                Mesh     = Plate.Object,
                Material = window.CurrentRenderPipeline.DefaultMaterial,

                ModelMatrix   = Matrix4.Identity,
                TextureMatrix = Matrix3.Identity,
                Instances     = new Instance[1]
                {
                    new Instance {
                        ModelMatrix = Matrix4.Identity, TextureMatrix = Matrix3.Identity
                    }
                }
            };

            drawContext.SetCamera(window.ViewportCamera);

            GL.DepthFunc(DepthFunction.Lequal);
            window.CurrentRenderPipeline?.Render(ref drawContext);
        }
Ejemplo n.º 7
0
        internal static void Load(IGenericWindow window)
        {
            GLSystem.INIT_SYSTEM();
            GLSettings.ShaderPreProcessing = true;
            Framebuffer.ScreenWindow       = window;

            var args = Environment.GetCommandLineArgs();

            if (args.Contains("--advDebugging"))
            {
                SMRenderer.AdvancedDebugging = true;
                GLSettings.InfoEveryUniform  = true;
            }

            Log.Init();

            Log.Write("#", ConsoleColor.Cyan, "----------------------",
                      "--- OpenGL Loading ---",
                      "----------------------------------",
                      $"--- {"DeviceVersion",14}: {GLSystem.DeviceVersion,-10} ---",
                      $"--- {"ForcedVersion",14}: {GLSettings.ForcedVersion,-10} ---",
                      $"--- {"ShadingVersion",14}: {GLSystem.ShadingVersion,-10} ---",
                      $"--- {"Debugging",14}: {GLSystem.Debugging,-10} ---",
                      $"--- {"AdvDebugging",14}: {SMRenderer.AdvancedDebugging,-10} ---",
                      "----------------------------------");

            if (SMRenderer.AdvancedDebugging)
            {
                Log.Write("Extension", ConsoleColor.DarkCyan, GLSystem.Extensions);
            }

            ExtensionManager.InitExtensions();

            window.TriggerLoad();
            window.AppliedSetup?.Load(window);
        }
Ejemplo n.º 8
0
 /// <inheritdoc />
 public void Loaded(IGenericWindow window)
 {
 }
Ejemplo n.º 9
0
 /// <inheritdoc />
 public void Load(IGenericWindow window)
 {
     GL.Enable(EnableCap.DepthTest);
 }
Ejemplo n.º 10
0
 /// <inheritdoc/>
 public override void ScreenSizeChanged(IGenericWindow window)
 {
     CreateFramebuffers();
 }
Ejemplo n.º 11
0
 public override void ScreenSizeChanged(IGenericWindow window)
 {
     tempFramebuffer.Recompile();
 }
Ejemplo n.º 12
0
        internal static void PrepareScene(IGenericWindow window, GenericScene scene)
        {
            window.CurrentScene?.Deactivate();

            Util.Activate(scene);
        }
Ejemplo n.º 13
0
 /// <summary>
 ///     This calculates the view matrix.
 /// </summary>
 /// <returns>
 ///     The new view matrix. This is the returns for <see cref="CalculateViewMatrix" /> and the next value for
 ///     <see cref="View" />.
 /// </returns>
 protected abstract Matrix4 ViewCalculation(IGenericWindow window);
Ejemplo n.º 14
0
 internal static void PreparePipeline(IGenericWindow window, RenderPipeline pipeline)
 {
     pipeline.ConnectedWindow = window;
     Util.Activate(pipeline);
 }
Ejemplo n.º 15
0
 /// <inheritdoc />
 public void Resize(IGenericWindow window)
 {
     Camera.ResizeCounter++;
 }
Ejemplo n.º 16
0
 /// <summary>
 ///     Event, when the screen size changed.
 /// </summary>
 /// <param name="window">Window that changed</param>
 public virtual void ScreenSizeChanged(IGenericWindow window)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// This calculates the world.
 /// </summary>
 /// <param name="window"></param>
 /// <param name="world"></param>
 /// <returns></returns>
 protected abstract bool WorldCalculation(IGenericWindow window, out Matrix4 world);