public void Drawing_ValidatingDistortionInput_CatchNullIndicesInput() { 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); var stage = Substitute.For <IDistortionStage>(); var request = new DistortionDrawRequest { Colour = Colour.White, CoordinateSpace = CoordinateSpace.Screen, FillType = FillType.Coloured, Indices = new int[] { 0, 1, 2 }, Texture0 = new TextureReference(1UL), Texture1 = new TextureReference(2UL), TextureWrap0 = TextureCoordinateMode.Mirror, TextureWrap1 = TextureCoordinateMode.Mirror, Vertices = new Vertex2D[] { new Vertex2D(), new Vertex2D(), new Vertex2D() } }; request.Indices = null; Assert.Throws <Yak2DException>(() => { drawing.DrawDistortion(stage, ref request, false); }); }
public void DrawDistortion(ulong stage, CoordinateSpace target, FillType type, Vertex2D[] vertices, int[] indices, Colour colour, ulong texture0, ulong texture1, TextureCoordinateMode texWrap0, TextureCoordinateMode texWrap1, float intensity, bool validate = false) { var request = new DistortionDrawRequest { CoordinateSpace = target, FillType = type, Vertices = vertices, Indices = indices, Colour = new Colour(colour.R * intensity, colour.G * intensity, colour.B * intensity, colour.A * intensity), Texture0 = WrapTextureId(texture0), Texture1 = WrapTextureId(texture1), TextureWrap0 = texWrap0, TextureWrap1 = texWrap1 }; DrawDistortion(stage, ref request, validate); }
public void DrawDistortion(IDistortionStage stage, ref DistortionDrawRequest request, bool validate = false) { if (stage == null) { throw new Yak2DException("Distortion Draw request failed. Null Draw Stage"); } DrawDistortion(stage.Id, ref request, validate); }
public void Drawing_CreatePersistentDistortQueue_CatchInvalidStage() { 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); var stage = Substitute.For <IDistortionStage>(); var requests = new DistortionDrawRequest[] { new DistortionDrawRequest { Colour = Colour.White, CoordinateSpace = CoordinateSpace.Screen, FillType = FillType.Coloured, Indices = new int[] { 0, 1, 2 }, Texture0 = new TextureReference(1UL), Texture1 = new TextureReference(2UL), TextureWrap0 = TextureCoordinateMode.Mirror, TextureWrap1 = TextureCoordinateMode.Mirror, Vertices = new Vertex2D[] { new Vertex2D(), new Vertex2D(), new Vertex2D() } } }; renderStageManager.RetrieveStageModel(Arg.Any <ulong>()).ReturnsNull(); Assert.Throws <Yak2DException>(() => { drawing.CreatePersistentDistortQueue(stage, requests, false); }); }
public void DrawDistortion(ulong stage, ref DistortionDrawRequest request, bool validate = false) { //Deeper validation, if requested, is done at queue level. //Light / null check validation is always performed at this level. //Note -> No validation steps ensure non-null/zero texture references have matching keys in texture collections if (request.FillType == FillType.Textured && (request.Texture0 == null || request.Texture0?.Id == 0UL)) { throw new Yak2DException("DistortionDraw request failed. Invalid Texture0 input"); } else if (request.FillType == FillType.DualTextured) { if (request.Texture0 == null || request.Texture0?.Id == 0UL || request.Texture1 == null || request.Texture1?.Id == 0UL) { throw new Yak2DException("DistortionDraw request failed. Invalid Texture input for dual texturing (textures either null or Ids are zero)"); } if (request.Texture0.Id == request.Texture1.Id) { throw new Yak2DException("DistortionDraw request failed. The same Texture cannot be used for both Textures during Dual Texturing"); } } if (request.Vertices == null) { throw new Yak2DException("DistortionDraw request failed. Null Vertex data"); } if (request.Indices == null) { throw new Yak2DException("DistortionDraw request failed. Null Index data"); } if (request.Texture0 == null) { request.Texture0 = new TextureReference(0UL); } if (request.Texture1 == null) { request.Texture1 = new TextureReference(0UL); } if (_cachedDistortionDrawStageKey != stage || _renderStageVisitor.CachedDistortionEffectStageModel == null) { _cachedDistortionDrawStageKey = stage; var model = _renderStageManager.RetrieveStageModel(_cachedDistortionDrawStageKey); if (model == null) { throw new Yak2DException("DistortionDraw request failed. Requested DistortionDrawStage does not exist"); } model.CacheInstanceInVisitor(_renderStageVisitor); } var t0 = request.Texture0.Id; var t1 = request.Texture1.Id; var depth = 0.0f; var layer = 0; _renderStageVisitor.CachedDistortionEffectStageModel?.DrawToDynamicQueue(ref request.CoordinateSpace, ref request.FillType, ref request.Colour, ref request.Vertices, ref request.Indices, ref t0, ref t1, ref request.TextureWrap0, ref request.TextureWrap1, ref depth, ref layer); }
public void DrawDistortion(ulong stage, DistortionDrawRequest request, bool validate = false) { DrawDistortion(stage, ref request, validate); }