private void ApplicationIdle(object sender, EventArgs e) { while (IsApplicationIdle()) { // TODO : process input // update game objects double gameTime = (double)gameTimer.ElapsedTicks / Stopwatch.Frequency; float deltaTime = (float)(gameTime - lastGameTime); if (deltaTime >= 0.008) { lastGameTime = gameTime; foreach (IGameObject gameObj in gameObjects) { gameObj.Update(deltaTime); } moveAIPaddle(); checkBallCollisions(); if (!firstPaint) { renderTarget.BeginDraw(); renderTarget.Transform = Matrix3x2.Identity; renderTarget.Clear(new Color4(0.0f, 0.0f, 0.0f)); foreach (IGameObject gameObj in gameObjects) { gameObj.Render(factory, dwFactory, renderTarget); } renderTarget.EndDraw(); } // Debug.WriteLine("deltaTime = " + deltaTime); } } }
/// <summary> /// Renderloop /// </summary> public void Render() { WindowRenderTarget.BeginDraw(); WindowRenderTarget.Clear(Colors.AdvancedColors.DarkGray); for (int i = 0; i < screens.Count; i++) { screens[i].Render(windowBounds, WindowRenderTarget); } WindowRenderTarget.EndDraw(); //if (sw == null) // sw = Stopwatch.StartNew(); //else //{ // if (sw.ElapsedMilliseconds >= 1000) // { // sw.Restart(); // Console.WriteLine("FPS: " + fps); // fps = 0; // } // fps++; //} }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (!graphicsInitialized) { return; } windowRenderTarget.AntialiasMode = AntialiasMode.PerPrimitive; windowRenderTarget.BeginDraw(); try { windowRenderTarget.Clear(backgroundColor); if (scene != null) { DrawScene(); } } finally { windowRenderTarget.EndDraw(); } }
public override void Init() { // create Direct2D1 Factory factory = new Factory(); //Set Rendering properties RenderTargetProperties renderProp = new RenderTargetProperties() { PixelFormat = new PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied), }; //set hwnd target properties (permit to attach Direct2D to window) HwndRenderTargetProperties winProp = new HwndRenderTargetProperties() { Hwnd = UIForm.Handle, PixelSize = new Size2(Width, Height), PresentOptions = PresentOptions.None }; //target creation DrawTarget = new WindowRenderTarget(factory, renderProp, winProp); // create Bitmap BitmapBuffer = new SharpDX.Direct2D1.Bitmap(DrawTarget, new Size2(Width, Height), new BitmapProperties(DrawTarget.PixelFormat)); //Start to draw DrawTarget.BeginDraw(); DrawTarget.Clear(new SharpDX.Mathematics.Interop.RawColor4(0f, 0f, 0f, 1f)); DrawTarget.EndDraw(); // init events UIForm.KeyDown += new KeyEventHandler(EventsKeyboardDown); UIForm.KeyUp += new KeyEventHandler(EventsKeyboardUp); UIForm.FormClosed += new FormClosedEventHandler(EventsQuit); }
/// <summary> /// This is the thread where we draw /// </summary> /// <param name="sender"></param> private void SDxThread(object sender) { Main.Alert("Overlay launched!"); while (Shouldrun) { _device.BeginDraw(); _device.Clear(new RawColor4(Color.Transparent.R, Color.Transparent.G, Color.Transparent.B, Color.Transparent.A)); _device.TextAntialiasMode = TextAntialiasMode.Default; using (var g = Graphics.FromHwnd(IntPtr.Zero)) { if (!string.IsNullOrEmpty(Currentwindow)) { if (GameTitles.Any(x => Currentwindow.ToUpper().Contains(x))) { _device.DrawText(Demodata, new TextFormat(_fontFactory, TextFont.FontFamily.Name, FontWeight.Normal, FontStyle.Normal, TextFont.Size), new RawRectangleF(0, 0, (int)g.MeasureString(Demodata, TextFont).Width + 5, (int)g.MeasureString(Demodata, TextFont).Height + 5), _solidColorBrush); } } } _device.EndDraw(); } }
private void ThreadDirectX(object sender) { while (true) { device.BeginDraw(); device.Clear(Color.Transparent); device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased; List <BHelper.PlayerDraw> PlayerDataBuffer = Bluehack.PlayerDraws; for (int i = 0; i < PlayerDataBuffer.Count; i++) { BHelper.PlayerDraw PlayerData = PlayerDataBuffer[i]; DrawPlayerHealth(PlayerData.espX, PlayerData.espY, PlayerData.espDistance, PlayerData.PlayerHealth); DrawPlayerHead(PlayerData.espX, PlayerData.espY, PlayerData.espDistance); DrawPlayerBones(PlayerData.Bones); } List <BHelper.EntityDraw> EntityDataBuffer = Bluehack.EntityDraws; for (int i = 0; i < EntityDataBuffer.Count; i++) { BHelper.EntityDraw EntityData = EntityDataBuffer[i]; if (Enum.IsDefined(typeof(BHelper.AcceptedGrenadeIDS), EntityData.EntityClassID)) { DrawEntityGrenade(EntityData.espX, EntityData.espY, EntityData.espDistance, EntityData.EntityClassID, EntityData.EntityModel); } } float[] Punch = BHelper.LocalPlayer.GetPunch(); DrawPlayerCrosshair(Punch[0], Punch[1]); device.EndDraw(); Thread.Sleep(10); } }
public void Run() { SharpDX.Threading.TaskUtil.Run(() => { while (!_cancelTask.IsCancellationRequested) { lock (_lockObj) { hwndRenderTarget.BeginDraw(); hwndRenderTarget.Clear(Color.White); if (_opacity > 0.0f)//表示切换中 { RectangleF preRenderRect = ZoomBitmap(RenderTargetClientSize, _preBmp.Size); hwndRenderTarget.DrawBitmap(_preBmp.Bmp, preRenderRect, _opacity, BitmapInterpolationMode.NearestNeighbor, _preBmp.BitmapRectangleF); _opacity -= 0.02f; } else { if (_preBmp != null) { _preBmp.Dispose(); } } RectangleF renderRect = ZoomBitmap(RenderTargetClientSize, _bmp.Size); hwndRenderTarget.DrawBitmap(_bmp.Bmp, renderRect, 1f - _opacity, BitmapInterpolationMode.NearestNeighbor, _bmp.BitmapRectangleF); hwndRenderTarget.EndDraw(); } Thread.Sleep(40); } }); }
protected override void OnRender(WindowRenderTarget renderTarget) { if (_task != null) { _task.Wait(); _task.Dispose(); } List <Tuple <Geometry, Color> > copy = _geometries; _task = CreateGeometries(_time); if (_time == 0.1f) { renderTarget.Clear(Color.FromKnown(Colors.Black, 1f)); } renderTarget.FillRect(_brush, new RectF(0, 0, ClientSize.Width, ClientSize.Height)); for (int index = 0; index < copy.Count; ++index) { Tuple <Geometry, Color> tuple = copy[index]; using (Geometry geometry = tuple.Item1) { using (SolidColorBrush brush = renderTarget.CreateSolidColorBrush(tuple.Item2.AdjustContrast(1.5f))) { renderTarget.DrawGeometry(brush, 0.1f, geometry); } } } copy.Clear(); _time += 0.002f; }
private void Draw() { //begin rendering target.BeginDraw(); //clear target target.Clear(SharpDX.Color.CornflowerBlue); //draw a rounded box target.FillRoundedRectangle(new RoundedRectangle() { RadiusX = 10, RadiusY = 10, Rect = new SharpDX.RectangleF(0, 0, ClientSize.Width, ClientSize.Height) }, gradient); //draw some ellipse for (int i = 0; i < 20; i++) { target.DrawEllipse(new Ellipse(new Vector2(ClientSize.Width / 2, ClientSize.Height / 2), 20 * i, 20 * i), redBrush); } //draw text target.DrawText("Hello Direct2D", textFormat, new SharpDX.RectangleF(0, 0, 400, 200), whiteBrush); //end drawing target.EndDraw(); }
private void MainWindow_Paint(object sender, PaintEventArgs e) { _renderTarget.BeginDraw(); _renderTarget.Clear(Color.FromKnown(Colors.Blue, 1)); PointF center = new PointF(ClientSize.Width / 2, ClientSize.Height / 2); _renderTarget.Transform = Matrix3x2.Rotation(_angle, center); RoundedRect rr = new RoundedRect(new RectF(30, 30, ClientSize.Width - 60, ClientSize.Height - 60), ClientSize.Width / 2.5f, ClientSize.Height / 2.5f); _renderTarget.FillRoundedRect(RectBrush, rr); _renderTarget.DrawRoundedRect(_strokeBrush, 5, _strokeStyle, rr); Ellipse ellipse = new Ellipse(ClientSize.Width / 2, ClientSize.Height / 2, ClientSize.Width / 4, ClientSize.Height / 4); using (EllipseGeometry eg = _factory.CreateEllipseGeometry(ellipse)) { using (Brush b = CreateEllipseBrush(ellipse)) { _renderTarget.FillGeometry(b, eg); _renderTarget.DrawGeometry(_strokeBrush, 5, _strokeStyle, eg); } } RectF textBounds = new RectF(0, 0, ClientSize.Width, ClientSize.Height); _renderTarget.DrawText("Hello, world!", _textFormat, textBounds, _strokeBrush, DrawTextOptions.None, MeasuringMode.Natural); _renderTarget.DrawLine(_strokeBrush, 5, _strokeStyle, new PointF(0, 0), new PointF(ClientSize.Width, ClientSize.Height)); _renderTarget.EndDraw(); }
public void DrawText(WindowRenderTarget renderTarget, string titleText, string xAxisText, string yAxisText, float baseTextSize) { var sgOffsetY = renderTarget.Size.Height * 1 / 15; var sgOffsetX = renderTarget.Size.Width * 1 / 15; var containerHeight = renderTarget.Size.Height - sgOffsetY * 2; var containerWidth = renderTarget.Size.Width - sgOffsetX * 2; // not used? var textWidth = (int)containerHeight; var textHeight = (int)sgOffsetY; var factoryDWrite = new SharpDX.DirectWrite.Factory(); _textFormatTitle = new TextFormat(factoryDWrite, "Segoe", baseTextSize * 5 / 4) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; _textFormatHorizontal = new TextFormat(factoryDWrite, "Segoe", baseTextSize) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Far }; _textFormatVertical = new TextFormat(factoryDWrite, "Segoe", baseTextSize) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Far }; renderTarget.AntialiasMode = AntialiasMode.PerPrimitive; renderTarget.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Cleartype; var ClientRectangleTitle = new RectangleF(0, 0, textWidth, textHeight); var ClientRectangleXAxis = new RectangleF(0, containerHeight - textHeight + sgOffsetY * 2, textWidth, textHeight); var ClientRectangleYAxis = new RectangleF(-sgOffsetX, containerHeight - textHeight + sgOffsetY, textWidth, textHeight); _textSceneColorBrush.Color = _black; // Draw title and x axis text. renderTarget.BeginDraw(); renderTarget.Clear(_white); renderTarget.DrawText(titleText, _textFormatTitle, ClientRectangleTitle, _textSceneColorBrush); renderTarget.DrawText(xAxisText, _textFormatHorizontal, ClientRectangleXAxis, _textSceneColorBrush); renderTarget.EndDraw(); // Rotate render target to draw y axis text. renderTarget.Transform = Matrix3x2.Rotation((float)(-Math.PI / 2), new SharpDX.Vector2(0, containerHeight)); renderTarget.BeginDraw(); renderTarget.DrawText(yAxisText, _textFormatVertical, ClientRectangleYAxis, _textSceneColorBrush); renderTarget.EndDraw(); // Rotate the RenderTarget back. renderTarget.Transform = Matrix3x2.Identity; }
private void MyChart_Paint(object sender, PaintEventArgs e) { _renderTarget.BeginDraw(); _renderTarget.Clear(new RawColor4(1.0f, 1.0f, 1.0f, 1.0f));//用白色清空 DrawGrid(); if (Setting.ShowWave) { DrawWave(); } if (Setting.ShowFrameSeparator) { DrawFrameSepa(); } if (Setting.ShowSpec) { DrawSpec(); } if (Setting.ShowSpecSpec) { DrawSpecSpec(); } if (Setting.ShowLogSpec) { DrawLogSpec(); } if (Setting.ShowCepstrum) { DrawCepstrum(); } if (_isMouseMoving) { RawRectangleF rect = new RawRectangleF { Left = Math.Min(_mouseStartPoint.X, _mouseEndPoint.X), Right = Math.Max(_mouseStartPoint.X, _mouseEndPoint.X), Top = Math.Min(_mouseStartPoint.Y, _mouseEndPoint.Y), Bottom = Math.Max(_mouseStartPoint.Y, _mouseEndPoint.Y) }; _renderTarget.FillRectangle(rect, _blueBrush); } if (_chosenAreaMin < _chosenAreaMax) { var x = (_chosenAreaMin - _minX) * _scale_times_X + 40.0f; if (x > 40 && x < renderControl.ClientSize.Width) { _renderTarget.DrawLine(new RawVector2(x, 0), new RawVector2(x, this.Height), _blueBrush, 2); } x = (_chosenAreaMax - _minX) * _scale_times_X + 40.0f; if (x > 40 && x < renderControl.ClientSize.Width) { _renderTarget.DrawLine(new RawVector2(x, 0), new RawVector2(x, this.Height), _blueBrush, 2); } } _renderTarget.EndDraw(); }
private void DirectXThread(object obj) { while (Options.EspIsEnabled) { _device.BeginDraw(); _device.Clear(new RawColor4(Color.Transparent.R, Color.Transparent.G, Color.Transparent.B, Color.Transparent.A)); _device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased; //Get all players in the game var players = Utils.GetPlayers(); //Get our local player var localPlayer = Utils.GetLocalPlayer(); //If there aren't any players, we continue looping if (players.Count == 0) { continue; } foreach (var player in players) { //If the player is dead, or it's in our team or is dormant, it's not a valid one, so we continue looping if (player.GetHealth() == 0 || player.GetTeam() == localPlayer.GetTeam() || player.IsDormant()) { continue; } //Get player position var playerPosition = player.GetPosition(); //Get player head position var head = player.GetBonePos((int)Utils.PlayerBones.Head); //Get height based on the head positon, and the player position (which is always between the player's foot) var height = head.Y - playerPosition.Y; //Divide height by 4 to get the player's width var width = height / 4; //Bottom Line _device.DrawLine(new RawVector2(playerPosition.X - width, playerPosition.Y), new RawVector2(playerPosition.X + width, playerPosition.Y), _brush, 2f); //Top line _device.DrawLine(new RawVector2(playerPosition.X - width, playerPosition.Y + height), new RawVector2(playerPosition.X + width, playerPosition.Y + height), _brush, 2f); //Right line _device.DrawLine(new RawVector2(playerPosition.X - width, playerPosition.Y), new RawVector2(playerPosition.X - width, playerPosition.Y + height), _brush, 2f); //Left line _device.DrawLine(new RawVector2(playerPosition.X + width, playerPosition.Y), new RawVector2(playerPosition.X + width, playerPosition.Y + height), _brush, 2f); //Draw Health _device.DrawTextLayout(new RawVector2(playerPosition.X, playerPosition.Y + 10), new TextLayout(_fontFactory, "Health: " + player.GetHealth(), _font, 50, 12), _brush); //Draw Armor _device.DrawTextLayout(new RawVector2(playerPosition.X, playerPosition.Y + 40), new TextLayout(_fontFactory, "Armor: " + player.GetArmor(), _font, 50, 12), _brush); } _device.EndDraw(); Thread.Sleep(17); } }
public void Render() { wndRender.BeginDraw(); wndRender.Clear(Colors.DarkBlue); wndRender.DrawRectangle(new SharpDX.RectangleF(10, 10, 50, 50), scenebrush, 2.00F); wndRender.Flush(); wndRender.EndDraw(); }
public override void Clear(Color color) { if (device == null) { throw new SharpDXException("The device was not initialized yet"); } device.Clear(color); }
/// <summary> /// 描画 /// </summary> public void Paint() { render.BeginDraw(); render.Clear(background); //Value2Map(); var fontFactory = new SharpDX.DirectWrite.Factory(); var textFormat = new TextFormat(fontFactory, "メイリオ", 24.0f); textFormat.TextAlignment = TextAlignment.Center; var textBrush = new SharpDX.Direct2D1.SolidColorBrush(render, new RawColor4(1f, 1f, 1f, 1f)); render.DrawText("ここにカルノー図が表示されます", textFormat, new RawRectangleF(10, (this.height / 2) - 12, target.Width - 10, target.Height - 10), textBrush, DrawTextOptions.None); render.EndDraw(); }
//重绘 private void Renders() { target.BeginDraw(); target.Clear(Global.ToColor4(this.BackColor)); for (int i = 0; i < Figures.Count; i++) { } target.EndDraw(); }
private void Draw() { Converter.Render(objects, this); SceneBuffer.CopyFromMemory(SceneCache, 4 * Width); CameraView.BeginDraw(); CameraView.Clear(new Color4(0, 0, 0, 1f)); CameraView.DrawBitmap(SceneBuffer, 1f, BitmapInterpolationMode.Linear); CameraView.EndDraw(); }
/// <summary> /// 绘制图片 /// </summary> /// <param name="pic1"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="pic2"></param> /// <param name="x2"></param> /// <param name="y2"></param> private void DrawPicture(SharpDX.Direct2D1.Bitmap pic) { _renderTarget.BeginDraw(); _renderTarget.Clear(SharpDX.Color.White.ToColor4()); RawRectangleF point = new RawRectangleF(0, 0, _picContainer.Width, _picContainer.Height); _renderTarget.DrawBitmap(pic, point, 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor); _renderTarget.EndDraw(); }
protected override void OnRender(WindowRenderTarget renderTarget) { renderTarget.Clear(Color.FromKnown(Colors.Black, 1)); using (EllipseGeometry geometry = Direct2DFactory.CreateEllipseGeometry(new Graphics.Direct2D.Ellipse(ClientSize.Width / 2, ClientSize.Height / 2, ClientSize.Width / 2 - 25, ClientSize.Height / 2 - 25))) { using (SolidColorBrush brush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Red, 1))) { renderTarget.DrawGeometry(brush, 50, geometry); } } }
private void MainWindow_Paint(object sender, PaintEventArgs e) { _renderTarget.BeginDraw(); _renderTarget.Clear(Color.FromKnown(Colors.Black, 1)); if (_cache != null) { _renderTarget.DrawBitmap(_cache, new RectF(0, 0, ClientSize.Width, ClientSize.Height), 1, BitmapInterpolationMode.Linear); } _renderTarget.EndDraw(); }
public Example() { InitializeComponent(); Screen[] sc; sc = Screen.AllScreens; this.Bounds = sc[0].Bounds; //better results than FormWindowState.Maximum! this.BackColor = System.Drawing.Color.Black; this.FormBorderStyle = FormBorderStyle.None; this.ShowIcon = false; this.ShowInTaskbar = false; this.TopMost = false; this.WindowState = FormWindowState.Normal; Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, (IntPtr)(Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE) ^ Win32.WS_EX_LAYERED ^ Win32.WS_EX_TRANSPARENT)); //Clickable Win32.SetLayeredWindowAttributes(this.Handle, 0, 255, Win32.LWA_ALPHA); var targetProperties = new HwndRenderTargetProperties { Hwnd = this.Handle, PixelSize = new Size2(this.Bounds.Right - this.Bounds.Left, this.Bounds.Bottom - this.Bounds.Top), PresentOptions = PresentOptions.Immediately }; var prop = new RenderTargetProperties(RenderTargetType.Hardware, new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT); var d3dFactory = new SharpDX.Direct2D1.Factory(); var device = new WindowRenderTarget(d3dFactory, prop, targetProperties) { TextAntialiasMode = TextAntialiasMode.Cleartype, AntialiasMode = AntialiasMode.Aliased }; var dxthread = new Thread(() => { //define your text and colors here! while (true) { device.BeginDraw(); device.Clear(null); //drawing code goes here! device.EndDraw(); Thread.Sleep(1000 / 60); } }); dxthread.IsBackground = true; dxthread.Start(); }
protected virtual void Render(RenderTarget rt) { RenderTarget2D.Clear(SceneColorBrush.Color); var width = ClientSize.Width; var height = ClientSize.Height; float indent = ImagePadding; float rcRad = indent * 1.5f; using (var rcG = new RoundedRectangleGeometry(Factory2D, new RoundedRectangle() { RadiusX = rcRad, RadiusY = rcRad, Rect = new RectangleF(indent, indent, width - indent * 2, height - indent * 2) })) using (var sBr = new SolidColorBrush(RenderTarget2D, Color.Black)) RenderTarget2D.FillGeometry(rcG, sBr, null); }
public override bool Begin(gdi.Color color) { if (stateDraw) { return(false); } while (tLock) { ; } stateDraw = true; mainRenderTarget.BeginDraw(); mainRenderTarget.Clear(color.ToColor4()); return(true); }
private void Draw() { //begin rendering target.BeginDraw(); //clear target target.Clear(SharpDX.Color.Black); float delta = (DateTime.Now.Ticks - lastTick.Ticks) / 10000000f; lastTick = DateTime.Now; game.Update(delta); game.Draw(); //end drawing target.EndDraw(); }
private void sDXThread(object sender) { while (true) { device.BeginDraw(); device.Clear(Color.Transparent); device.TextAntialiasMode = TextAntialiasMode.Aliased;// you can set another text mode //place your rendering things here device.EndDraw(); } //whatever you want }
private void _loop_DXThread(object sender) { while (true) { device.BeginDraw(); device.Clear(Color.Transparent); device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased; device.DrawText("Overlay text using direct draw with DirectX", font, new SharpDX.Mathematics.Interop.RawRectangleF(5, 100, 500, 30), solidColorBrush); device.DrawBitmap(_bitmap, 1, BitmapInterpolationMode.Linear, new SharpDX.Mathematics.Interop.RawRectangleF(600, 400, 0, 0)); //place your rendering things here device.EndDraw(); } }
public void Draw() { if (!Program.GameController.IsInGame) { if (!UpdateWhenIdle) { return; } } device.BeginDraw(); device.Clear(SharpDX.Color.Transparent); this.OnDraw(device); device.EndDraw(); }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); if (!renderTarget.IsOccluded) { renderTarget.BeginDraw(); renderTarget.Transform = Matrix3x2.Identity; renderTarget.Clear(this.BackColor); if (UserPaint != null) { UserPaint(renderTarget); } renderTarget.EndDraw(); } }
private void CompositionHost_InvalidateDrawing(object sender, InvalidateDrawingEventArgs e) { var width = e.Width; var height = e.Height; // Clear render target backbround windowRenderTarget.BeginDraw(); windowRenderTarget.Clear(white); windowRenderTarget.EndDraw(); // Update graph if (currentGraph != null) { var currentDpi = VisualTreeHelper.GetDpi(this); currentGraph.UpdateSize(currentDpi, width, height); } }
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); }