private void ApplyHorizontalReduction(RenderImage source, RenderImage destination) { int step = reductionChainCount - 1; RenderImage src = source; RenderImage HorizontalReduction = reductionRT[step]; reductionEffectTechnique["HorizontalReduction"].setAsCurrentShader(); // Disabled GLTexture stuff for now just to get the pipeline working. // The only side effect is that floating point precision will be low, // making light borders and shit have jaggy edges. //GLTexture GLHorizontalReduction = new GLTexture("desto", (int)source.Width, (int)source.Height, ImageBufferFormats.BufferGR1616F); //Debug.DebugRendertarget(source); while (step >= 0) { HorizontalReduction = reductionRT[step]; // next step HorizontalReduction.BeginDrawing(); HorizontalReduction.Clear(Color.White); //reductionEffectTechnique["HorizontalReduction"].SetParameter("secondTexture", src); reductionEffectTechnique["HorizontalReduction"].SetParameter("TextureDimensions", 1.0f / src.Width); // Sourcetexture not needed... just blit! src.Blit(0, 0, HorizontalReduction.Width, HorizontalReduction.Height, BlitterSizeMode.Scale); // draw SRC to HR //fix //GLHorizontalReduction.Blit(src.Texture, CluwneLib.CurrentShader); HorizontalReduction.EndDrawing(); src = HorizontalReduction; // hr becomes new src //Debug.DebugRendertarget(HorizontalReduction); step--; } CluwneLib.ResetShader(); //copy to destination destination.BeginDrawing(); destination.Clear(Color.White); HorizontalReduction.Blit(0, 0, destination.Height, destination.Width); //GLHorizontalReduction.Blit(HorizontalReduction.Texture, CluwneLib.CurrentShader); destination.EndDrawing(); //Debug.DebugRendertarget(destination); CluwneLib.ResetRenderTarget(); }
private void DrawGraph() { int totalRecBytes = 0; int totalSentBytes = 0; double totalMilliseconds = 0d; for (int i = 0; i < MaxDataPoints; i++) { if (_dataPoints.Count <= i) { continue; } totalMilliseconds += _dataPoints[i].ElapsedMilliseconds; totalRecBytes += _dataPoints[i].ReceivedBytes; totalSentBytes += _dataPoints[i].SentBytes; CluwneLib.ResetRenderTarget(); //Draw recieved line CluwneLib.drawRectangle((int)CluwneLib.CurrentRenderTarget.Size.X - (4 * (MaxDataPoints - i)), (int)CluwneLib.CurrentRenderTarget.Size.Y - (int)(_dataPoints[i].ReceivedBytes * 0.1f), 2, (int)(_dataPoints[i].ReceivedBytes * 0.1f), SFML.Graphics.Color.Red.WithAlpha(180)); CluwneLib.drawRectangle((int)CluwneLib.CurrentRenderTarget.Size.X - (4 * (MaxDataPoints - i)) + 2, (int)CluwneLib.CurrentRenderTarget.Size.Y - (int)(_dataPoints[i].SentBytes * 0.1f), 2, (int)(_dataPoints[i].SentBytes * 0.1f), new SFML.Graphics.Color(0, 128, 0).WithAlpha(180)); } _textSprite.Text = String.Format("Up: {0} kb/s.", Math.Round(totalSentBytes / totalMilliseconds, 6)); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - (4 * MaxDataPoints) - 100, (int)CluwneLib.CurrentRenderTarget.Size.Y - 30); _textSprite.Draw(); _textSprite.Text = String.Format("Down: {0} kb/s.", Math.Round(totalRecBytes / totalMilliseconds, 6)); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - (4 * MaxDataPoints) - 100, (int)CluwneLib.CurrentRenderTarget.Size.Y - 60); _textSprite.Draw(); }
private void ApplyHorizontalReduction(RenderImage source, RenderImage destination) { var step = reductionChainCount - 1; var src = source; var HorizontalReduction = reductionRT[step]; reductionEffectTechnique["HorizontalReduction"].setAsCurrentShader(); // Disabled GLTexture stuff for now just to get the pipeline working. // The only side effect is that floating point precision will be low, // making light borders and shit have jaggy edges. while (step >= 0) { HorizontalReduction = reductionRT[step]; // next step HorizontalReduction.BeginDrawing(); HorizontalReduction.Clear(Color.White); reductionEffectTechnique["HorizontalReduction"].SetUniform("TextureDimensions", 1.0f / src.Width); // Sourcetexture not needed... just blit! src.Blit(0, 0, HorizontalReduction.Width, HorizontalReduction.Height, BlitterSizeMode.Scale); // draw SRC to HR //fix HorizontalReduction.EndDrawing(); src = HorizontalReduction; // hr becomes new src step--; } CluwneLib.ResetShader(); //copy to destination destination.BeginDrawing(); destination.Clear(Color.White); HorizontalReduction.Blit(0, 0, destination.Height, destination.Width); destination.EndDrawing(); CluwneLib.ResetRenderTarget(); }
//Resets the rendertarget back to the screen public void ResetCurrentRenderTarget() { CluwneLib.ResetRenderTarget(); }
private void DrawGraph() { var totalRecBytes = 0; var totalSentBytes = 0; var totalMilliseconds = 0d; var totalRecPkts = 0; var totalSentPkts = 0; for (var i = 0; i < MaxDataPoints; i++) { if (_dataPoints.Count <= i) { continue; } totalMilliseconds += _dataPoints[i].ElapsedMilliseconds; totalRecBytes += _dataPoints[i].ReceivedBytes; totalSentBytes += _dataPoints[i].SentBytes; totalRecPkts += _dataPoints[i].ReceivedPkts; totalSentPkts += _dataPoints[i].SentPkts; CluwneLib.ResetRenderTarget(); CluwneLib.drawRectangle((int)CluwneLib.CurrentRenderTarget.Size.X - 2 * (MaxDataPoints - i) + 2, (int)CluwneLib.CurrentRenderTarget.Size.Y - (int)(_dataPoints[i].SentBytes * 0.1f), 2, (int)(_dataPoints[i].SentBytes * 0.2f), new Color(0, 128, 0, 255)); CluwneLib.drawRectangle((int)CluwneLib.CurrentRenderTarget.Size.X - 2 * (MaxDataPoints - i), (int)CluwneLib.CurrentRenderTarget.Size.Y - (int)(_dataPoints[i].ReceivedBytes * 0.1f), 2, (int)(_dataPoints[i].ReceivedBytes * 0.2f), new Color(255, 0, 0, 128)); } _textSprite.Text = string.Format("Up: {0:0.00} kb/s", Math.Round(totalSentBytes / totalMilliseconds, 2)); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 125, (int)CluwneLib.CurrentRenderTarget.Size.Y - 4 * _textSprite.Height - 5); _textSprite.Draw(); _textSprite.Text = string.Format("Down: {0:0.00} kb/s", Math.Round(totalRecBytes / totalMilliseconds, 2)); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 125, (int)CluwneLib.CurrentRenderTarget.Size.Y - 3 * _textSprite.Height - 5); _textSprite.Draw(); _textSprite.Text = string.Format("Out: {0} pkts", Math.Round(totalSentPkts / (totalMilliseconds / 1000))); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 125, (int)CluwneLib.CurrentRenderTarget.Size.Y - 2 * _textSprite.Height - 5); _textSprite.Draw(); _textSprite.Text = string.Format("In: {0} pkts", Math.Round(totalRecPkts / (totalMilliseconds / 1000))); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 125, (int)CluwneLib.CurrentRenderTarget.Size.Y - 1 * _textSprite.Height - 5); _textSprite.Draw(); _textSprite.Text = string.Format("Ping: {0}ms", _networkManager.ServerChannel?.Ping ?? -1); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 0, (int)CluwneLib.CurrentRenderTarget.Size.Y - 4 * _textSprite.Height - 5); _textSprite.Draw(); _textSprite.Text = string.Format("Frame Time: {0:0.00}ms ({1:0.00}FPS)", _timing.RealFrameTimeAvg.TotalMilliseconds, 1 / _timing.RealFrameTimeAvg.TotalSeconds); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 0, (int)CluwneLib.CurrentRenderTarget.Size.Y - 3 * _textSprite.Height - 5); _textSprite.Draw(); _textSprite.Text = string.Format("Frame SD: {0:0.00}ms", _timing.RealFrameTimeStdDev.TotalMilliseconds); _textSprite.Position = new Vector2i((int)CluwneLib.CurrentRenderTarget.Size.X - 4 * MaxDataPoints - 0, (int)CluwneLib.CurrentRenderTarget.Size.Y - 2 * _textSprite.Height - 5); _textSprite.Draw(); }