Beispiel #1
0
        public Backbuffer(D3D11Device device, Window window)
        {
            m_swapchain  = device.CreateSwapchain(window.WindowHandle);
            m_backbuffer = m_swapchain.CreateBitmap();

            m_dispatcher.RegisterInterface(typeof(IDrawProcessor), m_backbuffer);
        }
        public void CreateWindowSizeDependentResources()
        {
            var    context       = this.deviceResources.D2DRenderTarget;
            var    dwriteFactory = this.deviceResources.DWriteFactory;
            string text          = "Hello, World!";

            byte[] bitmapBytes = File.ReadAllBytes(@"texturedata.bin");
            this.bitmap      = context.CreateBitmap(new D2D1SizeU(256, 256), bitmapBytes, 256 * 4, new D2D1BitmapProperties(new D2D1PixelFormat(DxgiFormat.R8G8B8A8UNorm, D2D1AlphaMode.Premultiplied), 96.0f, 96.0f));
            this.bitmapBrush = context.CreateBitmapBrush(this.bitmap, new D2D1BitmapBrushProperties(D2D1ExtendMode.Wrap, D2D1ExtendMode.Wrap, D2D1BitmapInterpolationMode.Linear));

            this.textBrush = context.CreateSolidColorBrush(new D2D1ColorF(D2D1KnownColor.Red));

            this.textLayout = dwriteFactory.CreateTextLayout(
                text,
                this.textFormat,
                this.deviceResources.ConvertPixelsToDipsX(this.deviceResources.BackBufferWidth),
                this.deviceResources.ConvertPixelsToDipsY(this.deviceResources.BackBufferHeight));

            this.textLayout.SetFontSize(140.0f, new DWriteTextRange(0, (uint)text.Length));

            using (var typography = dwriteFactory.CreateTypography())
            {
                typography.AddFontFeature(new DWriteFontFeature(DWriteFontFeatureTag.StylisticSet7, 1));
                this.textLayout.SetTypography(typography, new DWriteTextRange(0, 13));
            }
        }
Beispiel #3
0
        public void Dispose()
        {
            if (m_backbuffer != null)
            {
                m_backbuffer.Dispose();
                m_backbuffer = null;
            }

            if (m_swapchain != null)
            {
                m_swapchain.Dispose();
                m_swapchain = null;
            }
        }