コード例 #1
0
        /// <summary>
        ///     デバイスを初期化します.
        /// </summary>
        public new void Load()
        {
            base.Load(false, D3D.DeviceCreationFlags.BgraSupport, DeviceCreationFlags.BgraSupport);

            //ラスタライザの設定を上書き
            var blendDesc = new D3D.BlendStateDescription();

            blendDesc.AlphaToCoverageEnable  = true; // Alpha to Coverage を有効にする
            blendDesc.IndependentBlendEnable = false;
            for (int i = 0; i < blendDesc.RenderTargets.Length; i++)
            {
                blendDesc.RenderTargets[i].BlendEnable           = true;
                blendDesc.RenderTargets[i].SourceBlend           = D3D.BlendOption.SourceAlpha;
                blendDesc.RenderTargets[i].DestinationBlend      = D3D.BlendOption.InverseSourceAlpha;
                blendDesc.RenderTargets[i].BlendOperation        = D3D.BlendOperation.Add;
                blendDesc.RenderTargets[i].SourceBlendAlpha      = D3D.BlendOption.One;
                blendDesc.RenderTargets[i].DestinationBlendAlpha = D3D.BlendOption.One; // ここを1にしないとアルファの合成が変
                blendDesc.RenderTargets[i].BlendOperationAlpha   = D3D.BlendOperation.Add;
                blendDesc.RenderTargets[i].RenderTargetWriteMask = D3D.ColorWriteMaskFlags.All;
            }

            customBlendState = Context.OutputMerger.BlendState = D3D.BlendState.FromDescription(Device, blendDesc);

            d2dFactory = new D2D.Factory(D2D.FactoryType.Multithreaded);
            dwFactory  = new DW.Factory(DW.FactoryType.Shared);
        }
コード例 #2
0
        public DX11TextLayerAdvancedNode(IIOFactory factory, SlimDX.DirectWrite.Factory dwFactory)
        {
            this.iofactory = factory;
            this.dwFactory = dwFactory;

            this.iofactory.PluginHost.CreateTransformInput("Transform In", TSliceMode.Dynamic, TPinVisibility.True, out this.transformIn);
            this.transformIn.Order = 1;
        }
コード例 #3
0
ファイル: TextRenderTarget.cs プロジェクト: Christof/ionfish
 private void CreateTextFormat()
 {
     var factory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
     mTextFormat = factory.CreateTextFormat("Consola", FontWeight.Normal,
         SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 100, "en-us");
     mTextFormat.TextAlignment = TextAlignment.Center;
     mTextFormat.ParagraphAlignment = ParagraphAlignment.Center;
 }
コード例 #4
0
ファイル: DWOutlinedText.cs プロジェクト: Shoepon/Galateia
 public DWOutlinedText(D2D.Factory d2dFactory, DW.Factory dwFactory, string fontfile, int fontFaceIndex,
                       DW.FontFaceType fontFaceType)
 {
     _d2DFactory    = d2dFactory;
     _dwFactory     = dwFactory;
     _fontFile      = _dwFactory.CreateFontFileReference(fontfile);
     _fontFaceIndex = fontFaceIndex;
     _fontFaceType  = fontFaceType;
 }
コード例 #5
0
ファイル: D2DInteropHandler.cs プロジェクト: hexd0t/Garm_Net
        public D2DInteropHandler(RenderManager manager)
        {
            Manager = manager;
            #if DEBUG
            D3DDevice10 = new D3D101.Device1(manager.DXGIAdapter, D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.BgraSupport | D3D10.DeviceCreationFlags.Debug, D3D101.FeatureLevel.Level_10_0);
            #else
            D3DDevice10 = new D3D101.Device1(D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.BgraSupport, D3D101.FeatureLevel.Level_10_0);
            #endif
            D2DFactory = new D2D.Factory(D2D.FactoryType.SingleThreaded);

            DWFactory = new DW.Factory(DW.FactoryType.Shared);
        }
