public void Render(IEnumerable <Entity> entities) { Dictionary <IVertexArrayObject, int> vaoInformations = PrepareVAOs(entities); _camera.Position = new System.Numerics.Vector3(0.15f, 0.5f, 0.5f); _camera.Pitch = 20; _wrapper.ActivateShader(_vertex, _fragment); _wrapper.SetUniform("Camera", (Matrix4x4)_camera.CalcMatrix()); _wrapper.SetUniform("CameraPosition", (Vector3)_camera.CalcPosition()); _wrapper.SetUniform("LightDirection", (Vector3)System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(-1f, -1, -1))); _wrapper.SetUniform("AmbientLightColor", new Vector4(0.1f, 0.1f, 0.1f, 1f)); _wrapper.SetUniform("LightColor", new Vector4(1f, 1f, 1f, 1f)); //_wrapper.SetUniform("Camera", (Matrix4x4)System.Numerics.Matrix4x4.Identity); List <Texture2D> layers = new List <Texture2D>(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); foreach (var vaoInformation in vaoInformations) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Reset(); stopwatch.Start(); vaoInformation.Key.Draw(vaoInformation.Value); stopwatch.Stop(); Console.WriteLine($"\t\t\t\tTotal Time:\t{stopwatch.Elapsed.TotalMilliseconds}ms\n"); if (_wrapper is RenderSimulator) { layers.Add(new Texture2D(((RenderSimulator)_wrapper).RenderResult)); } } _wrapper.DeactivateShader(); if (_wrapper is RenderSimulator) { GL.Enable(EnableCap.Texture2D); layers[0].Bind(); Drawer.DrawScreenQuad(); Texture2D.Unbind(); GL.Disable(EnableCap.Texture2D); } }
public void Render(IEnumerable <Entity> entities) { Dictionary <IVertexArrayObject, int> vaoInformations = PrepareVAOs(entities); _camera.Position = new System.Numerics.Vector3(0.15f, 0.5f, 0.5f); _camera.Pitch = 20; _wrapper.ActivateShader(_vertex, _fragment); _wrapper.SetUniform("Camera", (Matrix4x4)_camera.CalcMatrix()); _wrapper.SetUniform("CameraPosition", (Vector3)_camera.CalcPosition()); _wrapper.SetUniform("LightDirection", (Vector3)System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(-1f, -1, -1))); _wrapper.SetUniform("AmbientLightColor", new Vector4(0.1f, 0.1f, 0.1f, 1f)); _wrapper.SetUniform("LightColor", new Vector4(1f, 1f, 1f, 1f)); //_wrapper.SetUniform("Camera", (Matrix4x4)System.Numerics.Matrix4x4.Transpose(System.Numerics.Matrix4x4.CreateTranslation(new System.Numerics.Vector3(0f, -0.5f, 0)))); List <Texture2D> layers = new List <Texture2D>(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); foreach (var vaoInformation in vaoInformations) { vaoInformation.Key.Draw(vaoInformation.Value); if (_wrapper is RenderSimulator) { layers.Add(new Texture2D(((RenderSimulator)_wrapper).RenderResult)); } } _wrapper.DeactivateShader(); if (_wrapper is RenderSimulator) { GL.Enable(EnableCap.Texture2D); layers[0].Bind(); Drawer.DrawScreenQuad(); Texture2D.Unbind(); GL.Disable(EnableCap.Texture2D); } }