public IPersistentDrawQueue CreatePersistentDrawQueue(ulong stage, DrawRequest[] requests, bool validate = false) { if (requests == null || requests.Length == 0) { throw new Yak2DException("Unable to create persistent draw queue, null or zero length requests array passed"); } var internalRequests = new InternalDrawRequest[requests.Length]; for (var r = 0; r < requests.Length; r++) { if (requests[r].FillType == FillType.DualTextured) { if (requests[r].Texture0 == requests[r].Texture1) { throw new Yak2DException("Unable to create persistent draw queue, Dual Texturing must use two unique textures"); } } internalRequests[r] = new InternalDrawRequest { CoordinateSpace = requests[r].CoordinateSpace, FillType = requests[r].FillType, Vertices = requests[r].Vertices, Indices = requests[r].Indices, Colour = requests[r].Colour, Texture0 = requests[r].Texture0 == null ? 0UL : requests[r].Texture0.Id, Texture1 = requests[r].Texture1 == null ? 0UL : requests[r].Texture1.Id, TextureMode0 = requests[r].TextureWrap0, TextureMode1 = requests[r].TextureWrap1, Depth = requests[r].Depth, Layer = requests[r].Layer }; } if (CacheRenderStageModelInVisitor(stage)) { return(_renderStageVisitor.CachedDrawStageModel?.AddPersistentQueue(internalRequests, validate)); } else { throw new Yak2DException("Unable to create persistent draw queue, draw stage provided was invalid"); } }
public IPersistentDistortionQueue CreatePersistentDistortQueue(ulong stage, DistortionDrawRequest[] requests, bool validate = false) { if (requests == null || requests.Length == 0) { throw new Yak2DException("Unable to create persistent distortion draw queue, null or zero length requests array passed"); } var drawRequests = new InternalDrawRequest[requests.Length]; for (var r = 0; r < requests.Length; r++) { drawRequests[r] = new InternalDrawRequest { CoordinateSpace = requests[r].CoordinateSpace, FillType = requests[r].FillType, Vertices = requests[r].Vertices, Indices = requests[r].Indices, Colour = requests[r].Colour, Texture0 = requests[r].Texture0.Id, Texture1 = requests[r].Texture1.Id, TextureMode0 = requests[r].TextureWrap0, TextureMode1 = requests[r].TextureWrap1, Depth = 0.0f, Layer = 0 }; } if (CacheRenderStageModelInVisitor(stage)) { var drawQueueTag = _renderStageVisitor.CachedDistortionEffectStageModel?.AddPersistentQueue(drawRequests, validate); return(new PersistentDistortionQueueReference(drawQueueTag.Id)); } else { throw new Yak2DException("Unable to create persistent distortion draw queue, draw stage provided was invalid"); } }