コード例 #6
0
ファイル: ProgressUpdate.cs プロジェクト: amitprakash07/dx11
        public ProgressUpdate(WindowRenderTarget rt1) {
            _rt = rt1;
            _brush = new SolidColorBrush(_rt, Color.Green);
            _clearColor = new SolidColorBrush(_rt, Color.Black);

            _borderBounds = new Rectangle(18, rt1.PixelSize.Height / 2 - 2, rt1.PixelSize.Width - 36, 24);
            _barBounds = new Rectangle(20, rt1.PixelSize.Height / 2, rt1.PixelSize.Width - 40, 20);

            _factory = new Factory(FactoryType.Isolated);
            _txtFormat = new TextFormat(_factory, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 18, "en-us") {
                TextAlignment = TextAlignment.Center
            };
            _textRect = new Rectangle(100, rt1.PixelSize.Height / 2 - 25, _rt.PixelSize.Width - 200, 20);
        }
コード例 #7
0
ファイル: d2dengine.cs プロジェクト: EllionFellow/D2D
 public d2dengine(Control container, List <gameobject> theList)
 {
     ToDraw                = theList;
     targetControl         = container;
     debugLevel            = DebugLevel.None;
     d2dFactory            = new SlimDX.Direct2D.Factory(SlimDX.Direct2D.FactoryType.Multithreaded, debugLevel);
     wrtFactory            = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
     d2dWindowRenderTarget = new WindowRenderTarget(d2dFactory, new WindowRenderTargetProperties()
     {
         Handle         = targetControl.Handle,
         PixelSize      = targetControl.Size,
         PresentOptions = PresentOptions.Immediately
     });
 }
コード例 #8
0
        public ProgressUpdate(WindowRenderTarget rt1)
        {
            _rt         = rt1;
            _brush      = new SolidColorBrush(_rt, Color.Green);
            _clearColor = new SolidColorBrush(_rt, Color.Black);

            _borderBounds = new Rectangle(18, rt1.PixelSize.Height / 2 - 2, rt1.PixelSize.Width - 36, 24);
            _barBounds    = new Rectangle(20, rt1.PixelSize.Height / 2, rt1.PixelSize.Width - 40, 20);

            _factory   = new Factory(FactoryType.Isolated);
            _txtFormat = new TextFormat(_factory, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 18, "en-us")
            {
                TextAlignment = TextAlignment.Center
            };
            _textRect = new Rectangle(100, rt1.PixelSize.Height / 2 - 25, _rt.PixelSize.Width - 200, 20);
        }
コード例 #9
0
ファイル: Score.cs プロジェクト: cbeihl/pong
        public void Render(SlimDX.Direct2D.Factory factory, SlimDX.DirectWrite.Factory dwFactory, RenderTarget renderTarget)
        {
            if (this.brush == null)
            {
                brush     = new SolidColorBrush(renderTarget, new Color4(1.0f, 1.0f, 1.0f));
                txtFormat = dwFactory.CreateTextFormat("lcd phone", FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 60, "en-us");
            }

            SizeF newWindowSize = renderTarget.Size;

            if (windowSize == null || !windowSize.Equals(newWindowSize))
            {
                windowSize = newWindowSize;
                float centerX = windowSize.Width / 2;
                rect = new RectangleF(new PointF(centerX + posOffset.X, posOffset.Y), textLayoutSize);
            }

            renderTarget.DrawText(val.ToString(), txtFormat, rect, brush);
        }
コード例 #10
0
ファイル: SlimDXRenderer.cs プロジェクト: andyld97/Spider
        public override void OnInit(Game currentGame, Form owner, Save settings)
        {
            base.currentGame = currentGame;
            base.owner       = owner;
            base.info        = settings;

            this.owner.Controls.Add(this);
            this.Dock = DockStyle.Fill;

            try
            {
                SlimDX.DirectWrite.Factory m = new SlimDX.DirectWrite.Factory(FactoryType.Shared);
                textFormatCentered = m.CreateTextFormat(this.Font.FontFamily.Name, SlimDX.DirectWrite.FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Expanded, 50, "de-de");
                textFormatCentered.TextAlignment      = SlimDX.DirectWrite.TextAlignment.Center;
                textFormatCentered.ParagraphAlignment = SlimDX.DirectWrite.ParagraphAlignment.Center;
            }
            catch (Exception)
            { }

            this.initializeGraphics();

            this.FinishedInit = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw, true);
            this.UpdateStyles();

            try
            {
                if (string.IsNullOrEmpty(settings.Background))
                {
                    this.BackgroundImage = Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "Images", "Image.jpg"));
                }
                else
                {
                    this.BackgroundImage = Image.FromFile(settings.Background);
                }
            }
            catch (Exception)
            { }

            this.e = new Graphics.DirectGraphics(this.renderTarget);
            this.Invalidate();
        }
