Beispiel #1
0
        protected override void Destroy()
        {
            DestroyPlatformDevice();

            // Notify listeners
            if (Disposing != null)
            {
                Disposing(this, EventArgs.Empty);
            }

            SamplerStates.Dispose();
            BlendStates.Dispose();
            RasterizerStates.Dispose();
            if (DepthStencilBuffer != null)
            {
                DepthStencilBuffer.Dispose();
            }
            primitiveQuad.Dispose();

            SamplerStates      = null;
            BlendStates        = null;
            RasterizerStates   = null;
            DepthStencilStates = null;

            base.Destroy();
        }
Beispiel #2
0
 protected void SetBlendState(BlendStates state)
 {
     if (CurrentBlendMode == (int)state)
     {
         return;
     }
     GetContext.OutputMerger.SetBlendState(GetSharedItems.GetBlendState(state),
                                           GetSharedItems.BlendFactor, 0xFFFFFFFF);
     CurrentBlendMode = (int)state;
 }
        private void Update(EvaluationContext context)
        {
            // var blendStates = BlendStates.GetCollectedTypedInputs();
            BlendStates.GetValues(ref _blendStates, context);
            var index = Index.GetValue(context);

            if (_blendStates.Length == 0 || index == -1)
            {
                return;
            }

            index %= _blendStates.Length;
            if (index < 0)
            {
                index += _blendStates.Length;
            }

            Output.Value = _blendStates[index];
        }
Beispiel #4
0
 public void SetBlendState(BlendStates state)
 {
     _context.DeviceManager.Context.OutputMerger.BlendState = blendingStates[state];
 }
Beispiel #5
0
 public void ブレンドステートを設定する(DeviceContext deviceContext, BlendStates state)
 {
     deviceContext.OutputMerger.BlendState = _ブレンドステートマップ[state];
 }
Beispiel #6
0
        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.");
        }