예제 #1
0
        public void Init(IW32Win w32, NoForm root)
        {
            this.w32        = w32;
            noForm          = root;
            noForm.renderer = this;
            lock (noForm)
            {
                var sz = root.Size;
                // Initialise d2d things
                backBuffer = new Texture2D(device, new Texture2DDescription()
                {
                    ArraySize         = 1,
                    MipLevels         = 1,
                    SampleDescription = new SampleDescription(1, 0),
                    OptionFlags       = ResourceOptionFlags.GdiCompatible,
                    Width             = (int)sz.width,
                    Height            = (int)sz.height,
                    Usage             = ResourceUsage.Default,
                    BindFlags         = BindFlags.RenderTarget,
                    Format            = Format.B8G8R8A8_UNorm,
                });
                renderView      = new RenderTargetView(device, backBuffer);
                surface         = backBuffer.QueryInterface <Surface1>();
                d2dRenderTarget = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));
                scbTrans        = new SolidColorBrush(d2dRenderTarget, new Color4(1f, 0f, 1f, 0f)); // set buffer area to transparent

                // Init uDraw and assign IRenderElement parts
                _backRenderer = new SharpDX_RenderElements(d2dRenderTarget);
                _uDraw        = new D2DDraw(_backRenderer);

                // Create the observer
                dobs = new DirtyObserver(noForm, RenderPass, () => noForm.DirtyAnimated, () => noForm.ReqSize, () => FPSLimit);
            }
        }
예제 #2
0
        void HandleCreatedStuff()
        {
            SwapChainDescription swapchainDescription = new SwapChainDescription()
            {
                BufferCount       = 1,
                Flags             = SwapChainFlags.GdiCompatible,
                IsWindowed        = true,
                ModeDescription   = new ModeDescription((int)noForm.Size.width, (int)noForm.Size.height, new Rational(60, 1), Format.B8G8R8A8_UNorm),
                OutputHandle      = winHandle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Sequential,
                Usage             = Usage.RenderTargetOutput
            };

            SharpDXLib.Direct3D10.Device1.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, swapchainDescription, out device, out swapchain);

            // Initialise d2d things
            backBuffer      = Texture2D.FromSwapChain <Texture2D>(swapchain, 0);
            renderView      = new RenderTargetView(device, backBuffer);
            surface         = backBuffer.QueryInterface <Surface1>();
            d2dRenderTarget = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

            // Init uDraw and assign IRenderElement parts
            _backRenderer = new SharpDX_RenderElements(d2dRenderTarget);
            _uDraw        = new D2DDraw(_backRenderer);
        }