コード例 #11
0
        /// <summary>
        /// In a derived class, implements logic to initialize the sample.
        /// </summary>
        protected override void OnInitialize()
        {
            DeviceSettings2D settings = new DeviceSettings2D
            {
                Width  = WindowWidth,
                Height = WindowHeight
            };

            InitializeDevice(settings);
            _writeFactory                  = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
            _textFormat                    = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us");
            _textFormat.TextAlignment      = TextAlignment.Center;
            _textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle))
            {
                _dpiY = graphics.DpiY / 96.0f;
                _dpiX = graphics.DpiX / 96.0f;
            }

            InitializeSimpleText();
            InitializeMultiformattedText();
        }
コード例 #12
0
 public MeasureTextNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #13
0
        public static void Init(RenderTarget renderTarget)
        {
            FullRectangle     = new RectangleF(0, 0, Bounds.Width, Bounds.Height);
            ProgressBarBounds =
                new RectangleF(20 + DebugRectangle.X + DebugRectangle.Width, 20,
                               Bounds.Width - 40 - DebugRectangle.X - DebugRectangle.Width, 20);

            // Generate common brushes
            DefaultBrushes = new Brush[DefaultColors.Length];
            for (int i = 0; i < DefaultColors.Length; i++)
            {
                DefaultBrushes[i] = new SolidColorBrush(renderTarget, DefaultColors[i]);
            }
            ChannelBrushes = new Brush[ChannelColors.Length];
            for (int i = 0; i < ChannelColors.Length; i++)
            {
                ChannelBrushes[i] = new SolidColorBrush(renderTarget, ChannelColors[i]);
            }

            // Generate common gradients
            KeyboardGradient = new LinearGradientBrush(renderTarget,
                                                       new GradientStopCollection(renderTarget, new[] {
                new GradientStop()
                {
                    Color = new Color4(Color.White), Position = 0
                },
                new GradientStop()
                {
                    Color = new Color4(Color.DarkGray), Position = 1
                }
            }),
                                                       new LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, renderTarget.Size.Height),
                EndPoint   = new PointF(0, renderTarget.Size.Height - KeyHeight)
            });
            BackgroundGradient = new LinearGradientBrush(renderTarget,
                                                         new GradientStopCollection(renderTarget, new[] {
                new GradientStop()
                {
                    Color = Color.Black, Position = 1f
                },
                new GradientStop()
                {
                    Color = Color.FromArgb(30, 30, 30), Position = 0f
                }
            }),
                                                         new LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, renderTarget.Size.Height),
                EndPoint   = new PointF(0, 0)
            });
            ChannelGradientBrushes = new LinearGradientBrush[ChannelColors.Length];
            for (int i = 0; i < ChannelGradientBrushes.Length; i++)
            {
                ChannelGradientBrushes[i] = new LinearGradientBrush(renderTarget,
                                                                    new GradientStopCollection(renderTarget, new[] {
                    new GradientStop()
                    {
                        Color = ChannelColors[i], Position = 1f
                    },
                    new GradientStop()
                    {
                        Color = ControlPaint.Light(ChannelColors[i], .8f), Position = 0f
                    }
                }),
                                                                    new LinearGradientBrushProperties()
                {
                    StartPoint = new PointF(0, renderTarget.Size.Height),
                    EndPoint   = new PointF(0, 0)
                });
            }
            // Generate common fonts
            using (var textFactory = new Factory())
            {
                DebugFormat = new TextFormat(textFactory, "Consolas", FontWeight.Bold,
                                             SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 14, "en-us");
                SmallFormat = new TextFormat(textFactory, "Century Gothic", FontWeight.UltraBold,
                                             SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 10, "en-us");
                HugeFormat = new TextFormat(textFactory, "Century Gothic", FontWeight.UltraBold,
                                            SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 50, "en-us")
                {
                    TextAlignment      = TextAlignment.Center,
                    ParagraphAlignment = ParagraphAlignment.Center
                };
            }
        }
