protected override void LoadSynchronized() { base.LoadSynchronized(); var gdiFont = new SysFont( "Microsoft Sans Serif", 10f /*8.25f*/, FontStyle.Bold, GraphicsUnit.Pixel); //_font = new D3dFont(Allocator.Device, gdiFont); _font = D3DXHelper.CreateFont(Allocator.Device, gdiFont); }
private void RenderSprite( D3DXSprite sprite, Direct3DTexture9 texture, Size srcSize, RectangleF dstRect, bool antiAlias) { sprite.Begin(D3DXSPRITEFLAG.NONE); try { if (!antiAlias) { Allocator.Device.SetSamplerState(0, D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT); Allocator.Device.SetSamplerState(0, D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT); Allocator.Device.SetSamplerState(0, D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT); } D3DXHelper.Draw2D(sprite, texture, dstRect, srcSize); } finally { sprite.End(); } }
protected override void RenderSynchronized(int width, int height) { var size = new Size(width, height); var visibleIcons = _iconTextures.Values .Where(icon => icon.Visible) .ToArray(); foreach (var icon in visibleIcons) { icon.LoadResources(Allocator.Device); } var potSize = ScaleHelper.GetPotSize(32); var iconSize = new SizeF(potSize, potSize); var iconNumber = 1; foreach (var iconTexture in visibleIcons) { var iconRect = new Rectangle(new Point(0, 0), iconTexture.Size); var iconPos = new PointF( size.Width - iconSize.Width * iconNumber, 0); _spriteIcon.Begin(D3DXSPRITEFLAG.D3DXSPRITE_ALPHABLEND); try { D3DXHelper.Draw2D( _spriteIcon, iconTexture.Texture, new RectangleF(iconPos, iconSize), iconTexture.Size); } finally { _spriteIcon.End(); } iconNumber++; } }
protected override void RenderSynchronized(int width, int height) { base.RenderSynchronized(width, height); var wndSize = new SizeF(width, height); var frameRate = Allocator.Device.DisplayMode.RefreshRate; var graphRender = _graphRender.Get(); var graphLoad = _graphLoad.Get(); #if SHOW_LATENCY var graphLatency = _graphLatency.Get(); //var graphCopy = _copyGraph.Get(); #endif var graphUpdate = _graphUpdate.Get(); var frequency = GraphMonitor.Frequency; var limitDisplay = frequency / frameRate; var limit50 = frequency / 50D; var limit1ms = frequency / 1000D; var maxRender = graphRender.Max(); var maxLoad = graphLoad.Max(); var minT = graphRender.Min() * 1000D / frequency; var avgT = graphRender.Average() * 1000D / frequency; var maxT = maxRender * 1000D / frequency; #if SHOW_LATENCY var minL = _graphLatency.IsDataAvailable ? graphLatency.Min() * 1000D / frequency : 0D; var avgL = _graphLatency.IsDataAvailable ? graphLatency.Average() * 1000D / frequency : 0D; var maxL = _graphLatency.IsDataAvailable ? graphLatency.Max() * 1000D / frequency : 0D; #endif var avgE = graphLoad.Average() * 1000D / frequency; var avgU = graphUpdate.Average() * 1000D / frequency; var maxScale = Math.Max(maxRender, maxLoad); maxScale = Math.Max(maxScale, limit50); maxScale = Math.Max(maxScale, limitDisplay); var fpsRender = 1000D / avgT; var fpsUpdate = 1000D / avgU; var textValue = string.Format( "Render FPS: {0:F3}\n" + "Update FPS: {1:F3}\n" + "Device FPS: {2}\n" + "Back: [{3}, {4}]\n" + "Frame: [{5}, {6}]\n" + "Sound: {7:F3} kHz\n" + "FrameStart: {8}T", fpsRender, IsRunning ? fpsUpdate : (double?)null, frameRate, wndSize.Width, wndSize.Height, FrameSize.Width, FrameSize.Height, SampleRate / 1000D, FrameStartTact); var textRect = D3DXHelper.GetRect(_font.MeasureText(null, textValue, DT.DT_NOCLIP)); textRect = new Rectangle( textRect.Left, textRect.Top, Math.Max(textRect.Width + 10, GraphLength), textRect.Height); FillRect(textRect, Color.FromArgb(192, Color.Green)); _font.DrawText( null, textValue, D3DXHelper.GetRawRect(textRect), DT.DT_NOCLIP, D3DXHelper.GetColor(Color.Yellow)); // Draw graphs var graphRect = new Rectangle( textRect.Left, textRect.Top + textRect.Height, GraphLength, (int)(wndSize.Height - textRect.Top - textRect.Height)); FillRect(graphRect, Color.FromArgb(192, Color.Black)); RenderGraph(graphRender, maxScale, graphRect, Color.FromArgb(196, Color.Lime)); RenderGraph(graphLoad, maxScale, graphRect, Color.FromArgb(196, Color.Red)); //RenderGraph(graphCopy, maxTime, graphRect, Color.FromArgb(196, Color.Yellow)); RenderLimit(limitDisplay, maxScale, graphRect, Color.FromArgb(196, Color.Yellow)); RenderLimit(limit50, maxScale, graphRect, Color.FromArgb(196, Color.Magenta)); DrawGraphGrid(maxScale, limit1ms, graphRect, _graphRender.GetIndex(), Color.FromArgb(64, Color.White)); var msgTime = string.Format( "MinT: {0:F3} [ms]\nAvgT: {1:F3} [ms]\nMaxT: {2:F3} [ms]\nAvgE: {3:F3} [ms]", minT, avgT, maxT, avgE); #if SHOW_LATENCY if (_graphLatency.IsDataAvailable) { msgTime = string.Format( "{0}\nMinL: {1:F3} [ms]\nAvgL: {2:F3} [ms]\nMaxL: {3:F3} [ms]", msgTime, minL, avgL, maxL); } #endif _font.DrawText( null, msgTime, D3DXHelper.GetRawRect(graphRect), DT.DT_NOCLIP, D3DXHelper.GetColor(Color.FromArgb(156, Color.Yellow))); }