Draws shapes, images and geometries. Framework independent, but needs a graphic device.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Graphics Drawing
Namespace: DeltaEngine.Graphics
Assembly: DeltaEngine.Graphics (in DeltaEngine.Graphics.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Drawing type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Drawing | Initializes a new instance of the Drawing class |
Methods
Name | Description | |
---|---|---|
Add T (Material, T , Int16 , Int32, Int32) |
Adds presorted material DrawableEntities calls. Rendering happens after all vertices have
been added at the end of the frame in .
DrawEverythingInCurrentLayer View code on GitHub | |
Add T (Material, BlendMode, T , Int16 , Int32, Int32) | ||
AddGeometry | ||
AddLines T | ||
Dispose | Releases all resources used by the Drawing | |
FlushDrawBuffer |
Properties
Name | Description | |
---|---|---|
NumberOfDynamicDrawCallsThisFrame | ||
NumberOfDynamicVerticesDrawnThisFrame | ||
ViewportPixelSize |
Remarks
Examples
/// <summary> /// Proof that 30k lines can be rendered with up to 3000fps in a small window, fast GPU. Even /// 1000fps means that 30 million lines are drawn each second. More than 30k lines are possible /// with multiple draw calls, but causes multiple CircularBuffer flushes and thus not faster. /// </summary> [Test, Category("Slow")] public void Draw30000LinesPerFrame() { var manyLines = new DrawingTests.Line(Vector2D.Zero, new Vector2D(1280, 720), Color.Red); const int NumberOfRandomLines = 30000; var vertices = new VertexPosition2DColor[2 * NumberOfRandomLines]; var random = Randomizer.Current; var viewport = Resolve<Window>().ViewportPixelSize; for (int i = 0; i < NumberOfRandomLines; i++) { var startPoint = new Vector2D(random.Get(0, viewport.Width), random.Get(0, viewport.Height)); var endPoint = startPoint + new Vector2D(random.Get(-50, 50), random.Get(-50, 50)); vertices[i * 2 + 0] = new VertexPosition2DColor(startPoint, Color.GetRandomColor()); vertices[i * 2 + 1] = new VertexPosition2DColor(endPoint, Color.GetRandomColor()); } manyLines.Set(vertices); }
/// <summary> /// Draws 100*100 small images (=10000 images =20000 polygons) 50 times a frame to reach 1 million /// polygons drawn per frame. Can reach 100fps or more, which means 100 million polygons per second. /// </summary> [Test, Category("Slow")] public void DrawImagesWithOneMillionPolygonsPerFrame() { var verticesAndIndices = CreateVerticesAndIndices(); verticesAndIndices.OnDraw<RenderOneMillionPolygons>(); }
[Test, ApproveFirstFrameScreenshot] public void DrawRedLine() { new Line(Vector2D.Zero, new Vector2D(1280, 720), Color.Red); RunAfterFirstFrame( () => Assert.AreEqual(2, Resolve<Drawing>().NumberOfDynamicVerticesDrawnThisFrame)); }
See Also