public static void Init() { DepthOnlyPass = Shaders.Get("ShadowMapping").GetPass("Depth"); ShadowMapsNeedRemade = true; AreSplitsDirty = true; _texScaleBias = Matrix.Scaling(0.5f, -0.5f, 1.0f); _texScaleBias.TranslationVector = new DxVector3(0.5f, 0.5f, 0.0f); }
internal static void Shutdown() { lock (Locker) { Factory2D?.Dispose(); Device2D?.Dispose(); Brushes.InvalidateAll(); Brushes = null; DirectWriteFactory?.Dispose(); ImagingFactory?.Dispose(); Factory.Dispose(); Device.Dispose(); DeviceDebug?.Dispose(); DxgiDevice?.Dispose(); Shaders.DisposeAll(); } }
internal static void Init() { Logger.Info("GraphicsManager initializing."); // Direct3D11 Init --- ResizeNextFrame = true; Factory = new FactoryDXGI(); ImagingFactory = new FactoryWIC(); Factory2D = new FactoryD2D(FactoryType.MultiThreaded, Engine.IsDebug ? DebugLevel.Error : DebugLevel.None); DirectWriteFactory = new FactoryDW(SharpDX.DirectWrite.FactoryType.Shared); CreateDevices(RenderSettings.GraphicsAdapter); Brushes = new MemoizingMRUCache <Colour, SolidColorBrush>( (colour, _) => new SolidColorBrush(Context2D, (Color4)colour) { Opacity = colour.A }, int.MaxValue, brush => brush.Dispose()); // ------------------------------------ Engine.HandleSet += hwnd => { var camera = Game.Workspace.CurrentCamera; camera.RenderHandle = hwnd; }; if (Engine.Handle != IntPtr.Zero) { var camera = Game.Workspace.CurrentCamera; camera.RenderHandle = Engine.Handle; } SamplerStates.Load(); Shaders.Init(); BlendStates.Load(); DepthStencilStates.Load(); RasterizerStates.Load(); //StandardConstants = new ConstantBuffer<StandardConstantData>(); StandardShader = Shaders.Get("Standard"); MainPass = StandardShader.GetPass(); LightingShader = Shaders.Get("Lighting"); LightingPass = LightingShader.GetPass(); PostProcessShader = Shaders.Get("PostProcess"); SkyboxShader = Shaders.Get("Skybox"); SkyboxPass = SkyboxShader.GetPass(); AdornShader = Shaders.Get("Adorn"); AALinePass = AdornShader.GetPass("AALine"); AdornSelfLitPass = AdornShader.GetPass("AdornSelfLit"); Shadows.Init(); // ------------------ IsInitialized = true; Initialized?.Invoke(); Initialized = null; //PixHelper.AllowProfiling(Engine.IsDebug); Logger.Info("Renderer initialized."); }