コード例 #14
0
 public CaretPositionNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #15
0
ファイル: HelloWorldSample.cs プロジェクト: zhandb/slimdx
		/// <summary>
		/// In a derived class, implements logic to initialize the sample.
		/// </summary>
		protected override void OnInitialize()
		{
			DeviceSettings2D settings = new DeviceSettings2D
			{
				Width = WindowWidth,
				Height = WindowHeight
			};

			InitializeDevice(settings);
			_writeFactory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
			_textFormat = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us");
			_textFormat.TextAlignment = TextAlignment.Center;
			_textFormat.ParagraphAlignment = ParagraphAlignment.Center;
			using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle))
			{
				_dpiY = graphics.DpiY/96.0f;
				_dpiX = graphics.DpiX/96.0f;
			}

			InitializeSimpleText();
			InitializeMultiformattedText();
		}
コード例 #16
0
 public CaretRangeNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #17
0
 public TextLayoutMetricsNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #18
0
 public FontTypographyStyle(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #19
0
ファイル: TextRangeNode.cs プロジェクト: vsnchips/dx11-vvvv
 public CaretRangeNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #20
0
 public TextLayoutLineMetricsNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #21
0
 public DX11TextLayerCacheNode(SlimDX.DirectWrite.Factory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #22
0
 public CaretPositionNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #23
0
 public TextLayoutClusterMetricsNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #24
0
 public HitTestTextNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #25
0
 public TextLayoutAdvancedNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #26
0
ファイル: Text.cs プロジェクト: Christof/afterglow
        public void Using_DirectWrite()
        {
            Device device;
            SwapChain swapChain;
            RenderTargetView renderTarget;

            EmptyWindow.CreateDeviceSwapChainAndRenderTarget(mForm, out device, out swapChain, out renderTarget);

            var direct2dfactory = new Direct2DFactory();
            var directWriteFactory = new DirectWriteFactory();

            var properties = new WindowRenderTargetProperties { Handle = mForm.Handle, PixelSize = mForm.ClientSize };
            var windowRenderTarget = new WindowRenderTarget(direct2dfactory, properties);
            var brush = new SolidColorBrush(windowRenderTarget, Color.Black);

            var textFormat = new TextFormat(directWriteFactory, "Gabriola",
                FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us")
            {
                TextAlignment = TextAlignment.Center,
                ParagraphAlignment = ParagraphAlignment.Center
            };

            Application.Idle +=
                delegate
                {
                    device.ClearRenderTargetView(renderTarget, new Color4(1, 0, 0));

                    if (!windowRenderTarget.IsOccluded)
                    {
                        windowRenderTarget.BeginDraw();
                        windowRenderTarget.Transform = Matrix3x2.Identity;
                        windowRenderTarget.Clear(Color.White);

                        windowRenderTarget.DrawText("Hello World using DirectWrite!", textFormat, mForm.ClientRectangle, brush);

                        windowRenderTarget.EndDraw();
                    }

                    swapChain.Present(0, PresentFlags.None);

                    Application.DoEvents();
                };

            Application.Run(mForm);
        }
コード例 #27
0
 public TextLayoutNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #28
0
 public FontTypographyStyle(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #29
0
 public TextFormatNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #30
0
 public MeasureTextNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #31
0
ファイル: GFXResources.cs プロジェクト: HuYang719/MIDITrailer
        public static void Init(RenderTarget renderTarget)
        {
            // Generate common brushes
            DefaultBrushes = new Brush[DefaultColors.Length];
            for (int i = 0; i < DefaultColors.Length; i++)
                DefaultBrushes[i] = new SolidColorBrush(renderTarget, DefaultColors[i]);
            ChannelBrushes = new Brush[ChannelColors.Length];
            for (int i = 0; i < ChannelColors.Length; i++)
                ChannelBrushes[i] = new SolidColorBrush(renderTarget, ChannelColors[i]);

            // Generate common gradients
            KeyboardGradient = new LinearGradientBrush(renderTarget,
                new GradientStopCollection(renderTarget, new[] {
                    new GradientStop()
                    { Color = new Color4(Color.White),Position = 0 },
                    new GradientStop()
                    { Color = new Color4(Color.DarkGray), Position = 1 }
                }),
                new LinearGradientBrushProperties()
                {
                    StartPoint = new PointF(0, renderTarget.Size.Height),
                    EndPoint = new PointF(0, renderTarget.Size.Height - KEY_HEIGHT)
                });
            BackgroundGradient = new LinearGradientBrush(renderTarget,
                new GradientStopCollection(renderTarget, new[] {
                    new GradientStop()
                    { Color = Color.Black, Position = 1f },
                    new GradientStop()
                    { Color = Color.FromArgb(30, 30, 30), Position = 0f }
                }),
                new LinearGradientBrushProperties()
                {
                    StartPoint = new PointF(0, renderTarget.Size.Height),
                    EndPoint = new PointF(0, 0)
                });
            ChannelGradientBrushes = new LinearGradientBrush[ChannelColors.Length];
            for (int i = 0; i < ChannelGradientBrushes.Length; i++)
            {
                ChannelGradientBrushes[i] = new LinearGradientBrush(renderTarget,
                new GradientStopCollection(renderTarget, new[] {
                    new GradientStop()
                    { Color = ChannelColors[i], Position = 1f },
                    new GradientStop()
                    { Color = ControlPaint.Light(ChannelColors[i], .8f), Position = 0f }
                }),
                new LinearGradientBrushProperties()
                {
                    StartPoint = new PointF(0, renderTarget.Size.Height),
                    EndPoint = new PointF(0, 0)
                });
            }
            // Generate common fonts
            using (var textFactory = new Factory())
            {
                DebugFormat = new TextFormat(textFactory, "Consolas", FontWeight.UltraBold,
                    SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 18, "en-us");
                HugeFormat = new TextFormat(textFactory, "Consolas", FontWeight.UltraBold,
                   SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 50, "en-us")
                {
                    TextAlignment = TextAlignment.Center,
                    ParagraphAlignment = ParagraphAlignment.Center
                };
            }
        }
コード例 #32
0
        public override void OnInit(Game currentGame, Form owner, Save settings)
        {
            base.currentGame = currentGame;
            base.owner = owner;
            base.info = settings;

            this.owner.Controls.Add(this);
            this.Dock = DockStyle.Fill;

            try
            {
                SlimDX.DirectWrite.Factory m = new SlimDX.DirectWrite.Factory(FactoryType.Shared);
                textFormatCentered = m.CreateTextFormat(this.Font.FontFamily.Name, SlimDX.DirectWrite.FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Expanded, 50, "de-de");
                textFormatCentered.TextAlignment = SlimDX.DirectWrite.TextAlignment.Center;
                textFormatCentered.ParagraphAlignment = SlimDX.DirectWrite.ParagraphAlignment.Center;
            }
            catch (Exception)
            { }

            this.initializeGraphics();

            this.FinishedInit = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw, true);
            this.UpdateStyles();

            try
            {
                if (string.IsNullOrEmpty(settings.Background))
                    this.BackgroundImage = Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "Images", "Image.jpg"));
                else
                    this.BackgroundImage = Image.FromFile(settings.Background);
            }
            catch (Exception)
            { }

            this.e = new Graphics.DirectGraphics(this.renderTarget);
            this.Invalidate();
        }
コード例 #33
0
 public TextFormatNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }
コード例 #34
0
 public HitTestTextNode(DWriteFactory dwFactory)
 {
     this.dwFactory = dwFactory;
 }