public void DrawString(IDrawStage stage, CoordinateSpace target, string text, Colour colour, float fontSize, Vector2 position, TextJustify justify, float depth, int layer, IFont font = null, bool usKerningsWhereAvaliable = true) { var fntFamily = font == null ? _fontManager.SystemFont : _fontManager.RetrieveFont(font.Id); DrawString(stage.Id, ref target, ref text, colour, ref fontSize, ref position, ref justify, ref depth, ref layer, fntFamily, ref usKerningsWhereAvaliable); }
public void Drawing_ValidatingInput_CatchNullDrawStage() { var messenger = Substitute.For <IFrameworkMessenger>(); var renderStageManager = Substitute.For <IRenderStageManager>(); var renderStageVisitor = Substitute.For <IRenderStageVisitor>(); var fontManager = Substitute.For <IFontManager>(); var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>(); IDrawing drawing = new Drawing(messenger, renderStageManager, renderStageVisitor, fontManager, gpuSurfaceManager); IDrawStage stage = null; var request = new DrawRequest { Colour = Colour.White, CoordinateSpace = CoordinateSpace.Screen, Depth = 0.0f, FillType = FillType.Coloured, Indices = new int[] { 0, 1, 2 }, Layer = 0, Texture0 = new TextureReference(1UL), Texture1 = new TextureReference(2UL), TextureWrap0 = TextureCoordinateMode.Mirror, TextureWrap1 = TextureCoordinateMode.Mirror, Vertices = new Vertex2D[] { new Vertex2D(), new Vertex2D(), new Vertex2D() } }; Assert.Throws <Yak2DException>(() => { drawing.Draw(stage, ref request, false); }); }
public void Draw(IDrawStage stage, ICamera2D camera, IRenderTarget target) { if (stage == null) { throw new Yak2DException("Unable to queue DrawStage. Stage is null", new ArgumentNullException()); } if (camera == null) { throw new Yak2DException("Unable to queue DrawStage. Camera is null", new ArgumentNullException()); } if (target == null) { throw new Yak2DException("Unable to queue DrawStage. Target is null", new ArgumentNullException()); } _commandQueue.Add(RenderCommandType.DrawStage, stage.Id, target.Id, camera.Id, 0UL, 0UL, 0UL, 0UL, RgbaFloat.Clear); }
public void Draw(IDrawStage stage, CoordinateSpace target, FillType type, Vertex2D[] vertices, int[] indices, Colour colour, ITexture texture0, ITexture texture1, TextureCoordinateMode texWrap0, TextureCoordinateMode texWrap1, float depth, int layer, bool validate = false) { var request = new DrawRequest { CoordinateSpace = target, FillType = type, Vertices = vertices, Indices = indices, Colour = colour, Texture0 = texture0, Texture1 = texture1, TextureWrap0 = texWrap0, TextureWrap1 = texWrap1, Depth = depth, Layer = layer }; Draw(stage, ref request, validate); }
public IPersistentDrawQueue CreatePersistentDrawQueue(IDrawStage stage, DrawRequest[] requests, bool validate = false) { if (stage == null) { throw new Yak2DException("Unable to create persistent draw queue, null draw stage passed"); } return(CreatePersistentDrawQueue(stage.Id, requests, validate)); }
public void Draw(IDrawStage stage, ref DrawRequest request, bool validate = false) { if (stage == null) { throw new Yak2DException("Draw request failed. Null Draw Stage"); } Draw(stage.Id, ref request, validate); }
public void ClearDynamicDrawRequestQueue(IDrawStage stage) { if (stage == null) { throw new Yak2DException("Unable to clear dynamic draw queue, null draw stage provided"); } ClearDynamicDrawRequestQueue(stage.Id); }
public void RemovePersistentDrawQueue(IDrawStage stage, IPersistentDrawQueue queue) { if (stage == null) { throw new Yak2DException("Unable to remove persistent draw queue, null draw stage provided"); } if (queue == null) { throw new Yak2DException("Unable to remove persistent draw queue, null queue provided"); } RemovePersistentDrawQueue(stage.Id, queue.Id); }
public void DrawLine(IDrawStage drawStage, CoordinateSpace space, Vector2 from, Vector2 to, float width, Colour colour, float depth, int layer = 0, bool rounded = false) { var vertsAndIndices = Common.LineAndArrowVertexAndIndicesGenerator(from, to, width, rounded, true); DrawColouredVertsAndIndices(drawStage, vertsAndIndices, space, colour, depth, layer); }
public void DrawColouredPoly(IDrawStage drawStage, CoordinateSpace space, Colour colour, Vector2 position, int numSides, float radius, float depth, int layer = 0, float xScaling = 1.0f, float yScaling = 1.0f, float rotation_clockwise_radians = 0.0f) { var verticesAndIndices = Common.RegularPolygonVertexAndIndicesGenerator(Vector2.Zero, numSides, radius); var numVertices = numSides + 1; var vertices = new Vertex2D[numVertices]; for (var v = 0; v < numVertices; v++) { var pos = verticesAndIndices.Item1[v]; pos.X *= xScaling; pos.Y *= yScaling; pos = Common.RotateVectorClockwise(ref pos, rotation_clockwise_radians); pos += position; vertices[v] = new Vertex2D { Position = pos, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, Colour = Colour.White, TexWeighting = 1.0f }; } _drawing.Draw(drawStage, space, FillType.Coloured, vertices, verticesAndIndices.Item2, colour, null, null, TextureCoordinateMode.None, TextureCoordinateMode.None, depth, layer); }
//Usage (Vertex2Ds are created and vertices are finally positioned. Previously all relative to single position point to enable transforms) public void SubmitDraw(IDrawStage drawStage, CoordinateSpace space, float depth, int layer) { _drawing.Draw(drawStage, space, _fill, CreateVerticesInFinalPosition(), _indices, _colour, _texture0.Texture, _texture1.Texture, _texture0.TextureMode, _texture1.TextureMode, depth, layer); }
public void DrawTexturedQuad(IDrawStage drawStage, CoordinateSpace space, ITexture texture, Colour colour, Vector2 position, float width, float height, float depth, int layer = 0, float rotation_clockwise_radians = 0.0f, float texcoord_min_x = 0.0f, float texcoord_min_y = 0.0f, float texcoord_max_x = 1.0f, float texcoord_max_y = 1.0f, TextureCoordinateMode textureMode = TextureCoordinateMode.Wrap) { var halfSize = 0.5f * new Vector2(width, height); _drawing.Draw(drawStage, space, FillType.Textured, new Vertex2D[] { new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(-halfSize.X, halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_min_x, texcoord_min_y), TexCoord1 = new Vector2(0.0f, 0.0f), TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(halfSize.X, halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_max_x, texcoord_min_y), TexCoord1 = new Vector2(1.0f, 0.0f), TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(-halfSize.X, -halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_min_x, texcoord_max_y), TexCoord1 = new Vector2(0.0f, 1.0f), TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(halfSize.X, -halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_max_x, texcoord_max_y), TexCoord1 = new Vector2(1.0f, 1.0f), TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, }, new int[] { 0, 1, 2, 2, 1, 3 }, colour, texture, null, textureMode, TextureCoordinateMode.None, depth, layer); }
public void DrawColouredQuad(IDrawStage drawStage, CoordinateSpace space, Colour colour, Vector2 position, float width, float height, float depth, int layer = 0, float rotation_clockwise_radians = 0.0f) { var halfSize = 0.5f * new Vector2(width, height); _drawing.Draw(drawStage, space, FillType.Coloured, new Vertex2D[] { new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(-halfSize.X, halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(halfSize.X, halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(-halfSize.X, -halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, new Vertex2D { Position = Common.RotateVectorClockwise(new Vector2(halfSize.X, -halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f) }, }, new int[] { 0, 1, 2, 2, 1, 3 }, colour, null, null, TextureCoordinateMode.None, TextureCoordinateMode.None, depth, layer); }
private void DrawColouredVertsAndIndices(IDrawStage drawStage, Tuple <Vector2[], int[]> vertsAndIndices, CoordinateSpace space, Colour colour, float depth, int layer) { _drawing.Draw(drawStage, space, FillType.Coloured, vertsAndIndices.Item1.Select(v => new Vertex2D { Position = v, Colour = Colour.White, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 1.0f }).ToArray(), vertsAndIndices.Item2, colour, null, null, TextureCoordinateMode.None, TextureCoordinateMode.None, depth, layer); }
public void Draw(IDrawStage stage, DrawRequest request, bool validate = false) { Draw(stage, ref request, validate); }